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, 2021 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–2021 Tobias Geerinckx-Rice <me@tobias.gr>
12 ;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com>
13 ;;; Copyright © 2020 Nicolas Goaziou <mail@nicolasgoaziou.fr>
14 ;;; Copyright © 2020 Simon South <simon@simonsouth.net>
15 ;;; Copyright © 2020 Paul A. Patience <paul@apatience.com>
16 ;;; Copyright © 2021 Vinícius dos Santos Oliveira <vini.ipsmaker@gmail.com>
18 ;;; This file is part of GNU Guix.
20 ;;; GNU Guix is free software; you can redistribute it and/or modify it
21 ;;; under the terms of the GNU General Public License as published by
22 ;;; the Free Software Foundation; either version 3 of the License, or (at
23 ;;; your option) any later version.
25 ;;; GNU Guix is distributed in the hope that it will be useful, but
26 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
27 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 ;;; GNU General Public License for more details.
30 ;;; You should have received a copy of the GNU General Public License
31 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
33 (define-module (gnu packages lua)
34 #:use-module ((guix licenses) #:prefix license:)
35 #:use-module (guix packages)
36 #:use-module (guix download)
37 #:use-module (guix git-download)
38 #:use-module (guix utils)
39 #:use-module (guix build-system gnu)
40 #:use-module (guix build-system cmake)
41 #:use-module (guix build-system meson)
42 #:use-module (guix build-system trivial)
43 #:use-module (gnu packages)
44 #:use-module (gnu packages boost)
45 #:use-module (gnu packages build-tools)
46 #:use-module (gnu packages gcc)
47 #:use-module (gnu packages glib)
48 #:use-module (gnu packages gtk)
49 #:use-module (gnu packages libevent)
50 #:use-module (gnu packages libffi)
51 #:use-module (gnu packages m4)
52 #:use-module (gnu packages ncurses)
53 #:use-module (gnu packages pkg-config)
54 #:use-module (gnu packages pretty-print)
55 #:use-module (gnu packages re2c)
56 #:use-module (gnu packages readline)
57 #:use-module (gnu packages tls)
58 #:use-module (gnu packages vim)
59 #:use-module (gnu packages xml)
60 #:use-module (gnu packages xorg))
68 (uri (string-append "https://www.lua.org/ftp/lua-"
71 (base32 "1b2qn2rv96nmbm6zab4l877bd4zq7wpwm8drwjiy2ih4jqzysbhc"))
72 (patches (search-patches "lua-pkgconfig.patch"
73 "lua-liblua-so.patch"))))
74 (build-system gnu-build-system)
75 (inputs `(("readline" ,readline)))
77 `(#:modules ((guix build gnu-build-system)
82 (list "MYCFLAGS=-fPIC -DLUA_DL_DLOPEN"
83 (string-append "CC=" ,(cc-for-target))
84 (string-append "SYSLIBS=-L" (assoc-ref %build-inputs "readline")
88 (modify-phases %standard-phases
91 (lambda* (#:key outputs #:allow-other-keys)
92 (let ((out (assoc-ref outputs "out")))
93 (invoke "make" "install"
94 (string-append "INSTALL_TOP=" out)
95 (string-append "INSTALL_MAN=" out
96 "/share/man/man1"))))))))
97 (home-page "https://www.lua.org/")
98 (synopsis "Embeddable scripting language")
100 "Lua is a powerful, fast, lightweight, embeddable scripting language. Lua
101 combines simple procedural syntax with powerful data description constructs
102 based on associative arrays and extensible semantics. Lua is dynamically typed,
103 runs by interpreting bytecode for a register-based virtual machine, and has
104 automatic memory management with incremental garbage collection, making it ideal
105 for configuration, scripting, and rapid prototyping.")
106 (license license:x11)))
108 (define-public lua-5.2
109 (package (inherit lua)
114 (uri (string-append "https://www.lua.org/ftp/lua-"
117 (base32 "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr"))
118 (patches (search-patches "lua-pkgconfig.patch"
119 "lua-liblua-so.patch"))))))
121 (define-public lua-5.1
122 (package (inherit lua)
126 (uri (string-append "https://www.lua.org/ftp/lua-"
129 (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))
130 (patches (search-patches "lua51-liblua-so.patch"
131 "lua-CVE-2014-5461.patch"
132 "lua51-pkgconfig.patch"))))))
134 (define-public luajit
137 (version "2.1.0-beta3")
140 (uri (string-append "http://luajit.org/download/LuaJIT-"
143 (base32 "1hyrhpkwjqsv54hnnx4cl8vk44h9d6c9w0fz1jfjz00w255y7lhs"))
144 (patches (search-patches "luajit-no_ldconfig.patch"))))
145 (build-system gnu-build-system)
147 `(#:tests? #f ; luajit is distributed without tests
149 (modify-phases %standard-phases
150 (delete 'configure) ; no configure script
151 (add-after 'install 'create-luajit-symlink
152 (lambda* (#:key outputs #:allow-other-keys)
153 (let* ((out (assoc-ref outputs "out"))
154 (bin (string-append out "/bin")))
155 (with-directory-excursion bin
156 (symlink ,(string-append name "-" version)
159 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))))
160 (home-page "https://www.luajit.org/")
161 (synopsis "Just in time compiler for Lua programming language version 5.1")
163 "LuaJIT is a Just-In-Time Compiler (JIT) for the Lua
164 programming language. Lua is a powerful, dynamic and light-weight programming
165 language. It may be embedded or used as a general-purpose, stand-alone
167 (license license:x11)))
169 (define-public luajit-lua52-openresty
172 (name "luajit-lua52-openresty")
173 (version "2.1-20201229")
178 (url "https://github.com/openresty/luajit2.git")
179 (commit (string-append "v" version))))
180 (file-name (git-file-name name version))
182 (base32 "07haj27kbpbnkv836c2nd36h2xislrmri52w0zbpxvl68xk6g96p"))))
184 `(#:tests? #f ;no test
185 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
187 (modify-phases %standard-phases
188 (delete 'configure) ;no configure script
189 (add-after 'unpack 'enable-lua52-compat
191 (substitute* "src/Makefile"
192 (("#(XCFLAGS\\+= -DLUAJIT_ENABLE_LUA52COMPAT)" _ flag) flag))
194 (home-page "https://github.com/openresty/luajit2")
195 (synopsis "OpenResty's Branch of LuaJIT 2")
197 "This is the official OpenResty branch of LuaJIT. It is not to be
198 considered a fork, since changes are regularly synchronized from the upstream
199 LuaJIT project. This package also enables the Lua 5.2 compat mode needed by
202 (define (make-lua-expat name lua)
208 (uri (string-append "https://matthewwild.co.uk/projects/"
209 "luaexpat/luaexpat-" version ".tar.gz"))
212 "1hvxqngn0wf5642i5p3vcyhg3pmp102k63s9ry4jqyyqc1wkjq6h"))))
213 (build-system gnu-build-system)
216 (let ((out (assoc-ref %outputs "out"))
217 (lua-version ,(version-major+minor (package-version lua))))
219 (string-append "LUA_LDIR=" out "/share/lua/" lua-version)
220 (string-append "LUA_CDIR=" out "/lib/lua/" lua-version)))
222 (modify-phases %standard-phases
226 (setenv "LUA_CPATH" "src/?.so;;")
227 (setenv "LUA_PATH" "src/?.lua;;")
228 (invoke "lua" "tests/test.lua")
229 (invoke "lua" "tests/test-lom.lua"))))))
233 (home-page "https://matthewwild.co.uk/projects/luaexpat/")
234 (synopsis "SAX XML parser based on the Expat library")
235 (description "LuaExpat is a SAX XML parser based on the Expat library.")
236 (license (package-license lua-5.1))))
238 (define-public lua5.1-expat
239 (make-lua-expat "lua5.1-expat" lua-5.1))
241 (define-public lua5.2-expat
242 (make-lua-expat "lua5.2-expat" lua-5.2))
244 (define (make-lua-socket name lua)
251 (url "https://github.com/diegonehab/luasocket")
252 (commit (string-append "v" version))))
253 (file-name (git-file-name name version))
256 "1chs7z7a3i3lck4x7rz60ziwbf793gw169hpjdfca8y4yf1hzsxk"))))
257 (build-system gnu-build-system)
260 (let ((out (assoc-ref %outputs "out"))
261 (lua-version ,(version-major+minor (package-version lua))))
262 (list (string-append "INSTALL_TOP=" out)
263 (string-append "LUAV?=" lua-version)))
265 (modify-phases %standard-phases
269 (setenv "LUA_CPATH" (string-append "src/?.so." ,version ";;"))
270 (setenv "LUA_PATH" "src/?.lua;;")
271 (when (zero? (primitive-fork))
272 (invoke "lua" "test/testsrvr.lua"))
273 (invoke "lua" "test/testclnt.lua"))))))
276 (home-page "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/")
277 (synopsis "Socket library for Lua")
278 (description "LuaSocket is a Lua extension library that is composed by two
279 parts: a C core that provides support for the TCP and UDP transport layers,
280 and a set of Lua modules that add support for functionality commonly needed by
281 applications that deal with the Internet.
283 Among the supported modules, the most commonly used implement the
284 SMTP (sending e-mails), HTTP (WWW access) and FTP (uploading and downloading
285 files) client protocols. These provide a very natural and generic interface
286 to the functionality defined by each protocol. In addition, you will find
287 that the MIME (common encodings), URL (anything you could possible want to do
288 with one) and LTN12 (filters, sinks, sources and pumps) modules can be very
290 (license license:expat)))
292 (define-public lua5.1-socket
293 (make-lua-socket "lua5.1-socket" lua-5.1))
295 (define-public lua5.2-socket
296 (make-lua-socket "lua5.2-socket" lua-5.2))
298 (define (make-lua-filesystem name lua)
305 (url "https://github.com/keplerproject/luafilesystem")
306 (commit (string-append "v"
308 (string-split version #\.) "_")))))
309 (file-name (git-file-name name version))
312 "0zmprgkm9zawdf9wnw0v3w6ibaj442wlc6alp39hmw610fl4vghi"))))
313 (build-system gnu-build-system)
316 (let ((out (assoc-ref %outputs "out"))
317 (lua-version ,(version-major+minor (package-version lua))))
318 (list (string-append "PREFIX=" out)
319 (string-append "LUA_LIBDIR=" out "/lib/lua/" lua-version)))
322 (modify-phases %standard-phases
323 (delete 'configure))))
326 (home-page "https://keplerproject.github.io/luafilesystem/index.html")
327 (synopsis "File system library for Lua")
328 (description "LuaFileSystem is a Lua library developed to complement the
329 set of functions related to file systems offered by the standard Lua
330 distribution. LuaFileSystem offers a portable way to access the underlying
331 directory structure and file attributes.")
332 (license (package-license lua-5.1))))
334 (define-public lua-filesystem
335 (make-lua-filesystem "lua-filesystem" lua))
337 (define-public lua5.1-filesystem
338 (make-lua-filesystem "lua5.1-filesystem" lua-5.1))
340 (define-public lua5.2-filesystem
341 (make-lua-filesystem "lua5.2-filesystem" lua-5.2))
343 (define (make-lua-ossl name lua)
349 (uri (string-append "https://25thandclement.com/~william/"
350 "projects/releases/luaossl-" version ".tgz"))
353 "10392bvd0lzyibipblgiss09zlqh3a5zgqg1b9lgbybpqb9cv2k3"))))
354 (build-system gnu-build-system)
357 (let ((out (assoc-ref %outputs "out"))
358 (lua-api-version ,(version-major+minor (package-version lua))))
360 "CFLAGS='-D HAVE_SYS_SYSCTL_H=0'" ; sys/sysctl.h is deprecated
361 (string-append "prefix=" out)
362 (string-append "LUA_APIS=" lua-api-version)))
364 (modify-phases %standard-phases
367 (add-after 'install 'check
368 (lambda* (#:key outputs #:allow-other-keys)
369 (let ((out (assoc-ref outputs "out"))
370 (lua-version ,(version-major+minor (package-version lua))))
372 (string-append out "/lib/lua/" lua-version "/?.so;;"))
374 (string-append out "/share/lua/" lua-version "/?.lua;;"))
375 (with-directory-excursion "regress"
376 (for-each (lambda (f)
378 (find-files "." "^[0-9].*\\.lua$"))))
382 ("openssl" ,openssl)))
383 (home-page "https://25thandclement.com/~william/projects/luaossl.html")
384 (synopsis "OpenSSL bindings for Lua")
385 (description "The luaossl extension module for Lua provides comprehensive,
386 low-level bindings to the OpenSSL library, including support for certificate and
387 key management, key generation, signature verification, and deep bindings to the
388 distinguished name, alternative name, and X.509v3 extension interfaces. It also
389 binds OpenSSL's bignum, message digest, HMAC, cipher, and CSPRNG interfaces.")
390 (license license:expat)))
392 (define-public lua-ossl
393 (make-lua-ossl "lua-ossl" lua))
395 (define-public lua5.1-ossl
396 (make-lua-ossl "lua5.1-ossl" lua-5.1))
398 (define-public lua5.2-ossl
399 (make-lua-ossl "lua5.2-ossl" lua-5.2))
401 (define (make-lua-sec name lua)
408 (url "https://github.com/brunoos/luasec")
409 (commit (string-append "v" version))))
410 (file-name (git-file-name name version))
413 "0ssncgkggyr8i3z6zbvgrgsqj2q8676rnsikhpfwnk9n7sx4gwbl"))))
414 (build-system gnu-build-system)
417 (let ((out (assoc-ref %outputs "out"))
418 (lua-version ,(version-major+minor (package-version lua))))
422 (string-append "LUAPATH=" out "/share/lua/" lua-version)
423 (string-append "LUACPATH=" out "/lib/lua/" lua-version)))
424 #:tests? #f ; no tests included
426 (modify-phases %standard-phases
427 (delete 'configure))))
430 ("openssl" ,openssl)))
434 (format #f "lua~a-socket"
435 (version-major+minor (package-version lua))) lua))))
436 (home-page "https://github.com/brunoos/luasec/wiki")
437 (synopsis "OpenSSL bindings for Lua")
438 (description "LuaSec is a binding for OpenSSL library to provide TLS/SSL
439 communication. It takes an already established TCP connection and creates a
440 secure session between the peers.")
441 (license license:expat)))
443 (define-public lua5.1-sec
444 (make-lua-sec "lua5.1-sec" lua-5.1))
446 (define-public lua5.2-sec
447 (make-lua-sec "lua5.2-sec" lua-5.2))
449 (define (make-lua-cqueues name lua lua-ossl)
455 (uri (string-append "https://25thandclement.com/~william/"
456 "projects/releases/cqueues-" version ".tgz"))
459 "1dabhpn6r0hlln8vx9hxm34pfcm46qzgpb2apmziwg5z51fi4ksb"))))
460 (build-system gnu-build-system)
462 `(#:modules ((guix build gnu-build-system)
466 (let ((out (assoc-ref %outputs "out"))
467 (lua-api-version ,(version-major+minor (package-version lua))))
469 (string-append "LUA_APIS=" lua-api-version)))
471 (modify-phases %standard-phases
475 (lambda* (#:key make-flags outputs #:allow-other-keys)
476 (let ((out (assoc-ref outputs "out")))
477 (apply invoke "make" "install"
479 (list (string-append "DESTDIR=" out)
481 (add-after 'install 'check
482 (lambda* (#:key inputs outputs make-flags #:allow-other-keys)
484 ((lua-version ,(version-major+minor (package-version lua)))
485 (env-suffix (if (equal? lua-version "5.1")
489 (string-replace-substring lua-version "." "_"))))
491 (lua-ossl (assoc-ref inputs "lua-ossl"))
492 (out (assoc-ref outputs "out"))
494 (lua-cpath (lambda (p)
495 (string-append p "/lib/lua/" lua-version "/?.so")))
496 (lua-path (lambda (p)
497 (string-append p "/share/lua/" lua-version "/?.lua"))))
498 ;; The test suite sets Lua-version-specific search-path variables
499 ;; when available so we must do the same, as these take
500 ;; precedence over the generic "LUA_CPATH" and "LUA_PATH"
501 (setenv (string-append "LUA_CPATH" env-suffix)
503 (string-join (map lua-cpath (list out lua-ossl)) ";")
505 (setenv (string-append "LUA_PATH" env-suffix)
507 (string-join (map lua-path (list out lua-ossl)) ";")
510 ;; Skip regression tests we expect to fail
511 (with-directory-excursion "regress"
512 (for-each (lambda (f)
513 (rename-file f (string-append f ".skip")))
515 ;; Regression tests that require network
517 '("22-client-dtls.lua"
518 "30-starttls-completion.lua"
520 "153-dns-resolvers.lua")
522 ;; Regression tests that require LuaJIT
523 '("44-resolvers-gc.lua"
524 "51-join-defunct-thread.lua")
526 ;; Regression tests that require Lua 5.3
527 (if (not (equal? lua-version "5.3"))
528 '("152-thread-integer-passing.lua")
531 (apply invoke "make" "check" make-flags)))))))
536 ("openssl" ,openssl)))
538 `(("lua-ossl" ,lua-ossl)))
539 (home-page "https://25thandclement.com/~william/projects/cqueues.html")
540 (synopsis "Event loop for Lua using continuation queues")
541 (description "The cqueues extension module for Lua implements an event loop
542 that operates through the yielding and resumption of coroutines. It is designed
543 to be non-intrusive, composable, and embeddable within existing applications.")
544 (license license:expat)))
546 (define-public lua-cqueues
547 (make-lua-cqueues "lua-cqueues" lua lua-ossl))
549 (define-public lua5.1-cqueues
550 (make-lua-cqueues "lua5.1-cqueues" lua-5.1 lua5.1-ossl))
552 (define-public lua5.2-cqueues
553 (make-lua-cqueues "lua5.2-cqueues" lua-5.2 lua5.2-ossl))
555 (define-public lua-penlight
557 (name "lua-penlight")
563 (url "https://github.com/Tieske/Penlight")
565 (file-name (git-file-name name version))
567 (base32 "0qc2d1riyr4b5a0gnsmdw2lz5pw65s4ac60hc34w3mmk9l6yg6nl"))))
568 (build-system trivial-build-system)
572 `(("lua-filesystem" ,lua-filesystem)))
574 `(#:modules ((guix build utils))
577 (use-modules (guix build utils))
578 (let* ((source (assoc-ref %build-inputs "source"))
579 (lua-version ,(version-major+minor (package-version lua)))
580 (destination (string-append (assoc-ref %outputs "out")
581 "/share/lua/" lua-version)))
582 (mkdir-p destination)
583 (with-directory-excursion source
584 (copy-recursively "lua/" destination)))
586 (home-page "http://tieske.github.io/Penlight/")
587 (synopsis "Collection of general purpose libraries for the Lua language")
588 (description "Penlight is a set of pure Lua libraries focusing on
589 input data handling (such as reading configuration files), functional
590 programming (such as map, reduce, placeholder expressions,etc), and OS
591 path management. Much of the functionality is inspired by the Python
592 standard libraries.")
593 (license license:expat)))
595 (define-public lua-ldoc
603 (url "https://github.com/stevedonovan/LDoc")
605 (file-name (git-file-name name version))
607 (base32 "1h0cf7bp4am54r0j8lhjs2l1c7q5vz74ba0jvw9qdbaqimls46g8"))))
608 (build-system gnu-build-system)
612 `(("lua-penlight" ,lua-penlight)))
614 `(#:tests? #f ;tests must run after installation.
616 (modify-phases %standard-phases
617 (add-after 'unpack 'fix-installation-directory
618 (lambda* (#:key outputs #:allow-other-keys)
619 (let ((out (assoc-ref outputs "out"))
620 (lua-version ,(version-major+minor (package-version lua))))
621 (substitute* "makefile"
623 (("(LUA_PREFIX=).*" _ prefix)
624 (string-append prefix out "\n"))
625 (("(LUA_BINDIR=).*" _ prefix)
626 (string-append prefix out "/bin\n"))
627 (("(LUA_SHAREDIR=).*" _ prefix)
628 (string-append prefix out "/share/lua/" lua-version "\n"))))
631 (add-before 'install 'create-bin-directory
632 (lambda* (#:key outputs #:allow-other-keys)
633 (mkdir-p (string-append (assoc-ref outputs "out") "/bin"))
635 (home-page "http://stevedonovan.github.io/ldoc/")
636 (synopsis "Lua documentation generator")
638 "LDoc is a LuaDoc-compatible documentation generation system for
639 Lua source code. It parses the declaration and documentation comments
640 in a set of Lua source files and produces a set of XHTML pages
641 describing the commented declarations and functions.")
642 (license license:expat)))
644 (define (make-lua-lgi name lua)
652 (url "https://github.com/pavouk/lgi")
654 (file-name (git-file-name name version))
656 (base32 "03rbydnj411xpjvwsyvhwy4plm96481d7jax544mvk7apd8sd5jj"))))
657 (build-system gnu-build-system)
661 (string-append "PREFIX=" (assoc-ref %outputs "out")))
663 (modify-phases %standard-phases
664 (delete 'configure) ; no configure script
665 (add-before 'build 'set-env
666 (lambda* (#:key inputs #:allow-other-keys)
667 ;; We need to load cairo dynamically.
668 (let* ((cairo (string-append (assoc-ref inputs "cairo") "/lib")))
669 (setenv "LD_LIBRARY_PATH" cairo)
671 (add-before 'build 'set-lua-version
673 ;; Lua version and therefore install directories are hardcoded.
674 (substitute* "./lgi/Makefile"
678 ,(version-major+minor (package-version lua)))))
680 (add-before 'check 'skip-test-gtk
682 ;; FIXME: Skip GTK tests:
683 ;; gtk3 - can't get it to run with the xorg-server config below
684 ;; and some non-gtk tests will also fail
685 ;; gtk2 - lots of functions aren't implemented
686 ;; We choose gtk2 as the lesser evil and simply skip the test.
687 ;; Currently, awesome is the only package that uses lua-lgi but
688 ;; it doesn't need or interact with GTK using lua-lgi.
689 (substitute* "./tests/test.lua"
690 (("'gtk.lua',") "-- 'gtk.lua',"))
692 (add-before 'check 'start-xserver-instance
693 (lambda* (#:key inputs #:allow-other-keys)
694 ;; There must be a running X server during tests.
695 (system (format #f "~a/bin/Xvfb :1 &"
696 (assoc-ref inputs "xorg-server")))
697 (setenv "DISPLAY" ":1")
700 `(("dbus" ,dbus) ;tests use 'dbus-run-session'
701 ("pkg-config" ,pkg-config)))
705 ("gobject-introspection" ,gobject-introspection)
710 ("xorg-server" ,xorg-server)))
711 (home-page "https://github.com/pavouk/lgi/")
712 (synopsis "Lua bridge to GObject based libraries")
714 "LGI is gobject-introspection based dynamic Lua binding to GObject based
715 libraries. It allows using GObject-based libraries directly from Lua.
716 Notable examples are GTK+, GStreamer and Webkit.")
717 (license license:expat)))
719 (define-public lua-lgi
720 (make-lua-lgi "lua-lgi" lua))
722 (define-public lua5.1-lgi
723 (make-lua-lgi "lua5.1-lgi" lua-5.1))
725 (define-public lua5.2-lgi
726 (make-lua-lgi "lua5.2-lgi" lua-5.2))
728 (define (make-lua-lpeg name lua)
734 (uri (string-append "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-"
737 (base32 "1zjzl7acvcdavmcg5l7wi12jd4rh95q9pl5aiww7hv0v0mv6bmj8"))))
738 (build-system gnu-build-system)
741 (modify-phases %standard-phases
743 ;; `make install` isn't available, so we have to do it manually
745 (lambda* (#:key outputs #:allow-other-keys)
746 (let ((out (assoc-ref outputs "out"))
747 (lua-version ,(version-major+minor (package-version lua))))
748 (install-file "lpeg.so"
749 (string-append out "/lib/lua/" lua-version))
750 (install-file "re.lua"
751 (string-append out "/share/lua/" lua-version))
753 #:test-target "test"))
754 (inputs `(("lua" ,lua)))
755 (synopsis "Pattern-matching library for Lua")
757 "LPeg is a pattern-matching library for Lua, based on Parsing Expression
759 (home-page "http://www.inf.puc-rio.br/~roberto/lpeg")
760 (license license:expat)))
762 (define-public lua-lpeg
763 (make-lua-lpeg "lua-lpeg" lua))
765 (define-public lua5.1-lpeg
766 (make-lua-lpeg "lua5.1-lpeg" lua-5.1))
768 (define-public lua5.2-lpeg
769 (make-lua-lpeg "lua5.2-lpeg" lua-5.2))
771 (define (make-lua-luv name lua)
776 ;; The release tarball includes the sources of libuv but does
777 ;; not include the pkg-config files.
780 (url "https://github.com/luvit/luv")
782 (file-name (git-file-name name version))
785 "0c65c1lhbl0axnyks3910gjs0z0hw7w6jvl07g8kbpnbvfl4qajh"))))
786 (build-system cmake-build-system)
788 `(#:tests? #f ; there are none
790 '("-DWITH_LUA_ENGINE=Lua"
791 "-DWITH_SHARED_LIBUV=On"
793 "-DBUILD_SHARED_LIBS=On"
794 "-DLUA_BUILD_TYPE=System")
796 (modify-phases %standard-phases
797 (add-after 'unpack 'copy-lua-compat
798 (lambda* (#:key inputs #:allow-other-keys)
799 (copy-recursively (assoc-ref inputs "lua-compat")
802 (string-append (getcwd) "/lua-compat:"
803 (or (getenv "CPATH") "")))
813 (url "https://github.com/keplerproject/lua-compat-5.3")
814 (commit "daebe77a2f498817713df37f0bb316db1d82222f")))
815 (file-name "lua-compat-5.3-checkout")
818 "02a14nvn7aggg1yikj9h3dcf8aqjbxlws1bfvqbpfxv9d5phnrpz"))))))
819 (home-page "https://github.com/luvit/luv/")
820 (synopsis "Libuv bindings for Lua")
822 "This library makes libuv available to Lua scripts.")
823 (license license:asl2.0)))
825 (define-public lua-luv
826 (make-lua-luv "lua-luv" lua))
828 (define-public lua5.1-luv
829 (make-lua-luv "lua5.1-luv" lua-5.1))
831 (define-public lua5.2-luv
832 (make-lua-luv "lua5.2-luv" lua-5.2))
834 ;; Lua 5.3 is not supported.
835 (define (make-lua-bitop name lua)
841 (uri (string-append "http://bitop.luajit.org/download/"
842 "LuaBitOp-" version ".tar.gz"))
845 "16fffbrgfcw40kskh2bn9q7m3gajffwd2f35rafynlnd7llwj1qj"))))
846 (build-system gnu-build-system)
848 `(#:test-target "test"
850 (list "INSTALL=install -pD"
851 (string-append "INSTALLPATH=printf "
852 (assoc-ref %outputs "out")
854 ,(version-major+minor (package-version lua))
857 (modify-phases %standard-phases
858 (delete 'configure))))
859 (inputs `(("lua" ,lua)))
860 (home-page "https://bitop.luajit.org/index.html")
861 (synopsis "Bitwise operations on numbers for Lua")
863 "Lua BitOp is a C extension module for Lua which adds bitwise operations
865 (license license:expat)))
867 (define-public lua5.2-bitop
868 (make-lua-bitop "lua5.2-bitop" lua-5.2))
870 (define-public lua5.1-bitop
871 (make-lua-bitop "lua5.1-bitop" lua-5.1))
873 (define-public selene
876 (version "2017.08.25")
880 (url "https://github.com/jeremyong/Selene")
881 ;; The release is quite old.
882 (commit "ffe1ade2568d4cff5894552be8f43e63e379a4c9")))
886 "1axrgv3rxxdsaf807lwvklfzicn6x6gpf35narllrnz9lg6hn508"))))
887 (build-system cmake-build-system)
890 ;; lua pc file in CMakeLists.txt is lua5.3.pc
891 '("-DLUA_PC_CFG=lua;lua-5.3;lua-5.1")
894 ;; This is a header only library
895 (modify-phases %standard-phases
898 (lambda* (#:key inputs outputs #:allow-other-keys)
899 (let* ((output (assoc-ref outputs "out"))
900 (source (assoc-ref inputs "source"))
901 (includedir (string-append output "/include")))
903 (string-append source "/include")
906 ;; The path of test files are hard coded.
908 (lambda* (#:key inputs outputs #:allow-other-keys)
909 (let* ((output (assoc-ref outputs "out"))
910 (source (assoc-ref inputs "source"))
912 (testdir (string-append builddir "/test")))
913 (copy-recursively (string-append source "/test") testdir)
916 (copy-file "./test_runner" "./runner/test_runner")
918 (invoke "./test_runner")))))))
921 ("pkg-config" ,pkg-config)))
922 (home-page "https://github.com/jeremyong/Selene")
923 (synopsis "Lua C++11 bindings")
925 "Selene is a simple C++11 header-only library enabling seamless
926 interoperability between C++ and Lua programming language.")
927 (license license:zlib)))
929 (define-public lua-resty-core
931 (name "lua-resty-core")
936 (url "https://github.com/openresty/lua-resty-core")
937 (commit (string-append "v" version))))
938 (file-name (git-file-name name version))
941 "1c58hykwpg5zqbyhrcb703pzwbkih409v3bh2gady6z2kj9q32dw"))))
942 (build-system trivial-build-system)
944 `(#:modules ((guix build utils))
947 (use-modules (guix build utils))
948 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
949 (package-lua-resty (lambda (input output)
950 (mkdir-p (string-append output "/lib/lua"))
951 (copy-recursively (string-append input "/lib/resty")
952 (string-append output "/lib/lua/resty"))
953 (copy-recursively (string-append input "/lib/ngx")
954 (string-append output "/lib/ngx"))
955 (symlink (string-append output "/lib/lua/resty")
956 (string-append output "/lib/resty")))))
957 (package-lua-resty (assoc-ref %build-inputs "source")
958 (assoc-ref %outputs "out")))
960 (home-page "https://github.com/openresty/lua-resty-core")
961 (synopsis "Lua API for NGINX")
962 (description "This package provides a FFI-based Lua API for
963 @code{ngx_http_lua_module} or @code{ngx_stream_lua_module}.")
964 (license license:bsd-2)))
966 (define-public lua-resty-lrucache
968 (name "lua-resty-lrucache")
973 (url "https://github.com/openresty/lua-resty-lrucache")
974 (commit (string-append "v" version))))
975 (file-name (git-file-name name version))
978 "1bsc54v1rvxmkwg7a2c01p192lvw5g576f589is8fy1m1c6v4ap8"))))
979 (build-system trivial-build-system)
981 `(#:modules ((guix build utils))
984 (use-modules (guix build utils))
985 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
986 (package-lua-resty (lambda (input output)
987 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
988 (copy-recursively (string-append input "/lib/resty")
989 (string-append output "/lib/lua/" luajit-major+minor "/resty"))
990 (symlink (string-append output "/lib/lua/" luajit-major+minor "/resty")
991 (string-append output "/lib/resty")))))
992 (package-lua-resty (assoc-ref %build-inputs "source")
993 (assoc-ref %outputs "out")))
995 (home-page "https://github.com/openresty/lua-resty-lrucache")
996 (synopsis "Lua LRU cache based on the LuaJIT FFI")
998 "This package provides Lua LRU cache based on the LuaJIT FFI.")
999 (license license:bsd-2)))
1001 (define-public lua-resty-signal
1003 (name "lua-resty-signal")
1008 (url "https://github.com/openresty/lua-resty-signal")
1009 (commit (string-append "v" version))))
1010 (file-name (git-file-name name version))
1013 "13y1pqn45y49mhqwywasfdsid46d0c33yi6mrnracbnmvyxz1cif"))))
1014 (build-system gnu-build-system)
1016 `(#:tests? #f ;TODO: Run the test suite.
1017 #:make-flags (list "CC=gcc"
1018 (string-append "PREFIX=" %output))
1020 (modify-phases %standard-phases
1022 (add-after 'install 'install-lua
1023 (lambda* (#:key inputs outputs #:allow-other-keys)
1024 (use-modules (guix build utils))
1025 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1026 (package-lua-resty (lambda (input output)
1027 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1028 (copy-recursively (string-append input "/lib/resty")
1029 (string-append output "/lib/lua/" luajit-major+minor "/resty"))
1030 (symlink (string-append output "/lib/lua/" luajit-major+minor "/resty")
1031 (string-append output "/lib/resty")))))
1032 (package-lua-resty (assoc-ref inputs "source")
1033 (assoc-ref outputs "out")))
1035 (home-page "https://github.com/openresty/lua-resty-signal")
1036 (synopsis "Lua library for killing or sending signals to Linux processes")
1037 (description "This package provides Lua library for killing or sending
1038 signals to Linux processes.")
1039 (license license:bsd-3)))
1041 (define-public lua-tablepool
1043 (name "lua-tablepool")
1048 (url "https://github.com/openresty/lua-tablepool")
1049 (commit (string-append "v" version))))
1050 (file-name (git-file-name name version))
1053 "03yjj3w6znvj6843prg84m0lkrn49l901f9hj9bgy3cj9s0awl6y"))))
1054 (build-system trivial-build-system)
1056 `(#:modules ((guix build utils))
1059 (use-modules (guix build utils))
1060 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1061 (package-lua-resty (lambda (input output)
1062 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1063 (copy-recursively (string-append input "/lib")
1064 (string-append output "/lib")))))
1065 (package-lua-resty (assoc-ref %build-inputs "source")
1066 (assoc-ref %outputs "out")))
1068 (home-page "https://github.com/openresty/lua-tablepool")
1069 (synopsis "Lua table recycling pools for LuaJIT")
1070 (description "This package provides Lua table recycling pools for LuaJIT.")
1071 (license license:bsd-2)))
1073 (define-public lua-resty-shell
1075 (name "lua-resty-shell")
1080 (url "https://github.com/openresty/lua-resty-shell")
1081 (commit (string-append "v" version))))
1082 (file-name (git-file-name name version))
1085 "1s6g04ip4hr97r2pd8ry3alq063604s9a3l0hn9nsidh81ps4dp7"))))
1086 (build-system trivial-build-system)
1088 `(#:modules ((guix build utils))
1091 (use-modules (guix build utils))
1092 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1093 (package-lua-resty (lambda (input output)
1094 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1095 (copy-recursively (string-append input "/lib/resty")
1096 (string-append output "/lib/lua/" luajit-major+minor "/resty"))
1097 (symlink (string-append output "/lib/lua/" luajit-major+minor "/resty")
1098 (string-append output "/lib/resty")))))
1099 (package-lua-resty (assoc-ref %build-inputs "source")
1100 (assoc-ref %outputs "out")))
1102 (home-page "https://github.com/openresty/lua-resty-shell")
1103 (synopsis "Lua module for nonblocking system shell command executions")
1104 (description "This package provides Lua module for nonblocking system
1105 shell command executions.")
1106 (license license:bsd-3)))
1108 (define-public emilua
1115 (url "https://gitlab.com/emilua/emilua.git")
1116 (commit (string-append "v" version))
1117 ;; Current version requires bundled CLI11, but at some future
1118 ;; release the one found in the system could be used
1119 ;; instead. Current version also requires Trial.Protocol and
1120 ;; the HTTP lib developed as part of GSoC 2014 for Boost, but
1121 ;; these are dependencies unlikely to be "unbundled" in future
1124 (file-name (git-file-name name version))
1127 "124fj73722c03znwdyqp1i0jygwv3s11f6s1j9rzym513qrf7fnd"))))
1128 (build-system meson-build-system)
1130 `(#:meson ,meson-0.55
1131 ;; Tests are disabled for now due to an issue that affecs guix:
1132 ;; <https://gitlab.com/emilua/emilua/-/issues/22>
1134 (list "-Denable_http=true"
1135 "-Denable_tests=false"
1136 "-Denable_manpages=false"
1137 "-Dversion_suffix=-guix1")))
1139 `(("gcc" ,gcc-10) ; gcc-7 is too old for our C++17 needs
1140 ("luajit-lua52-openresty" ,luajit-lua52-openresty)
1141 ("pkg-config" ,pkg-config)
1146 ("boost-static" ,boost-static)
1148 ;; LuaJIT has a 2GiB addressing limit[1] that has been fixed on OpenResty
1149 ;; fork. Emilua is severely affected by this limit, so the upstream package
1150 ;; is avoided. Emilua also depends on the -DLUAJIT_ENABLE_LUA52COMPAT
1151 ;; configure flag[2] for some features to work (e.g. __pairs on HTTP
1154 ;; [1] <http://hacksoflife.blogspot.com/2012/12/integrating-luajit-with-x-plane-64-bit.html>
1155 ;; [2] <http://luajit.org/extensions.html#lua52>
1156 ("luajit-lua52-openresty" ,luajit-lua52-openresty)
1157 ("ncurses" ,ncurses)
1158 ("openssl" ,openssl)))
1159 (native-search-paths
1161 (search-path-specification
1162 (variable "EMILUA_PATH")
1164 (list (string-append "lib/emilua-" (version-major+minor version)))))))
1165 (home-page "https://gitlab.com/emilua/emilua")
1166 (synopsis "Lua execution engine")
1168 "Emilua is a LuaJIT-based Lua execution engine that supports async IO,
1169 fibers and actor-inspired threading. The experimental builtin HTTP module is
1171 (license license:boost1.0)))
1173 (define-public fennel
1180 (url "https://git.sr.ht/~technomancy/fennel")
1182 (file-name (git-file-name name version))
1185 "0n0xkgzlrwpppm5vbvn84mq418xhmyakk9hakdmjv1lk2dfdq2g7"))
1186 (modules '((guix build utils)))
1189 (delete-file "fennelview.lua") #t))))
1190 (build-system gnu-build-system)
1192 '(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
1193 #:tests? #t ; even on cross-build
1194 #:test-target "test"
1196 (modify-phases %standard-phases
1198 (add-before 'build 'patch-lua-calls
1199 (lambda* (#:key inputs #:allow-other-keys)
1200 (let ((lua (string-append (assoc-ref inputs "lua") "/bin/lua")))
1202 (substitute* "old/launcher.lua"
1203 (("/usr/bin/env lua") lua))
1205 (add-after 'build 'patch-fennel
1206 (lambda* (#:key inputs #:allow-other-keys)
1207 (substitute* "fennel"
1208 (("/usr/bin/env .*lua")
1209 (string-append (assoc-ref inputs "lua") "/bin/lua")))
1212 (add-after 'install 'check
1213 (assoc-ref %standard-phases 'check))
1214 (add-after 'install 'install-manpage
1215 (lambda* (#:key outputs #:allow-other-keys)
1216 (install-file "fennel.1"
1217 (string-append (assoc-ref outputs "out")
1220 (inputs `(("lua" ,lua)))
1221 (home-page "https://fennel-lang.org/")
1222 (synopsis "Lisp that compiles to Lua")
1224 "Fennel is a programming language that brings together the speed,
1225 simplicity, and reach of Lua with the flexibility of a Lisp syntax and macro
1227 (license license:expat)))