1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013 Cyril Roelandt <tipecaml@gmail.com>
3 ;;; Copyright © 2014 Raimon Grau <raimonster@gmail.com>
4 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
5 ;;; Copyright © 2014 Andreas Enge <andreas@enge.fr>
6 ;;; Copyright © 2016, 2017, 2020 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2016, 2019 Ricardo Wurmus <rekado@elephly.net>
8 ;;; Copyright © 2016 doncatnip <gnopap@gmail.com>
9 ;;; Copyright © 2016, 2017, 2019 Clément Lassieur <clement@lassieur.org>
10 ;;; Copyright © 2016 José Miguel Sánchez García <jmi2k@openmailbox.org>
11 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
12 ;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com>
14 ;;; This file is part of GNU Guix.
16 ;;; GNU Guix is free software; you can redistribute it and/or modify it
17 ;;; under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 3 of the License, or (at
19 ;;; your option) any later version.
21 ;;; GNU Guix is distributed in the hope that it will be useful, but
22 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
29 (define-module (gnu packages lua)
30 #:use-module ((guix licenses) #:prefix license:)
31 #:use-module (guix packages)
32 #:use-module (guix download)
33 #:use-module (guix git-download)
34 #:use-module (guix utils)
35 #:use-module (guix build-system gnu)
36 #:use-module (guix build-system cmake)
37 #:use-module (gnu packages)
38 #:use-module (gnu packages readline)
39 #:use-module (gnu packages tls)
40 #:use-module (gnu packages xml)
41 #:use-module (gnu packages glib)
42 #:use-module (gnu packages libevent)
43 #:use-module (gnu packages libffi)
44 #:use-module (gnu packages pkg-config)
45 #:use-module (gnu packages xorg)
46 #:use-module (gnu packages gtk))
54 (uri (string-append "https://www.lua.org/ftp/lua-"
57 (base32 "1b2qn2rv96nmbm6zab4l877bd4zq7wpwm8drwjiy2ih4jqzysbhc"))
58 (patches (search-patches "lua-pkgconfig.patch"
59 "lua-liblua-so.patch"))))
60 (build-system gnu-build-system)
61 (inputs `(("readline" ,readline)))
63 '(#:modules ((guix build gnu-build-system)
68 '("MYCFLAGS=-fPIC -DLUA_DL_DLOPEN"
71 (modify-phases %standard-phases
74 (lambda* (#:key outputs #:allow-other-keys)
75 (let ((out (assoc-ref outputs "out")))
76 (invoke "make" "install"
77 (string-append "INSTALL_TOP=" out)
78 (string-append "INSTALL_MAN=" out
79 "/share/man/man1"))))))))
80 (home-page "https://www.lua.org/")
81 (synopsis "Embeddable scripting language")
83 "Lua is a powerful, fast, lightweight, embeddable scripting language. Lua
84 combines simple procedural syntax with powerful data description constructs
85 based on associative arrays and extensible semantics. Lua is dynamically typed,
86 runs by interpreting bytecode for a register-based virtual machine, and has
87 automatic memory management with incremental garbage collection, making it ideal
88 for configuration, scripting, and rapid prototyping.")
89 (license license:x11)))
91 (define-public lua-5.2
92 (package (inherit lua)
97 (uri (string-append "https://www.lua.org/ftp/lua-"
100 (base32 "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr"))
101 (patches (search-patches "lua-pkgconfig.patch"
102 "lua-liblua-so.patch"))))))
104 (define-public lua-5.1
105 (package (inherit lua)
109 (uri (string-append "https://www.lua.org/ftp/lua-"
112 (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))
113 (patches (search-patches "lua51-liblua-so.patch"
114 "lua-CVE-2014-5461.patch"
115 "lua51-pkgconfig.patch"))))))
117 (define-public luajit
120 (version "2.1.0-beta3")
123 (uri (string-append "http://luajit.org/download/LuaJIT-"
126 (base32 "1hyrhpkwjqsv54hnnx4cl8vk44h9d6c9w0fz1jfjz00w255y7lhs"))
127 (patches (search-patches "luajit-no_ldconfig.patch"))))
128 (build-system gnu-build-system)
130 `(#:tests? #f ; luajit is distributed without tests
132 (modify-phases %standard-phases
133 (delete 'configure) ; no configure script
134 (add-after 'install 'create-luajit-symlink
135 (lambda* (#:key outputs #:allow-other-keys)
136 (let* ((out (assoc-ref outputs "out"))
137 (bin (string-append out "/bin")))
138 (with-directory-excursion bin
139 (symlink ,(string-append name "-" version)
142 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))))
143 (home-page "https://www.luajit.org/")
144 (synopsis "Just in time compiler for Lua programming language version 5.1")
146 "LuaJIT is a Just-In-Time Compiler (JIT) for the Lua
147 programming language. Lua is a powerful, dynamic and light-weight programming
148 language. It may be embedded or used as a general-purpose, stand-alone
150 (license license:x11)))
152 (define (make-lua-expat name lua)
158 (uri (string-append "https://matthewwild.co.uk/projects/"
159 "luaexpat/luaexpat-" version ".tar.gz"))
162 "1hvxqngn0wf5642i5p3vcyhg3pmp102k63s9ry4jqyyqc1wkjq6h"))))
163 (build-system gnu-build-system)
166 (let ((out (assoc-ref %outputs "out"))
167 (lua-version ,(version-major+minor (package-version lua))))
169 (string-append "LUA_LDIR=" out "/share/lua/" lua-version)
170 (string-append "LUA_CDIR=" out "/lib/lua/" lua-version)))
172 (modify-phases %standard-phases
176 (setenv "LUA_CPATH" "src/?.so;;")
177 (setenv "LUA_PATH" "src/?.lua;;")
178 (invoke "lua" "tests/test.lua")
179 (invoke "lua" "tests/test-lom.lua"))))))
183 (home-page "http://matthewwild.co.uk/projects/luaexpat/")
184 (synopsis "SAX XML parser based on the Expat library")
185 (description "LuaExpat is a SAX XML parser based on the Expat library.")
186 (license (package-license lua-5.1))))
188 (define-public lua5.1-expat
189 (make-lua-expat "lua5.1-expat" lua-5.1))
191 (define-public lua5.2-expat
192 (make-lua-expat "lua5.2-expat" lua-5.2))
194 (define (make-lua-socket name lua)
201 "https://github.com/diegonehab/luasocket/archive/v"
203 (file-name (string-append name "-" version ".tar.gz"))
206 "0j8jx8bjicvp9khs26xjya8c495wrpb7parxfnabdqa5nnsxjrwb"))))
207 (build-system gnu-build-system)
210 (let ((out (assoc-ref %outputs "out"))
211 (lua-version ,(version-major+minor (package-version lua))))
212 (list (string-append "INSTALL_TOP=" out)
213 (string-append "LUAV?=" lua-version)))
215 (modify-phases %standard-phases
219 (setenv "LUA_CPATH" (string-append "src/?.so." ,version ";;"))
220 (setenv "LUA_PATH" "src/?.lua;;")
221 (when (zero? (primitive-fork))
222 (invoke "lua" "test/testsrvr.lua"))
223 (invoke "lua" "test/testclnt.lua"))))))
226 (home-page "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/")
227 (synopsis "Socket library for Lua")
228 (description "LuaSocket is a Lua extension library that is composed by two
229 parts: a C core that provides support for the TCP and UDP transport layers,
230 and a set of Lua modules that add support for functionality commonly needed by
231 applications that deal with the Internet.
233 Among the supported modules, the most commonly used implement the
234 SMTP (sending e-mails), HTTP (WWW access) and FTP (uploading and downloading
235 files) client protocols. These provide a very natural and generic interface
236 to the functionality defined by each protocol. In addition, you will find
237 that the MIME (common encodings), URL (anything you could possible want to do
238 with one) and LTN12 (filters, sinks, sources and pumps) modules can be very
240 (license license:expat)))
242 (define-public lua5.1-socket
243 (make-lua-socket "lua5.1-socket" lua-5.1))
245 (define-public lua5.2-socket
246 (make-lua-socket "lua5.2-socket" lua-5.2))
248 (define (make-lua-filesystem name lua)
255 (url "https://github.com/keplerproject/luafilesystem")
256 (commit (string-append "v_"
258 (string-split version #\.) "_")))))
259 (file-name (git-file-name name version))
262 "1hxcnqj53540ysyw8fzax7f09pl98b8f55s712gsglcdxp2g2pri"))))
263 (build-system gnu-build-system)
266 (let ((out (assoc-ref %outputs "out"))
267 (lua-version ,(version-major+minor (package-version lua))))
268 (list (string-append "PREFIX=" out)
269 (string-append "LUA_LIBDIR=" out "/lib/lua/" lua-version)))
272 (modify-phases %standard-phases
273 (delete 'configure))))
276 (home-page "https://keplerproject.github.io/luafilesystem/index.html")
277 (synopsis "File system library for Lua")
278 (description "LuaFileSystem is a Lua library developed to complement the
279 set of functions related to file systems offered by the standard Lua
280 distribution. LuaFileSystem offers a portable way to access the underlying
281 directory structure and file attributes.")
282 (license (package-license lua-5.1))))
284 (define-public lua-filesystem
285 (make-lua-filesystem "lua-filesystem" lua))
287 (define-public lua5.1-filesystem
288 (make-lua-filesystem "lua5.1-filesystem" lua-5.1))
290 (define-public lua5.2-filesystem
291 (make-lua-filesystem "lua5.2-filesystem" lua-5.2))
293 (define (make-lua-sec name lua)
299 (uri (string-append "https://github.com/brunoos/luasec/archive/"
300 "luasec-" version ".tar.gz"))
303 "0c9sdz3gvrsbvvdqzpnsappgwl40hfljlpfybqis6wia3mdyjxi1"))))
304 (build-system gnu-build-system)
307 (let ((out (assoc-ref %outputs "out"))
308 (lua-version ,(version-major+minor (package-version lua))))
312 (string-append "LUAPATH=" out "/share/lua/" lua-version)
313 (string-append "LUACPATH=" out "/lib/lua/" lua-version)))
314 #:tests? #f ; no tests included
316 (modify-phases %standard-phases
317 (delete 'configure))))
320 ("openssl" ,openssl)))
324 (format #f "lua~a-socket"
325 (version-major+minor (package-version lua))) lua))))
326 (home-page "https://github.com/brunoos/luasec/wiki")
327 (synopsis "OpenSSL bindings for Lua")
328 (description "LuaSec is a binding for OpenSSL library to provide TLS/SSL
329 communication. It takes an already established TCP connection and creates a
330 secure session between the peers.")
331 (license license:expat)))
333 (define-public lua5.1-sec
334 (make-lua-sec "lua5.1-sec" lua-5.1))
336 (define-public lua5.2-sec
337 (make-lua-sec "lua5.2-sec" lua-5.2))
339 (define-public lua-lgi
347 "https://github.com/pavouk/lgi/archive/"
349 (file-name (string-append name "-" version ".tar.gz"))
352 "0kwcaj3ahi9gxfyp0lr5zgr6vi1mgsg9sz0980x0nwxlh9a11i6g"))))
353 (build-system gnu-build-system)
355 '(#:make-flags (list "CC=gcc"
356 (string-append "PREFIX=" (assoc-ref %outputs "out")))
358 (modify-phases %standard-phases
359 (delete 'configure) ; no configure script
360 (add-before 'build 'set-env
361 (lambda* (#:key inputs #:allow-other-keys)
362 ;; we need to load cairo dynamically
363 (let* ((cairo (string-append
364 (assoc-ref inputs "cairo") "/lib" )))
365 (setenv "LD_LIBRARY_PATH" cairo)
367 (add-before 'build 'set-lua-version
369 ;; lua version and therefore install directories are hardcoded
370 ;; FIXME: This breaks when we update lua to >=5.3
371 (substitute* "./lgi/Makefile"
372 (("LUA_VERSION=5.1") "LUA_VERSION=5.2"))
374 (add-before 'check 'skip-test-gtk
376 ;; FIXME: Skip GTK tests:
377 ;; gtk3 - can't get it to run with the xorg-server config below
378 ;; and some non-gtk tests will also fail
379 ;; gtk2 - lots of functions aren't implemented
380 ;; We choose gtk2 as the lesser evil and simply skip the test.
381 ;; Currently, awesome is the only package that uses lua-lgi but
382 ;; it doesn't need or interact with GTK using lua-lgi.
383 (substitute* "./tests/test.lua"
384 (("'gtk.lua',") "-- 'gtk.lua',"))
386 (add-before 'check 'start-xserver-instance
387 (lambda* (#:key inputs #:allow-other-keys)
388 ;; There must be a running X server during tests.
389 (system (format #f "~a/bin/Xvfb :1 &"
390 (assoc-ref inputs "xorg-server")))
391 (setenv "DISPLAY" ":1")
394 `(("gobject-introspection" ,gobject-introspection)
401 ("xorg-server" ,xorg-server)))
403 `(("pkg-config" ,pkg-config)
404 ("dbus" ,dbus))) ;tests use 'dbus-run-session'
405 (home-page "https://github.com/pavouk/lgi/")
406 (synopsis "Lua bridge to GObject based libraries")
408 "LGI is gobject-introspection based dynamic Lua binding to GObject
409 based libraries. It allows using GObject-based libraries directly from Lua.
410 Notable examples are GTK+, GStreamer and Webkit.")
411 (license license:expat)))
413 (define (make-lua-lpeg name lua)
419 (uri (string-append "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-"
422 (base32 "1zjzl7acvcdavmcg5l7wi12jd4rh95q9pl5aiww7hv0v0mv6bmj8"))))
423 (build-system gnu-build-system)
426 (modify-phases %standard-phases
428 ;; `make install` isn't available, so we have to do it manually
430 (lambda* (#:key outputs #:allow-other-keys)
431 (let ((out (assoc-ref outputs "out"))
432 (lua-version ,(version-major+minor (package-version lua))))
433 (install-file "lpeg.so"
434 (string-append out "/lib/lua/" lua-version))
435 (install-file "re.lua"
436 (string-append out "/share/lua/" lua-version))
438 #:test-target "test"))
439 (inputs `(("lua" ,lua)))
440 (synopsis "Pattern-matching library for Lua")
442 "LPeg is a pattern-matching library for Lua, based on Parsing Expression
444 (home-page "http://www.inf.puc-rio.br/~roberto/lpeg")
445 (license license:expat)))
447 (define-public lua-lpeg
448 (make-lua-lpeg "lua-lpeg" lua))
450 (define-public lua5.1-lpeg
451 (make-lua-lpeg "lua5.1-lpeg" lua-5.1))
453 (define-public lua5.2-lpeg
454 (make-lua-lpeg "lua5.2-lpeg" lua-5.2))
456 (define (make-lua-luv name lua)
461 ;; The release tarball includes the sources of libuv but does
462 ;; not include the pkg-config files.
465 (url "https://github.com/luvit/luv.git")
467 (file-name (git-file-name name version))
470 "0b2zxrsjxzhzwfp28lchplrp272v6zkbpq1ddz7a0rf20l7dbls1"))))
471 (build-system cmake-build-system)
473 `(#:tests? #f ; there are none
475 '("-DWITH_LUA_ENGINE=Lua"
476 "-DWITH_SHARED_LIBUV=On"
478 "-DBUILD_SHARED_LIBS=On"
479 "-DLUA_BUILD_TYPE=System")
481 (modify-phases %standard-phases
482 (add-after 'unpack 'copy-lua-compat
483 (lambda* (#:key inputs #:allow-other-keys)
484 (copy-recursively (assoc-ref inputs "lua-compat")
487 (string-append (getcwd) "/lua-compat:"
488 (or (getenv "CPATH") "")))
498 (url "https://github.com/keplerproject/lua-compat-5.3.git")
499 (commit "daebe77a2f498817713df37f0bb316db1d82222f")))
500 (file-name "lua-compat-5.3-checkout")
503 "02a14nvn7aggg1yikj9h3dcf8aqjbxlws1bfvqbpfxv9d5phnrpz"))))))
504 (home-page "https://github.com/luvit/luv/")
505 (synopsis "Libuv bindings for Lua")
507 "This library makes libuv available to Lua scripts.")
508 (license license:asl2.0)))
510 (define-public lua-luv
511 (make-lua-luv "lua-luv" lua))
513 (define-public lua5.1-luv
514 (make-lua-luv "lua5.1-luv" lua-5.1))
516 (define-public lua5.2-luv
517 (make-lua-luv "lua5.2-luv" lua-5.2))
519 ;; Lua 5.3 is not supported.
520 (define (make-lua-bitop name lua)
526 (uri (string-append "http://bitop.luajit.org/download/"
527 "LuaBitOp-" version ".tar.gz"))
530 "16fffbrgfcw40kskh2bn9q7m3gajffwd2f35rafynlnd7llwj1qj"))))
531 (build-system gnu-build-system)
533 `(#:test-target "test"
535 (list "INSTALL=install -pD"
536 (string-append "INSTALLPATH=printf "
537 (assoc-ref %outputs "out")
539 ,(version-major+minor (package-version lua))
542 (modify-phases %standard-phases
543 (delete 'configure))))
544 (inputs `(("lua" ,lua)))
545 (home-page "https://bitop.luajit.org/index.html")
546 (synopsis "Bitwise operations on numbers for Lua")
548 "Lua BitOp is a C extension module for Lua which adds bitwise operations
550 (license license:expat)))
552 (define-public lua5.2-bitop
553 (make-lua-bitop "lua5.2-bitop" lua-5.2))
555 (define-public lua5.1-bitop
556 (make-lua-bitop "lua5.1-bitop" lua-5.1))
558 (define-public selene
561 (version "2017.08.25")
565 (url "https://github.com/jeremyong/Selene.git")
566 ;; The release is quite old.
567 (commit "ffe1ade2568d4cff5894552be8f43e63e379a4c9")))
571 "1axrgv3rxxdsaf807lwvklfzicn6x6gpf35narllrnz9lg6hn508"))))
572 (build-system cmake-build-system)
575 ;; lua pc file in CMakeLists.txt is lua5.3.pc
576 '("-DLUA_PC_CFG=lua;lua-5.3;lua-5.1")
579 ;; This is a header only library
580 (modify-phases %standard-phases
583 (lambda* (#:key inputs outputs #:allow-other-keys)
584 (let* ((output (assoc-ref outputs "out"))
585 (source (assoc-ref inputs "source"))
586 (includedir (string-append output "/include")))
588 (string-append source "/include")
591 ;; The path of test files are hard coded.
593 (lambda* (#:key inputs outputs #:allow-other-keys)
594 (let* ((output (assoc-ref outputs "out"))
595 (source (assoc-ref inputs "source"))
597 (testdir (string-append builddir "/test")))
598 (copy-recursively (string-append source "/test") testdir)
601 (copy-file "./test_runner" "./runner/test_runner")
603 (invoke "./test_runner")))))))
606 ("pkg-config" ,pkg-config)))
607 (home-page "https://github.com/jeremyong/Selene")
608 (synopsis "Lua C++11 bindings")
610 "Selene is a simple C++11 header-only library enabling seamless
611 interoperability between C++ and Lua programming language.")
612 (license license:zlib)))