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>
13 ;;; Copyright © 2020 Nicolas Goaziou <mail@nicolasgoaziou.fr>
15 ;;; This file is part of GNU Guix.
17 ;;; GNU Guix is free software; you can redistribute it and/or modify it
18 ;;; under the terms of the GNU General Public License as published by
19 ;;; the Free Software Foundation; either version 3 of the License, or (at
20 ;;; your option) any later version.
22 ;;; GNU Guix is distributed in the hope that it will be useful, but
23 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
24 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 ;;; GNU General Public License for more details.
27 ;;; You should have received a copy of the GNU General Public License
28 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
30 (define-module (gnu packages lua)
31 #:use-module ((guix licenses) #:prefix license:)
32 #:use-module (guix packages)
33 #:use-module (guix download)
34 #:use-module (guix git-download)
35 #:use-module (guix utils)
36 #:use-module (guix build-system gnu)
37 #:use-module (guix build-system cmake)
38 #:use-module (guix build-system trivial)
39 #:use-module (gnu packages)
40 #:use-module (gnu packages readline)
41 #:use-module (gnu packages tls)
42 #:use-module (gnu packages xml)
43 #:use-module (gnu packages glib)
44 #:use-module (gnu packages libevent)
45 #:use-module (gnu packages libffi)
46 #:use-module (gnu packages pkg-config)
47 #:use-module (gnu packages xorg)
48 #:use-module (gnu packages gtk))
56 (uri (string-append "https://www.lua.org/ftp/lua-"
59 (base32 "1b2qn2rv96nmbm6zab4l877bd4zq7wpwm8drwjiy2ih4jqzysbhc"))
60 (patches (search-patches "lua-pkgconfig.patch"
61 "lua-liblua-so.patch"))))
62 (build-system gnu-build-system)
63 (inputs `(("readline" ,readline)))
65 '(#:modules ((guix build gnu-build-system)
70 '("MYCFLAGS=-fPIC -DLUA_DL_DLOPEN"
73 (modify-phases %standard-phases
76 (lambda* (#:key outputs #:allow-other-keys)
77 (let ((out (assoc-ref outputs "out")))
78 (invoke "make" "install"
79 (string-append "INSTALL_TOP=" out)
80 (string-append "INSTALL_MAN=" out
81 "/share/man/man1"))))))))
82 (home-page "https://www.lua.org/")
83 (synopsis "Embeddable scripting language")
85 "Lua is a powerful, fast, lightweight, embeddable scripting language. Lua
86 combines simple procedural syntax with powerful data description constructs
87 based on associative arrays and extensible semantics. Lua is dynamically typed,
88 runs by interpreting bytecode for a register-based virtual machine, and has
89 automatic memory management with incremental garbage collection, making it ideal
90 for configuration, scripting, and rapid prototyping.")
91 (license license:x11)))
93 (define-public lua-5.2
94 (package (inherit lua)
99 (uri (string-append "https://www.lua.org/ftp/lua-"
102 (base32 "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr"))
103 (patches (search-patches "lua-pkgconfig.patch"
104 "lua-liblua-so.patch"))))))
106 (define-public lua-5.1
107 (package (inherit lua)
111 (uri (string-append "https://www.lua.org/ftp/lua-"
114 (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))
115 (patches (search-patches "lua51-liblua-so.patch"
116 "lua-CVE-2014-5461.patch"
117 "lua51-pkgconfig.patch"))))))
119 (define-public luajit
122 (version "2.1.0-beta3")
125 (uri (string-append "http://luajit.org/download/LuaJIT-"
128 (base32 "1hyrhpkwjqsv54hnnx4cl8vk44h9d6c9w0fz1jfjz00w255y7lhs"))
129 (patches (search-patches "luajit-no_ldconfig.patch"))))
130 (build-system gnu-build-system)
132 `(#:tests? #f ; luajit is distributed without tests
134 (modify-phases %standard-phases
135 (delete 'configure) ; no configure script
136 (add-after 'install 'create-luajit-symlink
137 (lambda* (#:key outputs #:allow-other-keys)
138 (let* ((out (assoc-ref outputs "out"))
139 (bin (string-append out "/bin")))
140 (with-directory-excursion bin
141 (symlink ,(string-append name "-" version)
144 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))))
145 (home-page "https://www.luajit.org/")
146 (synopsis "Just in time compiler for Lua programming language version 5.1")
148 "LuaJIT is a Just-In-Time Compiler (JIT) for the Lua
149 programming language. Lua is a powerful, dynamic and light-weight programming
150 language. It may be embedded or used as a general-purpose, stand-alone
152 (license license:x11)))
154 (define (make-lua-expat name lua)
160 (uri (string-append "https://matthewwild.co.uk/projects/"
161 "luaexpat/luaexpat-" version ".tar.gz"))
164 "1hvxqngn0wf5642i5p3vcyhg3pmp102k63s9ry4jqyyqc1wkjq6h"))))
165 (build-system gnu-build-system)
168 (let ((out (assoc-ref %outputs "out"))
169 (lua-version ,(version-major+minor (package-version lua))))
171 (string-append "LUA_LDIR=" out "/share/lua/" lua-version)
172 (string-append "LUA_CDIR=" out "/lib/lua/" lua-version)))
174 (modify-phases %standard-phases
178 (setenv "LUA_CPATH" "src/?.so;;")
179 (setenv "LUA_PATH" "src/?.lua;;")
180 (invoke "lua" "tests/test.lua")
181 (invoke "lua" "tests/test-lom.lua"))))))
185 (home-page "http://matthewwild.co.uk/projects/luaexpat/")
186 (synopsis "SAX XML parser based on the Expat library")
187 (description "LuaExpat is a SAX XML parser based on the Expat library.")
188 (license (package-license lua-5.1))))
190 (define-public lua5.1-expat
191 (make-lua-expat "lua5.1-expat" lua-5.1))
193 (define-public lua5.2-expat
194 (make-lua-expat "lua5.2-expat" lua-5.2))
196 (define (make-lua-socket name lua)
203 (url "https://github.com/diegonehab/luasocket")
204 (commit (string-append "v" version))))
205 (file-name (git-file-name name version))
208 "1chs7z7a3i3lck4x7rz60ziwbf793gw169hpjdfca8y4yf1hzsxk"))))
209 (build-system gnu-build-system)
212 (let ((out (assoc-ref %outputs "out"))
213 (lua-version ,(version-major+minor (package-version lua))))
214 (list (string-append "INSTALL_TOP=" out)
215 (string-append "LUAV?=" lua-version)))
217 (modify-phases %standard-phases
221 (setenv "LUA_CPATH" (string-append "src/?.so." ,version ";;"))
222 (setenv "LUA_PATH" "src/?.lua;;")
223 (when (zero? (primitive-fork))
224 (invoke "lua" "test/testsrvr.lua"))
225 (invoke "lua" "test/testclnt.lua"))))))
228 (home-page "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/")
229 (synopsis "Socket library for Lua")
230 (description "LuaSocket is a Lua extension library that is composed by two
231 parts: a C core that provides support for the TCP and UDP transport layers,
232 and a set of Lua modules that add support for functionality commonly needed by
233 applications that deal with the Internet.
235 Among the supported modules, the most commonly used implement the
236 SMTP (sending e-mails), HTTP (WWW access) and FTP (uploading and downloading
237 files) client protocols. These provide a very natural and generic interface
238 to the functionality defined by each protocol. In addition, you will find
239 that the MIME (common encodings), URL (anything you could possible want to do
240 with one) and LTN12 (filters, sinks, sources and pumps) modules can be very
242 (license license:expat)))
244 (define-public lua5.1-socket
245 (make-lua-socket "lua5.1-socket" lua-5.1))
247 (define-public lua5.2-socket
248 (make-lua-socket "lua5.2-socket" lua-5.2))
250 (define (make-lua-filesystem name lua)
257 (url "https://github.com/keplerproject/luafilesystem")
258 (commit (string-append "v"
260 (string-split version #\.) "_")))))
261 (file-name (git-file-name name version))
264 "0zmprgkm9zawdf9wnw0v3w6ibaj442wlc6alp39hmw610fl4vghi"))))
265 (build-system gnu-build-system)
268 (let ((out (assoc-ref %outputs "out"))
269 (lua-version ,(version-major+minor (package-version lua))))
270 (list (string-append "PREFIX=" out)
271 (string-append "LUA_LIBDIR=" out "/lib/lua/" lua-version)))
274 (modify-phases %standard-phases
275 (delete 'configure))))
278 (home-page "https://keplerproject.github.io/luafilesystem/index.html")
279 (synopsis "File system library for Lua")
280 (description "LuaFileSystem is a Lua library developed to complement the
281 set of functions related to file systems offered by the standard Lua
282 distribution. LuaFileSystem offers a portable way to access the underlying
283 directory structure and file attributes.")
284 (license (package-license lua-5.1))))
286 (define-public lua-filesystem
287 (make-lua-filesystem "lua-filesystem" lua))
289 (define-public lua5.1-filesystem
290 (make-lua-filesystem "lua5.1-filesystem" lua-5.1))
292 (define-public lua5.2-filesystem
293 (make-lua-filesystem "lua5.2-filesystem" lua-5.2))
295 (define (make-lua-sec name lua)
302 (url "https://github.com/brunoos/luasec")
303 (commit (string-append "v" version))))
304 (file-name (git-file-name name version))
307 "0ssncgkggyr8i3z6zbvgrgsqj2q8676rnsikhpfwnk9n7sx4gwbl"))))
308 (build-system gnu-build-system)
311 (let ((out (assoc-ref %outputs "out"))
312 (lua-version ,(version-major+minor (package-version lua))))
316 (string-append "LUAPATH=" out "/share/lua/" lua-version)
317 (string-append "LUACPATH=" out "/lib/lua/" lua-version)))
318 #:tests? #f ; no tests included
320 (modify-phases %standard-phases
321 (delete 'configure))))
324 ("openssl" ,openssl)))
328 (format #f "lua~a-socket"
329 (version-major+minor (package-version lua))) lua))))
330 (home-page "https://github.com/brunoos/luasec/wiki")
331 (synopsis "OpenSSL bindings for Lua")
332 (description "LuaSec is a binding for OpenSSL library to provide TLS/SSL
333 communication. It takes an already established TCP connection and creates a
334 secure session between the peers.")
335 (license license:expat)))
337 (define-public lua5.1-sec
338 (make-lua-sec "lua5.1-sec" lua-5.1))
340 (define-public lua5.2-sec
341 (make-lua-sec "lua5.2-sec" lua-5.2))
343 (define-public lua-penlight
345 (name "lua-penlight")
351 (url "https://github.com/Tieske/Penlight.git")
353 (file-name (git-file-name name version))
355 (base32 "0qc2d1riyr4b5a0gnsmdw2lz5pw65s4ac60hc34w3mmk9l6yg6nl"))))
356 (build-system trivial-build-system)
360 `(("lua-filesystem" ,lua-filesystem)))
362 `(#:modules ((guix build utils))
365 (use-modules (guix build utils))
366 (let* ((source (assoc-ref %build-inputs "source"))
367 (lua-version ,(version-major+minor (package-version lua)))
368 (destination (string-append (assoc-ref %outputs "out")
369 "/share/lua/" lua-version)))
370 (mkdir-p destination)
371 (with-directory-excursion source
372 (copy-recursively "lua/" destination)))
374 (home-page "http://tieske.github.io/Penlight/")
375 (synopsis "Collection of general purpose libraries for the Lua language")
376 (description "Penlight is a set of pure Lua libraries focusing on
377 input data handling (such as reading configuration files), functional
378 programming (such as map, reduce, placeholder expressions,etc), and OS
379 path management. Much of the functionality is inspired by the Python
380 standard libraries.")
381 (license license:expat)))
383 (define-public lua-ldoc
391 (url "https://github.com/stevedonovan/LDoc.git")
393 (file-name (git-file-name name version))
395 (base32 "1h0cf7bp4am54r0j8lhjs2l1c7q5vz74ba0jvw9qdbaqimls46g8"))))
396 (build-system gnu-build-system)
400 `(("lua-penlight" ,lua-penlight)))
402 `(#:tests? #f ;tests must run after installation.
404 (modify-phases %standard-phases
405 (add-after 'unpack 'fix-installation-directory
406 (lambda* (#:key outputs #:allow-other-keys)
407 (let ((out (assoc-ref outputs "out"))
408 (lua-version ,(version-major+minor (package-version lua))))
409 (substitute* "makefile"
411 (("(LUA_PREFIX=).*" _ prefix)
412 (string-append prefix out "\n"))
413 (("(LUA_BINDIR=).*" _ prefix)
414 (string-append prefix out "/bin\n"))
415 (("(LUA_SHAREDIR=).*" _ prefix)
416 (string-append prefix out "/share/lua/" lua-version "\n"))))
419 (add-before 'install 'create-bin-directory
420 (lambda* (#:key outputs #:allow-other-keys)
421 (mkdir-p (string-append (assoc-ref outputs "out") "/bin"))
423 (home-page "http://stevedonovan.github.io/ldoc/")
424 (synopsis "Lua documentation generator")
426 "LDoc is a LuaDoc-compatible documentation generation system for
427 Lua source code. It parses the declaration and documentation comments
428 in a set of Lua source files and produces a set of XHTML pages
429 describing the commented declarations and functions.")
430 (license license:expat)))
432 (define (make-lua-lgi name lua)
440 (url "https://github.com/pavouk/lgi")
442 (file-name (git-file-name name version))
444 (base32 "03rbydnj411xpjvwsyvhwy4plm96481d7jax544mvk7apd8sd5jj"))))
445 (build-system gnu-build-system)
449 (string-append "PREFIX=" (assoc-ref %outputs "out")))
451 (modify-phases %standard-phases
452 (delete 'configure) ; no configure script
453 (add-before 'build 'set-env
454 (lambda* (#:key inputs #:allow-other-keys)
455 ;; We need to load cairo dynamically.
456 (let* ((cairo (string-append (assoc-ref inputs "cairo") "/lib")))
457 (setenv "LD_LIBRARY_PATH" cairo)
459 (add-before 'build 'set-lua-version
461 ;; Lua version and therefore install directories are hardcoded.
462 (substitute* "./lgi/Makefile"
466 ,(version-major+minor (package-version lua)))))
468 (add-before 'check 'skip-test-gtk
470 ;; FIXME: Skip GTK tests:
471 ;; gtk3 - can't get it to run with the xorg-server config below
472 ;; and some non-gtk tests will also fail
473 ;; gtk2 - lots of functions aren't implemented
474 ;; We choose gtk2 as the lesser evil and simply skip the test.
475 ;; Currently, awesome is the only package that uses lua-lgi but
476 ;; it doesn't need or interact with GTK using lua-lgi.
477 (substitute* "./tests/test.lua"
478 (("'gtk.lua',") "-- 'gtk.lua',"))
480 (add-before 'check 'start-xserver-instance
481 (lambda* (#:key inputs #:allow-other-keys)
482 ;; There must be a running X server during tests.
483 (system (format #f "~a/bin/Xvfb :1 &"
484 (assoc-ref inputs "xorg-server")))
485 (setenv "DISPLAY" ":1")
488 `(("dbus" ,dbus) ;tests use 'dbus-run-session'
489 ("pkg-config" ,pkg-config)))
493 ("gobject-introspection" ,gobject-introspection)
498 ("xorg-server" ,xorg-server)))
499 (home-page "https://github.com/pavouk/lgi/")
500 (synopsis "Lua bridge to GObject based libraries")
502 "LGI is gobject-introspection based dynamic Lua binding to GObject based
503 libraries. It allows using GObject-based libraries directly from Lua.
504 Notable examples are GTK+, GStreamer and Webkit.")
505 (license license:expat)))
507 (define-public lua-lgi
508 (make-lua-lgi "lua-lgi" lua))
510 (define-public lua5.1-lgi
511 (make-lua-lgi "lua5.1-lgi" lua-5.1))
513 (define-public lua5.2-lgi
514 (make-lua-lgi "lua5.2-lgi" lua-5.2))
516 (define (make-lua-lpeg name lua)
522 (uri (string-append "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-"
525 (base32 "1zjzl7acvcdavmcg5l7wi12jd4rh95q9pl5aiww7hv0v0mv6bmj8"))))
526 (build-system gnu-build-system)
529 (modify-phases %standard-phases
531 ;; `make install` isn't available, so we have to do it manually
533 (lambda* (#:key outputs #:allow-other-keys)
534 (let ((out (assoc-ref outputs "out"))
535 (lua-version ,(version-major+minor (package-version lua))))
536 (install-file "lpeg.so"
537 (string-append out "/lib/lua/" lua-version))
538 (install-file "re.lua"
539 (string-append out "/share/lua/" lua-version))
541 #:test-target "test"))
542 (inputs `(("lua" ,lua)))
543 (synopsis "Pattern-matching library for Lua")
545 "LPeg is a pattern-matching library for Lua, based on Parsing Expression
547 (home-page "http://www.inf.puc-rio.br/~roberto/lpeg")
548 (license license:expat)))
550 (define-public lua-lpeg
551 (make-lua-lpeg "lua-lpeg" lua))
553 (define-public lua5.1-lpeg
554 (make-lua-lpeg "lua5.1-lpeg" lua-5.1))
556 (define-public lua5.2-lpeg
557 (make-lua-lpeg "lua5.2-lpeg" lua-5.2))
559 (define (make-lua-luv name lua)
564 ;; The release tarball includes the sources of libuv but does
565 ;; not include the pkg-config files.
568 (url "https://github.com/luvit/luv.git")
570 (file-name (git-file-name name version))
573 "0c65c1lhbl0axnyks3910gjs0z0hw7w6jvl07g8kbpnbvfl4qajh"))))
574 (build-system cmake-build-system)
576 `(#:tests? #f ; there are none
578 '("-DWITH_LUA_ENGINE=Lua"
579 "-DWITH_SHARED_LIBUV=On"
581 "-DBUILD_SHARED_LIBS=On"
582 "-DLUA_BUILD_TYPE=System")
584 (modify-phases %standard-phases
585 (add-after 'unpack 'copy-lua-compat
586 (lambda* (#:key inputs #:allow-other-keys)
587 (copy-recursively (assoc-ref inputs "lua-compat")
590 (string-append (getcwd) "/lua-compat:"
591 (or (getenv "CPATH") "")))
601 (url "https://github.com/keplerproject/lua-compat-5.3.git")
602 (commit "daebe77a2f498817713df37f0bb316db1d82222f")))
603 (file-name "lua-compat-5.3-checkout")
606 "02a14nvn7aggg1yikj9h3dcf8aqjbxlws1bfvqbpfxv9d5phnrpz"))))))
607 (home-page "https://github.com/luvit/luv/")
608 (synopsis "Libuv bindings for Lua")
610 "This library makes libuv available to Lua scripts.")
611 (license license:asl2.0)))
613 (define-public lua-luv
614 (make-lua-luv "lua-luv" lua))
616 (define-public lua5.1-luv
617 (make-lua-luv "lua5.1-luv" lua-5.1))
619 (define-public lua5.2-luv
620 (make-lua-luv "lua5.2-luv" lua-5.2))
622 ;; Lua 5.3 is not supported.
623 (define (make-lua-bitop name lua)
629 (uri (string-append "http://bitop.luajit.org/download/"
630 "LuaBitOp-" version ".tar.gz"))
633 "16fffbrgfcw40kskh2bn9q7m3gajffwd2f35rafynlnd7llwj1qj"))))
634 (build-system gnu-build-system)
636 `(#:test-target "test"
638 (list "INSTALL=install -pD"
639 (string-append "INSTALLPATH=printf "
640 (assoc-ref %outputs "out")
642 ,(version-major+minor (package-version lua))
645 (modify-phases %standard-phases
646 (delete 'configure))))
647 (inputs `(("lua" ,lua)))
648 (home-page "https://bitop.luajit.org/index.html")
649 (synopsis "Bitwise operations on numbers for Lua")
651 "Lua BitOp is a C extension module for Lua which adds bitwise operations
653 (license license:expat)))
655 (define-public lua5.2-bitop
656 (make-lua-bitop "lua5.2-bitop" lua-5.2))
658 (define-public lua5.1-bitop
659 (make-lua-bitop "lua5.1-bitop" lua-5.1))
661 (define-public selene
664 (version "2017.08.25")
668 (url "https://github.com/jeremyong/Selene.git")
669 ;; The release is quite old.
670 (commit "ffe1ade2568d4cff5894552be8f43e63e379a4c9")))
674 "1axrgv3rxxdsaf807lwvklfzicn6x6gpf35narllrnz9lg6hn508"))))
675 (build-system cmake-build-system)
678 ;; lua pc file in CMakeLists.txt is lua5.3.pc
679 '("-DLUA_PC_CFG=lua;lua-5.3;lua-5.1")
682 ;; This is a header only library
683 (modify-phases %standard-phases
686 (lambda* (#:key inputs outputs #:allow-other-keys)
687 (let* ((output (assoc-ref outputs "out"))
688 (source (assoc-ref inputs "source"))
689 (includedir (string-append output "/include")))
691 (string-append source "/include")
694 ;; The path of test files are hard coded.
696 (lambda* (#:key inputs outputs #:allow-other-keys)
697 (let* ((output (assoc-ref outputs "out"))
698 (source (assoc-ref inputs "source"))
700 (testdir (string-append builddir "/test")))
701 (copy-recursively (string-append source "/test") testdir)
704 (copy-file "./test_runner" "./runner/test_runner")
706 (invoke "./test_runner")))))))
709 ("pkg-config" ,pkg-config)))
710 (home-page "https://github.com/jeremyong/Selene")
711 (synopsis "Lua C++11 bindings")
713 "Selene is a simple C++11 header-only library enabling seamless
714 interoperability between C++ and Lua programming language.")
715 (license license:zlib)))