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, 2019, 2020 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>
17 ;;; This file is part of GNU Guix.
19 ;;; GNU Guix is free software; you can redistribute it and/or modify it
20 ;;; under the terms of the GNU General Public License as published by
21 ;;; the Free Software Foundation; either version 3 of the License, or (at
22 ;;; your option) any later version.
24 ;;; GNU Guix is distributed in the hope that it will be useful, but
25 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
26 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 ;;; GNU General Public License for more details.
29 ;;; You should have received a copy of the GNU General Public License
30 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
32 (define-module (gnu packages lua)
33 #:use-module ((guix licenses) #:prefix license:)
34 #:use-module (guix packages)
35 #:use-module (guix download)
36 #:use-module (guix git-download)
37 #:use-module (guix utils)
38 #:use-module (guix build-system gnu)
39 #:use-module (guix build-system cmake)
40 #:use-module (guix build-system trivial)
41 #:use-module (gnu packages)
42 #:use-module (gnu packages readline)
43 #:use-module (gnu packages m4)
44 #:use-module (gnu packages tls)
45 #:use-module (gnu packages xml)
46 #:use-module (gnu packages glib)
47 #:use-module (gnu packages libevent)
48 #:use-module (gnu packages libffi)
49 #:use-module (gnu packages pkg-config)
50 #:use-module (gnu packages xorg)
51 #:use-module (gnu packages gtk))
59 (uri (string-append "https://www.lua.org/ftp/lua-"
62 (base32 "1b2qn2rv96nmbm6zab4l877bd4zq7wpwm8drwjiy2ih4jqzysbhc"))
63 (patches (search-patches "lua-pkgconfig.patch"
64 "lua-liblua-so.patch"))))
65 (build-system gnu-build-system)
66 (inputs `(("readline" ,readline)))
68 `(#:modules ((guix build gnu-build-system)
73 (list "MYCFLAGS=-fPIC -DLUA_DL_DLOPEN"
74 (string-append "CC=" ,(cc-for-target))
75 (string-append "SYSLIBS=-L" (assoc-ref %build-inputs "readline")
79 (modify-phases %standard-phases
82 (lambda* (#:key outputs #:allow-other-keys)
83 (let ((out (assoc-ref outputs "out")))
84 (invoke "make" "install"
85 (string-append "INSTALL_TOP=" out)
86 (string-append "INSTALL_MAN=" out
87 "/share/man/man1"))))))))
88 (home-page "https://www.lua.org/")
89 (synopsis "Embeddable scripting language")
91 "Lua is a powerful, fast, lightweight, embeddable scripting language. Lua
92 combines simple procedural syntax with powerful data description constructs
93 based on associative arrays and extensible semantics. Lua is dynamically typed,
94 runs by interpreting bytecode for a register-based virtual machine, and has
95 automatic memory management with incremental garbage collection, making it ideal
96 for configuration, scripting, and rapid prototyping.")
97 (license license:x11)))
99 (define-public lua-5.2
100 (package (inherit lua)
105 (uri (string-append "https://www.lua.org/ftp/lua-"
108 (base32 "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr"))
109 (patches (search-patches "lua-pkgconfig.patch"
110 "lua-liblua-so.patch"))))))
112 (define-public lua-5.1
113 (package (inherit lua)
117 (uri (string-append "https://www.lua.org/ftp/lua-"
120 (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))
121 (patches (search-patches "lua51-liblua-so.patch"
122 "lua-CVE-2014-5461.patch"
123 "lua51-pkgconfig.patch"))))))
125 (define-public luajit
128 (version "2.1.0-beta3")
131 (uri (string-append "http://luajit.org/download/LuaJIT-"
134 (base32 "1hyrhpkwjqsv54hnnx4cl8vk44h9d6c9w0fz1jfjz00w255y7lhs"))
135 (patches (search-patches "luajit-no_ldconfig.patch"))))
136 (build-system gnu-build-system)
138 `(#:tests? #f ; luajit is distributed without tests
140 (modify-phases %standard-phases
141 (delete 'configure) ; no configure script
142 (add-after 'install 'create-luajit-symlink
143 (lambda* (#:key outputs #:allow-other-keys)
144 (let* ((out (assoc-ref outputs "out"))
145 (bin (string-append out "/bin")))
146 (with-directory-excursion bin
147 (symlink ,(string-append name "-" version)
150 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))))
151 (home-page "https://www.luajit.org/")
152 (synopsis "Just in time compiler for Lua programming language version 5.1")
154 "LuaJIT is a Just-In-Time Compiler (JIT) for the Lua
155 programming language. Lua is a powerful, dynamic and light-weight programming
156 language. It may be embedded or used as a general-purpose, stand-alone
158 (license license:x11)))
160 (define-public luajit-lua52-openresty
163 (name "luajit-lua52-openresty")
164 (version "2.1-20201229")
169 (url "https://github.com/openresty/luajit2.git")
170 (commit (string-append "v" version))))
171 (file-name (git-file-name name version))
173 (base32 "07haj27kbpbnkv836c2nd36h2xislrmri52w0zbpxvl68xk6g96p"))))
175 `(#:tests? #f ;no test
176 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
178 (modify-phases %standard-phases
179 (delete 'configure) ;no configure script
180 (add-after 'unpack 'enable-lua52-compat
182 (substitute* "src/Makefile"
183 (("#(XCFLAGS\\+= -DLUAJIT_ENABLE_LUA52COMPAT)" _ flag) flag))
185 (home-page "https://github.com/openresty/luajit2")
186 (synopsis "OpenResty's Branch of LuaJIT 2")
188 "This is the official OpenResty branch of LuaJIT. It is not to be
189 considered a fork, since changes are regularly synchronized from the upstream
190 LuaJIT project. This package also enables the Lua 5.2 compat mode needed by
193 (define (make-lua-expat name lua)
199 (uri (string-append "https://matthewwild.co.uk/projects/"
200 "luaexpat/luaexpat-" version ".tar.gz"))
203 "1hvxqngn0wf5642i5p3vcyhg3pmp102k63s9ry4jqyyqc1wkjq6h"))))
204 (build-system gnu-build-system)
207 (let ((out (assoc-ref %outputs "out"))
208 (lua-version ,(version-major+minor (package-version lua))))
210 (string-append "LUA_LDIR=" out "/share/lua/" lua-version)
211 (string-append "LUA_CDIR=" out "/lib/lua/" lua-version)))
213 (modify-phases %standard-phases
217 (setenv "LUA_CPATH" "src/?.so;;")
218 (setenv "LUA_PATH" "src/?.lua;;")
219 (invoke "lua" "tests/test.lua")
220 (invoke "lua" "tests/test-lom.lua"))))))
224 (home-page "https://matthewwild.co.uk/projects/luaexpat/")
225 (synopsis "SAX XML parser based on the Expat library")
226 (description "LuaExpat is a SAX XML parser based on the Expat library.")
227 (license (package-license lua-5.1))))
229 (define-public lua5.1-expat
230 (make-lua-expat "lua5.1-expat" lua-5.1))
232 (define-public lua5.2-expat
233 (make-lua-expat "lua5.2-expat" lua-5.2))
235 (define (make-lua-socket name lua)
242 (url "https://github.com/diegonehab/luasocket")
243 (commit (string-append "v" version))))
244 (file-name (git-file-name name version))
247 "1chs7z7a3i3lck4x7rz60ziwbf793gw169hpjdfca8y4yf1hzsxk"))))
248 (build-system gnu-build-system)
251 (let ((out (assoc-ref %outputs "out"))
252 (lua-version ,(version-major+minor (package-version lua))))
253 (list (string-append "INSTALL_TOP=" out)
254 (string-append "LUAV?=" lua-version)))
256 (modify-phases %standard-phases
260 (setenv "LUA_CPATH" (string-append "src/?.so." ,version ";;"))
261 (setenv "LUA_PATH" "src/?.lua;;")
262 (when (zero? (primitive-fork))
263 (invoke "lua" "test/testsrvr.lua"))
264 (invoke "lua" "test/testclnt.lua"))))))
267 (home-page "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/")
268 (synopsis "Socket library for Lua")
269 (description "LuaSocket is a Lua extension library that is composed by two
270 parts: a C core that provides support for the TCP and UDP transport layers,
271 and a set of Lua modules that add support for functionality commonly needed by
272 applications that deal with the Internet.
274 Among the supported modules, the most commonly used implement the
275 SMTP (sending e-mails), HTTP (WWW access) and FTP (uploading and downloading
276 files) client protocols. These provide a very natural and generic interface
277 to the functionality defined by each protocol. In addition, you will find
278 that the MIME (common encodings), URL (anything you could possible want to do
279 with one) and LTN12 (filters, sinks, sources and pumps) modules can be very
281 (license license:expat)))
283 (define-public lua5.1-socket
284 (make-lua-socket "lua5.1-socket" lua-5.1))
286 (define-public lua5.2-socket
287 (make-lua-socket "lua5.2-socket" lua-5.2))
289 (define (make-lua-filesystem name lua)
296 (url "https://github.com/keplerproject/luafilesystem")
297 (commit (string-append "v"
299 (string-split version #\.) "_")))))
300 (file-name (git-file-name name version))
303 "0zmprgkm9zawdf9wnw0v3w6ibaj442wlc6alp39hmw610fl4vghi"))))
304 (build-system gnu-build-system)
307 (let ((out (assoc-ref %outputs "out"))
308 (lua-version ,(version-major+minor (package-version lua))))
309 (list (string-append "PREFIX=" out)
310 (string-append "LUA_LIBDIR=" out "/lib/lua/" lua-version)))
313 (modify-phases %standard-phases
314 (delete 'configure))))
317 (home-page "https://keplerproject.github.io/luafilesystem/index.html")
318 (synopsis "File system library for Lua")
319 (description "LuaFileSystem is a Lua library developed to complement the
320 set of functions related to file systems offered by the standard Lua
321 distribution. LuaFileSystem offers a portable way to access the underlying
322 directory structure and file attributes.")
323 (license (package-license lua-5.1))))
325 (define-public lua-filesystem
326 (make-lua-filesystem "lua-filesystem" lua))
328 (define-public lua5.1-filesystem
329 (make-lua-filesystem "lua5.1-filesystem" lua-5.1))
331 (define-public lua5.2-filesystem
332 (make-lua-filesystem "lua5.2-filesystem" lua-5.2))
334 (define (make-lua-ossl name lua)
340 (uri (string-append "https://25thandclement.com/~william/"
341 "projects/releases/luaossl-" version ".tgz"))
344 "10392bvd0lzyibipblgiss09zlqh3a5zgqg1b9lgbybpqb9cv2k3"))))
345 (build-system gnu-build-system)
348 (let ((out (assoc-ref %outputs "out"))
349 (lua-api-version ,(version-major+minor (package-version lua))))
351 "CFLAGS='-D HAVE_SYS_SYSCTL_H=0'" ; sys/sysctl.h is deprecated
352 (string-append "prefix=" out)
353 (string-append "LUA_APIS=" lua-api-version)))
355 (modify-phases %standard-phases
358 (add-after 'install 'check
359 (lambda* (#:key outputs #:allow-other-keys)
360 (let ((out (assoc-ref outputs "out"))
361 (lua-version ,(version-major+minor (package-version lua))))
363 (string-append out "/lib/lua/" lua-version "/?.so;;"))
365 (string-append out "/share/lua/" lua-version "/?.lua;;"))
366 (with-directory-excursion "regress"
367 (for-each (lambda (f)
369 (find-files "." "^[0-9].*\\.lua$"))))
373 ("openssl" ,openssl)))
374 (home-page "https://25thandclement.com/~william/projects/luaossl.html")
375 (synopsis "OpenSSL bindings for Lua")
376 (description "The luaossl extension module for Lua provides comprehensive,
377 low-level bindings to the OpenSSL library, including support for certificate and
378 key management, key generation, signature verification, and deep bindings to the
379 distinguished name, alternative name, and X.509v3 extension interfaces. It also
380 binds OpenSSL's bignum, message digest, HMAC, cipher, and CSPRNG interfaces.")
381 (license license:expat)))
383 (define-public lua-ossl
384 (make-lua-ossl "lua-ossl" lua))
386 (define-public lua5.1-ossl
387 (make-lua-ossl "lua5.1-ossl" lua-5.1))
389 (define-public lua5.2-ossl
390 (make-lua-ossl "lua5.2-ossl" lua-5.2))
392 (define (make-lua-sec name lua)
399 (url "https://github.com/brunoos/luasec")
400 (commit (string-append "v" version))))
401 (file-name (git-file-name name version))
404 "0ssncgkggyr8i3z6zbvgrgsqj2q8676rnsikhpfwnk9n7sx4gwbl"))))
405 (build-system gnu-build-system)
408 (let ((out (assoc-ref %outputs "out"))
409 (lua-version ,(version-major+minor (package-version lua))))
413 (string-append "LUAPATH=" out "/share/lua/" lua-version)
414 (string-append "LUACPATH=" out "/lib/lua/" lua-version)))
415 #:tests? #f ; no tests included
417 (modify-phases %standard-phases
418 (delete 'configure))))
421 ("openssl" ,openssl)))
425 (format #f "lua~a-socket"
426 (version-major+minor (package-version lua))) lua))))
427 (home-page "https://github.com/brunoos/luasec/wiki")
428 (synopsis "OpenSSL bindings for Lua")
429 (description "LuaSec is a binding for OpenSSL library to provide TLS/SSL
430 communication. It takes an already established TCP connection and creates a
431 secure session between the peers.")
432 (license license:expat)))
434 (define-public lua5.1-sec
435 (make-lua-sec "lua5.1-sec" lua-5.1))
437 (define-public lua5.2-sec
438 (make-lua-sec "lua5.2-sec" lua-5.2))
440 (define (make-lua-cqueues name lua lua-ossl)
446 (uri (string-append "https://25thandclement.com/~william/"
447 "projects/releases/cqueues-" version ".tgz"))
450 "1dabhpn6r0hlln8vx9hxm34pfcm46qzgpb2apmziwg5z51fi4ksb"))))
451 (build-system gnu-build-system)
453 `(#:modules ((guix build gnu-build-system)
457 (let ((out (assoc-ref %outputs "out"))
458 (lua-api-version ,(version-major+minor (package-version lua))))
460 (string-append "LUA_APIS=" lua-api-version)))
462 (modify-phases %standard-phases
466 (lambda* (#:key make-flags outputs #:allow-other-keys)
467 (let ((out (assoc-ref outputs "out")))
468 (apply invoke "make" "install"
470 (list (string-append "DESTDIR=" out)
472 (add-after 'install 'check
473 (lambda* (#:key inputs outputs make-flags #:allow-other-keys)
475 ((lua-version ,(version-major+minor (package-version lua)))
476 (env-suffix (if (equal? lua-version "5.1")
480 (string-replace-substring lua-version "." "_"))))
482 (lua-ossl (assoc-ref inputs "lua-ossl"))
483 (out (assoc-ref outputs "out"))
485 (lua-cpath (lambda (p)
486 (string-append p "/lib/lua/" lua-version "/?.so")))
487 (lua-path (lambda (p)
488 (string-append p "/share/lua/" lua-version "/?.lua"))))
489 ;; The test suite sets Lua-version-specific search-path variables
490 ;; when available so we must do the same, as these take
491 ;; precedence over the generic "LUA_CPATH" and "LUA_PATH"
492 (setenv (string-append "LUA_CPATH" env-suffix)
494 (string-join (map lua-cpath (list out lua-ossl)) ";")
496 (setenv (string-append "LUA_PATH" env-suffix)
498 (string-join (map lua-path (list out lua-ossl)) ";")
501 ;; Skip regression tests we expect to fail
502 (with-directory-excursion "regress"
503 (for-each (lambda (f)
504 (rename-file f (string-append f ".skip")))
506 ;; Regression tests that require network
508 '("22-client-dtls.lua"
509 "30-starttls-completion.lua"
511 "153-dns-resolvers.lua")
513 ;; Regression tests that require LuaJIT
514 '("44-resolvers-gc.lua"
515 "51-join-defunct-thread.lua")
517 ;; Regression tests that require Lua 5.3
518 (if (not (equal? lua-version "5.3"))
519 '("152-thread-integer-passing.lua")
522 (apply invoke "make" "check" make-flags)))))))
527 ("openssl" ,openssl)))
529 `(("lua-ossl" ,lua-ossl)))
530 (home-page "https://25thandclement.com/~william/projects/cqueues.html")
531 (synopsis "Event loop for Lua using continuation queues")
532 (description "The cqueues extension module for Lua implements an event loop
533 that operates through the yielding and resumption of coroutines. It is designed
534 to be non-intrusive, composable, and embeddable within existing applications.")
535 (license license:expat)))
537 (define-public lua-cqueues
538 (make-lua-cqueues "lua-cqueues" lua lua-ossl))
540 (define-public lua5.1-cqueues
541 (make-lua-cqueues "lua5.1-cqueues" lua-5.1 lua5.1-ossl))
543 (define-public lua5.2-cqueues
544 (make-lua-cqueues "lua5.2-cqueues" lua-5.2 lua5.2-ossl))
546 (define-public lua-penlight
548 (name "lua-penlight")
554 (url "https://github.com/Tieske/Penlight")
556 (file-name (git-file-name name version))
558 (base32 "0qc2d1riyr4b5a0gnsmdw2lz5pw65s4ac60hc34w3mmk9l6yg6nl"))))
559 (build-system trivial-build-system)
563 `(("lua-filesystem" ,lua-filesystem)))
565 `(#:modules ((guix build utils))
568 (use-modules (guix build utils))
569 (let* ((source (assoc-ref %build-inputs "source"))
570 (lua-version ,(version-major+minor (package-version lua)))
571 (destination (string-append (assoc-ref %outputs "out")
572 "/share/lua/" lua-version)))
573 (mkdir-p destination)
574 (with-directory-excursion source
575 (copy-recursively "lua/" destination)))
577 (home-page "http://tieske.github.io/Penlight/")
578 (synopsis "Collection of general purpose libraries for the Lua language")
579 (description "Penlight is a set of pure Lua libraries focusing on
580 input data handling (such as reading configuration files), functional
581 programming (such as map, reduce, placeholder expressions,etc), and OS
582 path management. Much of the functionality is inspired by the Python
583 standard libraries.")
584 (license license:expat)))
586 (define-public lua-ldoc
594 (url "https://github.com/stevedonovan/LDoc")
596 (file-name (git-file-name name version))
598 (base32 "1h0cf7bp4am54r0j8lhjs2l1c7q5vz74ba0jvw9qdbaqimls46g8"))))
599 (build-system gnu-build-system)
603 `(("lua-penlight" ,lua-penlight)))
605 `(#:tests? #f ;tests must run after installation.
607 (modify-phases %standard-phases
608 (add-after 'unpack 'fix-installation-directory
609 (lambda* (#:key outputs #:allow-other-keys)
610 (let ((out (assoc-ref outputs "out"))
611 (lua-version ,(version-major+minor (package-version lua))))
612 (substitute* "makefile"
614 (("(LUA_PREFIX=).*" _ prefix)
615 (string-append prefix out "\n"))
616 (("(LUA_BINDIR=).*" _ prefix)
617 (string-append prefix out "/bin\n"))
618 (("(LUA_SHAREDIR=).*" _ prefix)
619 (string-append prefix out "/share/lua/" lua-version "\n"))))
622 (add-before 'install 'create-bin-directory
623 (lambda* (#:key outputs #:allow-other-keys)
624 (mkdir-p (string-append (assoc-ref outputs "out") "/bin"))
626 (home-page "http://stevedonovan.github.io/ldoc/")
627 (synopsis "Lua documentation generator")
629 "LDoc is a LuaDoc-compatible documentation generation system for
630 Lua source code. It parses the declaration and documentation comments
631 in a set of Lua source files and produces a set of XHTML pages
632 describing the commented declarations and functions.")
633 (license license:expat)))
635 (define (make-lua-lgi name lua)
643 (url "https://github.com/pavouk/lgi")
645 (file-name (git-file-name name version))
647 (base32 "03rbydnj411xpjvwsyvhwy4plm96481d7jax544mvk7apd8sd5jj"))))
648 (build-system gnu-build-system)
652 (string-append "PREFIX=" (assoc-ref %outputs "out")))
654 (modify-phases %standard-phases
655 (delete 'configure) ; no configure script
656 (add-before 'build 'set-env
657 (lambda* (#:key inputs #:allow-other-keys)
658 ;; We need to load cairo dynamically.
659 (let* ((cairo (string-append (assoc-ref inputs "cairo") "/lib")))
660 (setenv "LD_LIBRARY_PATH" cairo)
662 (add-before 'build 'set-lua-version
664 ;; Lua version and therefore install directories are hardcoded.
665 (substitute* "./lgi/Makefile"
669 ,(version-major+minor (package-version lua)))))
671 (add-before 'check 'skip-test-gtk
673 ;; FIXME: Skip GTK tests:
674 ;; gtk3 - can't get it to run with the xorg-server config below
675 ;; and some non-gtk tests will also fail
676 ;; gtk2 - lots of functions aren't implemented
677 ;; We choose gtk2 as the lesser evil and simply skip the test.
678 ;; Currently, awesome is the only package that uses lua-lgi but
679 ;; it doesn't need or interact with GTK using lua-lgi.
680 (substitute* "./tests/test.lua"
681 (("'gtk.lua',") "-- 'gtk.lua',"))
683 (add-before 'check 'start-xserver-instance
684 (lambda* (#:key inputs #:allow-other-keys)
685 ;; There must be a running X server during tests.
686 (system (format #f "~a/bin/Xvfb :1 &"
687 (assoc-ref inputs "xorg-server")))
688 (setenv "DISPLAY" ":1")
691 `(("dbus" ,dbus) ;tests use 'dbus-run-session'
692 ("pkg-config" ,pkg-config)))
696 ("gobject-introspection" ,gobject-introspection)
701 ("xorg-server" ,xorg-server)))
702 (home-page "https://github.com/pavouk/lgi/")
703 (synopsis "Lua bridge to GObject based libraries")
705 "LGI is gobject-introspection based dynamic Lua binding to GObject based
706 libraries. It allows using GObject-based libraries directly from Lua.
707 Notable examples are GTK+, GStreamer and Webkit.")
708 (license license:expat)))
710 (define-public lua-lgi
711 (make-lua-lgi "lua-lgi" lua))
713 (define-public lua5.1-lgi
714 (make-lua-lgi "lua5.1-lgi" lua-5.1))
716 (define-public lua5.2-lgi
717 (make-lua-lgi "lua5.2-lgi" lua-5.2))
719 (define (make-lua-lpeg name lua)
725 (uri (string-append "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-"
728 (base32 "1zjzl7acvcdavmcg5l7wi12jd4rh95q9pl5aiww7hv0v0mv6bmj8"))))
729 (build-system gnu-build-system)
732 (modify-phases %standard-phases
734 ;; `make install` isn't available, so we have to do it manually
736 (lambda* (#:key outputs #:allow-other-keys)
737 (let ((out (assoc-ref outputs "out"))
738 (lua-version ,(version-major+minor (package-version lua))))
739 (install-file "lpeg.so"
740 (string-append out "/lib/lua/" lua-version))
741 (install-file "re.lua"
742 (string-append out "/share/lua/" lua-version))
744 #:test-target "test"))
745 (inputs `(("lua" ,lua)))
746 (synopsis "Pattern-matching library for Lua")
748 "LPeg is a pattern-matching library for Lua, based on Parsing Expression
750 (home-page "http://www.inf.puc-rio.br/~roberto/lpeg")
751 (license license:expat)))
753 (define-public lua-lpeg
754 (make-lua-lpeg "lua-lpeg" lua))
756 (define-public lua5.1-lpeg
757 (make-lua-lpeg "lua5.1-lpeg" lua-5.1))
759 (define-public lua5.2-lpeg
760 (make-lua-lpeg "lua5.2-lpeg" lua-5.2))
762 (define (make-lua-luv name lua)
767 ;; The release tarball includes the sources of libuv but does
768 ;; not include the pkg-config files.
771 (url "https://github.com/luvit/luv")
773 (file-name (git-file-name name version))
776 "0c65c1lhbl0axnyks3910gjs0z0hw7w6jvl07g8kbpnbvfl4qajh"))))
777 (build-system cmake-build-system)
779 `(#:tests? #f ; there are none
781 '("-DWITH_LUA_ENGINE=Lua"
782 "-DWITH_SHARED_LIBUV=On"
784 "-DBUILD_SHARED_LIBS=On"
785 "-DLUA_BUILD_TYPE=System")
787 (modify-phases %standard-phases
788 (add-after 'unpack 'copy-lua-compat
789 (lambda* (#:key inputs #:allow-other-keys)
790 (copy-recursively (assoc-ref inputs "lua-compat")
793 (string-append (getcwd) "/lua-compat:"
794 (or (getenv "CPATH") "")))
804 (url "https://github.com/keplerproject/lua-compat-5.3")
805 (commit "daebe77a2f498817713df37f0bb316db1d82222f")))
806 (file-name "lua-compat-5.3-checkout")
809 "02a14nvn7aggg1yikj9h3dcf8aqjbxlws1bfvqbpfxv9d5phnrpz"))))))
810 (home-page "https://github.com/luvit/luv/")
811 (synopsis "Libuv bindings for Lua")
813 "This library makes libuv available to Lua scripts.")
814 (license license:asl2.0)))
816 (define-public lua-luv
817 (make-lua-luv "lua-luv" lua))
819 (define-public lua5.1-luv
820 (make-lua-luv "lua5.1-luv" lua-5.1))
822 (define-public lua5.2-luv
823 (make-lua-luv "lua5.2-luv" lua-5.2))
825 ;; Lua 5.3 is not supported.
826 (define (make-lua-bitop name lua)
832 (uri (string-append "http://bitop.luajit.org/download/"
833 "LuaBitOp-" version ".tar.gz"))
836 "16fffbrgfcw40kskh2bn9q7m3gajffwd2f35rafynlnd7llwj1qj"))))
837 (build-system gnu-build-system)
839 `(#:test-target "test"
841 (list "INSTALL=install -pD"
842 (string-append "INSTALLPATH=printf "
843 (assoc-ref %outputs "out")
845 ,(version-major+minor (package-version lua))
848 (modify-phases %standard-phases
849 (delete 'configure))))
850 (inputs `(("lua" ,lua)))
851 (home-page "https://bitop.luajit.org/index.html")
852 (synopsis "Bitwise operations on numbers for Lua")
854 "Lua BitOp is a C extension module for Lua which adds bitwise operations
856 (license license:expat)))
858 (define-public lua5.2-bitop
859 (make-lua-bitop "lua5.2-bitop" lua-5.2))
861 (define-public lua5.1-bitop
862 (make-lua-bitop "lua5.1-bitop" lua-5.1))
864 (define-public selene
867 (version "2017.08.25")
871 (url "https://github.com/jeremyong/Selene")
872 ;; The release is quite old.
873 (commit "ffe1ade2568d4cff5894552be8f43e63e379a4c9")))
877 "1axrgv3rxxdsaf807lwvklfzicn6x6gpf35narllrnz9lg6hn508"))))
878 (build-system cmake-build-system)
881 ;; lua pc file in CMakeLists.txt is lua5.3.pc
882 '("-DLUA_PC_CFG=lua;lua-5.3;lua-5.1")
885 ;; This is a header only library
886 (modify-phases %standard-phases
889 (lambda* (#:key inputs outputs #:allow-other-keys)
890 (let* ((output (assoc-ref outputs "out"))
891 (source (assoc-ref inputs "source"))
892 (includedir (string-append output "/include")))
894 (string-append source "/include")
897 ;; The path of test files are hard coded.
899 (lambda* (#:key inputs outputs #:allow-other-keys)
900 (let* ((output (assoc-ref outputs "out"))
901 (source (assoc-ref inputs "source"))
903 (testdir (string-append builddir "/test")))
904 (copy-recursively (string-append source "/test") testdir)
907 (copy-file "./test_runner" "./runner/test_runner")
909 (invoke "./test_runner")))))))
912 ("pkg-config" ,pkg-config)))
913 (home-page "https://github.com/jeremyong/Selene")
914 (synopsis "Lua C++11 bindings")
916 "Selene is a simple C++11 header-only library enabling seamless
917 interoperability between C++ and Lua programming language.")
918 (license license:zlib)))
920 (define-public lua-resty-core
922 (name "lua-resty-core")
927 (url "https://github.com/openresty/lua-resty-core")
928 (commit (string-append "v" version))))
929 (file-name (git-file-name name version))
932 "1c58hykwpg5zqbyhrcb703pzwbkih409v3bh2gady6z2kj9q32dw"))))
933 (build-system trivial-build-system)
935 `(#:modules ((guix build utils))
938 (use-modules (guix build utils))
939 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
940 (package-lua-resty (lambda (input output)
941 (mkdir-p (string-append output "/lib/lua"))
942 (copy-recursively (string-append input "/lib/resty")
943 (string-append output "/lib/lua/resty"))
944 (copy-recursively (string-append input "/lib/ngx")
945 (string-append output "/lib/ngx"))
946 (symlink (string-append output "/lib/lua/resty")
947 (string-append output "/lib/resty")))))
948 (package-lua-resty (assoc-ref %build-inputs "source")
949 (assoc-ref %outputs "out")))
951 (home-page "https://github.com/openresty/lua-resty-core")
952 (synopsis "Lua API for NGINX")
953 (description "This package provides a FFI-based Lua API for
954 @code{ngx_http_lua_module} or @code{ngx_stream_lua_module}.")
955 (license license:bsd-2)))
957 (define-public lua-resty-lrucache
959 (name "lua-resty-lrucache")
964 (url "https://github.com/openresty/lua-resty-lrucache")
965 (commit (string-append "v" version))))
966 (file-name (git-file-name name version))
969 "1bsc54v1rvxmkwg7a2c01p192lvw5g576f589is8fy1m1c6v4ap8"))))
970 (build-system trivial-build-system)
972 `(#:modules ((guix build utils))
975 (use-modules (guix build utils))
976 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
977 (package-lua-resty (lambda (input output)
978 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
979 (copy-recursively (string-append input "/lib/resty")
980 (string-append output "/lib/lua/" luajit-major+minor "/resty"))
981 (symlink (string-append output "/lib/lua/" luajit-major+minor "/resty")
982 (string-append output "/lib/resty")))))
983 (package-lua-resty (assoc-ref %build-inputs "source")
984 (assoc-ref %outputs "out")))
986 (home-page "https://github.com/openresty/lua-resty-lrucache")
987 (synopsis "Lua LRU cache based on the LuaJIT FFI")
989 "This package provides Lua LRU cache based on the LuaJIT FFI.")
990 (license license:bsd-2)))
992 (define-public lua-resty-signal
994 (name "lua-resty-signal")
999 (url "https://github.com/openresty/lua-resty-signal")
1000 (commit (string-append "v" version))))
1001 (file-name (git-file-name name version))
1004 "13y1pqn45y49mhqwywasfdsid46d0c33yi6mrnracbnmvyxz1cif"))))
1005 (build-system gnu-build-system)
1007 `(#:tests? #f ;TODO: Run the test suite.
1008 #:make-flags (list "CC=gcc"
1009 (string-append "PREFIX=" %output))
1011 (modify-phases %standard-phases
1013 (add-after 'install 'install-lua
1014 (lambda* (#:key inputs outputs #:allow-other-keys)
1015 (use-modules (guix build utils))
1016 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1017 (package-lua-resty (lambda (input output)
1018 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1019 (copy-recursively (string-append input "/lib/resty")
1020 (string-append output "/lib/lua/" luajit-major+minor "/resty"))
1021 (symlink (string-append output "/lib/lua/" luajit-major+minor "/resty")
1022 (string-append output "/lib/resty")))))
1023 (package-lua-resty (assoc-ref inputs "source")
1024 (assoc-ref outputs "out")))
1026 (home-page "https://github.com/openresty/lua-resty-signal")
1027 (synopsis "Lua library for killing or sending signals to Linux processes")
1028 (description "This package provides Lua library for killing or sending
1029 signals to Linux processes.")
1030 (license license:bsd-3)))
1032 (define-public lua-tablepool
1034 (name "lua-tablepool")
1039 (url "https://github.com/openresty/lua-tablepool")
1040 (commit (string-append "v" version))))
1041 (file-name (git-file-name name version))
1044 "03yjj3w6znvj6843prg84m0lkrn49l901f9hj9bgy3cj9s0awl6y"))))
1045 (build-system trivial-build-system)
1047 `(#:modules ((guix build utils))
1050 (use-modules (guix build utils))
1051 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1052 (package-lua-resty (lambda (input output)
1053 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1054 (copy-recursively (string-append input "/lib")
1055 (string-append output "/lib")))))
1056 (package-lua-resty (assoc-ref %build-inputs "source")
1057 (assoc-ref %outputs "out")))
1059 (home-page "https://github.com/openresty/lua-tablepool")
1060 (synopsis "Lua table recycling pools for LuaJIT")
1061 (description "This package provides Lua table recycling pools for LuaJIT.")
1062 (license license:bsd-2)))
1064 (define-public lua-resty-shell
1066 (name "lua-resty-shell")
1071 (url "https://github.com/openresty/lua-resty-shell")
1072 (commit (string-append "v" version))))
1073 (file-name (git-file-name name version))
1076 "1s6g04ip4hr97r2pd8ry3alq063604s9a3l0hn9nsidh81ps4dp7"))))
1077 (build-system trivial-build-system)
1079 `(#:modules ((guix build utils))
1082 (use-modules (guix build utils))
1083 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1084 (package-lua-resty (lambda (input output)
1085 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1086 (copy-recursively (string-append input "/lib/resty")
1087 (string-append output "/lib/lua/" luajit-major+minor "/resty"))
1088 (symlink (string-append output "/lib/lua/" luajit-major+minor "/resty")
1089 (string-append output "/lib/resty")))))
1090 (package-lua-resty (assoc-ref %build-inputs "source")
1091 (assoc-ref %outputs "out")))
1093 (home-page "https://github.com/openresty/lua-resty-shell")
1094 (synopsis "Lua module for nonblocking system shell command executions")
1095 (description "This package provides Lua module for nonblocking system
1096 shell command executions.")
1097 (license license:bsd-3)))
1099 (define-public fennel
1106 (url "https://git.sr.ht/~technomancy/fennel")
1108 (file-name (git-file-name name version))
1111 "1jng33vmnk6mi37l3x2z0plng940jpj7kz1s493ki80z3mkaxjfg"))
1112 (modules '((guix build utils)))
1115 (delete-file "fennelview.lua") #t))))
1116 (build-system gnu-build-system)
1118 '(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
1119 #:tests? #t ; even on cross-build
1120 #:test-target "test"
1122 (modify-phases %standard-phases
1124 (add-before 'build 'patch-lua-calls
1125 (lambda* (#:key inputs #:allow-other-keys)
1126 (let ((lua (string-append (assoc-ref inputs "lua") "/bin/lua")))
1128 (substitute* "old/launcher.lua"
1129 (("/usr/bin/env lua") lua))
1131 (add-after 'build 'patch-fennel
1132 (lambda* (#:key inputs #:allow-other-keys)
1133 (substitute* "fennel"
1134 (("/usr/bin/env .*lua")
1135 (string-append (assoc-ref inputs "lua") "/bin/lua")))
1138 (add-after 'install 'check
1139 (assoc-ref %standard-phases 'check))
1140 (add-after 'install 'install-manpage
1141 (lambda* (#:key outputs #:allow-other-keys)
1142 (install-file "fennel.1"
1143 (string-append (assoc-ref outputs "out")
1146 (inputs `(("lua" ,lua)))
1147 (home-page "https://fennel-lang.org/")
1148 (synopsis "Lisp that compiles to Lua")
1150 "Fennel is a programming language that brings together the speed,
1151 simplicity, and reach of Lua with the flexibility of a Lisp syntax and macro
1153 (license license:expat)))