Merge branch 'master' into staging
[jackhill/guix/guix.git] / gnu / packages / lua.scm
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>
16 ;;;
17 ;;; This file is part of GNU Guix.
18 ;;;
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.
23 ;;;
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.
28 ;;;
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/>.
31
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))
52
53 (define-public lua
54 (package
55 (name "lua")
56 (version "5.3.5")
57 (source (origin
58 (method url-fetch)
59 (uri (string-append "https://www.lua.org/ftp/lua-"
60 version ".tar.gz"))
61 (sha256
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)))
67 (arguments
68 `(#:modules ((guix build gnu-build-system)
69 (guix build utils)
70 (srfi srfi-1))
71 #:test-target "test"
72 #:make-flags
73 (list "MYCFLAGS=-fPIC -DLUA_DL_DLOPEN"
74 (string-append "CC=" ,(cc-for-target))
75 (string-append "SYSLIBS=-L" (assoc-ref %build-inputs "readline")
76 "/lib")
77 "linux")
78 #:phases
79 (modify-phases %standard-phases
80 (delete 'configure)
81 (replace 'install
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")
90 (description
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)))
98
99 (define-public lua-5.2
100 (package (inherit lua)
101 (version "5.2.4")
102 (source
103 (origin
104 (method url-fetch)
105 (uri (string-append "https://www.lua.org/ftp/lua-"
106 version ".tar.gz"))
107 (sha256
108 (base32 "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr"))
109 (patches (search-patches "lua-pkgconfig.patch"
110 "lua-liblua-so.patch"))))))
111
112 (define-public lua-5.1
113 (package (inherit lua)
114 (version "5.1.5")
115 (source (origin
116 (method url-fetch)
117 (uri (string-append "https://www.lua.org/ftp/lua-"
118 version ".tar.gz"))
119 (sha256
120 (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))
121 (patches (search-patches "lua51-liblua-so.patch"
122 "lua-CVE-2014-5461.patch"
123 "lua51-pkgconfig.patch"))))))
124
125 (define-public luajit
126 (package
127 (name "luajit")
128 (version "2.1.0-beta3")
129 (source (origin
130 (method url-fetch)
131 (uri (string-append "http://luajit.org/download/LuaJIT-"
132 version ".tar.gz"))
133 (sha256
134 (base32 "1hyrhpkwjqsv54hnnx4cl8vk44h9d6c9w0fz1jfjz00w255y7lhs"))
135 (patches (search-patches "luajit-no_ldconfig.patch"))))
136 (build-system gnu-build-system)
137 (arguments
138 `(#:tests? #f ; luajit is distributed without tests
139 #:phases
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)
148 ,name)
149 #t)))))
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")
153 (description
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
157 language.")
158 (license license:x11)))
159
160 (define (make-lua-expat name lua)
161 (package
162 (name name)
163 (version "1.3.0")
164 (source (origin
165 (method url-fetch)
166 (uri (string-append "https://matthewwild.co.uk/projects/"
167 "luaexpat/luaexpat-" version ".tar.gz"))
168 (sha256
169 (base32
170 "1hvxqngn0wf5642i5p3vcyhg3pmp102k63s9ry4jqyyqc1wkjq6h"))))
171 (build-system gnu-build-system)
172 (arguments
173 `(#:make-flags
174 (let ((out (assoc-ref %outputs "out"))
175 (lua-version ,(version-major+minor (package-version lua))))
176 (list "CC=gcc"
177 (string-append "LUA_LDIR=" out "/share/lua/" lua-version)
178 (string-append "LUA_CDIR=" out "/lib/lua/" lua-version)))
179 #:phases
180 (modify-phases %standard-phases
181 (delete 'configure)
182 (replace 'check
183 (lambda _
184 (setenv "LUA_CPATH" "src/?.so;;")
185 (setenv "LUA_PATH" "src/?.lua;;")
186 (invoke "lua" "tests/test.lua")
187 (invoke "lua" "tests/test-lom.lua"))))))
188 (inputs
189 `(("lua" ,lua)
190 ("expat" ,expat)))
191 (home-page "https://matthewwild.co.uk/projects/luaexpat/")
192 (synopsis "SAX XML parser based on the Expat library")
193 (description "LuaExpat is a SAX XML parser based on the Expat library.")
194 (license (package-license lua-5.1))))
195
196 (define-public lua5.1-expat
197 (make-lua-expat "lua5.1-expat" lua-5.1))
198
199 (define-public lua5.2-expat
200 (make-lua-expat "lua5.2-expat" lua-5.2))
201
202 (define (make-lua-socket name lua)
203 (package
204 (name name)
205 (version "3.0-rc1")
206 (source (origin
207 (method git-fetch)
208 (uri (git-reference
209 (url "https://github.com/diegonehab/luasocket")
210 (commit (string-append "v" version))))
211 (file-name (git-file-name name version))
212 (sha256
213 (base32
214 "1chs7z7a3i3lck4x7rz60ziwbf793gw169hpjdfca8y4yf1hzsxk"))))
215 (build-system gnu-build-system)
216 (arguments
217 `(#:make-flags
218 (let ((out (assoc-ref %outputs "out"))
219 (lua-version ,(version-major+minor (package-version lua))))
220 (list (string-append "INSTALL_TOP=" out)
221 (string-append "LUAV?=" lua-version)))
222 #:phases
223 (modify-phases %standard-phases
224 (delete 'configure)
225 (replace 'check
226 (lambda _
227 (setenv "LUA_CPATH" (string-append "src/?.so." ,version ";;"))
228 (setenv "LUA_PATH" "src/?.lua;;")
229 (when (zero? (primitive-fork))
230 (invoke "lua" "test/testsrvr.lua"))
231 (invoke "lua" "test/testclnt.lua"))))))
232 (inputs
233 `(("lua" ,lua)))
234 (home-page "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/")
235 (synopsis "Socket library for Lua")
236 (description "LuaSocket is a Lua extension library that is composed by two
237 parts: a C core that provides support for the TCP and UDP transport layers,
238 and a set of Lua modules that add support for functionality commonly needed by
239 applications that deal with the Internet.
240
241 Among the supported modules, the most commonly used implement the
242 SMTP (sending e-mails), HTTP (WWW access) and FTP (uploading and downloading
243 files) client protocols. These provide a very natural and generic interface
244 to the functionality defined by each protocol. In addition, you will find
245 that the MIME (common encodings), URL (anything you could possible want to do
246 with one) and LTN12 (filters, sinks, sources and pumps) modules can be very
247 handy.")
248 (license license:expat)))
249
250 (define-public lua5.1-socket
251 (make-lua-socket "lua5.1-socket" lua-5.1))
252
253 (define-public lua5.2-socket
254 (make-lua-socket "lua5.2-socket" lua-5.2))
255
256 (define (make-lua-filesystem name lua)
257 (package
258 (name name)
259 (version "1.7.0.2")
260 (source (origin
261 (method git-fetch)
262 (uri (git-reference
263 (url "https://github.com/keplerproject/luafilesystem")
264 (commit (string-append "v"
265 (string-join
266 (string-split version #\.) "_")))))
267 (file-name (git-file-name name version))
268 (sha256
269 (base32
270 "0zmprgkm9zawdf9wnw0v3w6ibaj442wlc6alp39hmw610fl4vghi"))))
271 (build-system gnu-build-system)
272 (arguments
273 `(#:make-flags
274 (let ((out (assoc-ref %outputs "out"))
275 (lua-version ,(version-major+minor (package-version lua))))
276 (list (string-append "PREFIX=" out)
277 (string-append "LUA_LIBDIR=" out "/lib/lua/" lua-version)))
278 #:test-target "test"
279 #:phases
280 (modify-phases %standard-phases
281 (delete 'configure))))
282 (inputs
283 `(("lua" ,lua)))
284 (home-page "https://keplerproject.github.io/luafilesystem/index.html")
285 (synopsis "File system library for Lua")
286 (description "LuaFileSystem is a Lua library developed to complement the
287 set of functions related to file systems offered by the standard Lua
288 distribution. LuaFileSystem offers a portable way to access the underlying
289 directory structure and file attributes.")
290 (license (package-license lua-5.1))))
291
292 (define-public lua-filesystem
293 (make-lua-filesystem "lua-filesystem" lua))
294
295 (define-public lua5.1-filesystem
296 (make-lua-filesystem "lua5.1-filesystem" lua-5.1))
297
298 (define-public lua5.2-filesystem
299 (make-lua-filesystem "lua5.2-filesystem" lua-5.2))
300
301 (define (make-lua-ossl name lua)
302 (package
303 (name name)
304 (version "20170903")
305 (source (origin
306 (method url-fetch)
307 (uri (string-append "https://25thandclement.com/~william/"
308 "projects/releases/luaossl-" version ".tgz"))
309 (sha256
310 (base32
311 "10392bvd0lzyibipblgiss09zlqh3a5zgqg1b9lgbybpqb9cv2k3"))))
312 (build-system gnu-build-system)
313 (arguments
314 `(#:make-flags
315 (let ((out (assoc-ref %outputs "out"))
316 (lua-api-version ,(version-major+minor (package-version lua))))
317 (list "CC=gcc"
318 "CFLAGS='-D HAVE_SYS_SYSCTL_H=0'" ; sys/sysctl.h is deprecated
319 (string-append "prefix=" out)
320 (string-append "LUA_APIS=" lua-api-version)))
321 #:phases
322 (modify-phases %standard-phases
323 (delete 'configure)
324 (delete 'check)
325 (add-after 'install 'check
326 (lambda* (#:key outputs #:allow-other-keys)
327 (let ((out (assoc-ref outputs "out"))
328 (lua-version ,(version-major+minor (package-version lua))))
329 (setenv "LUA_CPATH"
330 (string-append out "/lib/lua/" lua-version "/?.so;;"))
331 (setenv "LUA_PATH"
332 (string-append out "/share/lua/" lua-version "/?.lua;;"))
333 (with-directory-excursion "regress"
334 (for-each (lambda (f)
335 (invoke "lua" f))
336 (find-files "." "^[0-9].*\\.lua$"))))
337 #t)))))
338 (inputs
339 `(("lua" ,lua)
340 ("openssl" ,openssl)))
341 (home-page "https://25thandclement.com/~william/projects/luaossl.html")
342 (synopsis "OpenSSL bindings for Lua")
343 (description "The luaossl extension module for Lua provides comprehensive,
344 low-level bindings to the OpenSSL library, including support for certificate and
345 key management, key generation, signature verification, and deep bindings to the
346 distinguished name, alternative name, and X.509v3 extension interfaces. It also
347 binds OpenSSL's bignum, message digest, HMAC, cipher, and CSPRNG interfaces.")
348 (license license:expat)))
349
350 (define-public lua-ossl
351 (make-lua-ossl "lua-ossl" lua))
352
353 (define-public lua5.1-ossl
354 (make-lua-ossl "lua5.1-ossl" lua-5.1))
355
356 (define-public lua5.2-ossl
357 (make-lua-ossl "lua5.2-ossl" lua-5.2))
358
359 (define (make-lua-sec name lua)
360 (package
361 (name name)
362 (version "0.9")
363 (source (origin
364 (method git-fetch)
365 (uri (git-reference
366 (url "https://github.com/brunoos/luasec")
367 (commit (string-append "v" version))))
368 (file-name (git-file-name name version))
369 (sha256
370 (base32
371 "0ssncgkggyr8i3z6zbvgrgsqj2q8676rnsikhpfwnk9n7sx4gwbl"))))
372 (build-system gnu-build-system)
373 (arguments
374 `(#:make-flags
375 (let ((out (assoc-ref %outputs "out"))
376 (lua-version ,(version-major+minor (package-version lua))))
377 (list "linux"
378 "CC=gcc"
379 "LD=gcc"
380 (string-append "LUAPATH=" out "/share/lua/" lua-version)
381 (string-append "LUACPATH=" out "/lib/lua/" lua-version)))
382 #:tests? #f ; no tests included
383 #:phases
384 (modify-phases %standard-phases
385 (delete 'configure))))
386 (inputs
387 `(("lua" ,lua)
388 ("openssl" ,openssl)))
389 (propagated-inputs
390 `(("lua-socket"
391 ,(make-lua-socket
392 (format #f "lua~a-socket"
393 (version-major+minor (package-version lua))) lua))))
394 (home-page "https://github.com/brunoos/luasec/wiki")
395 (synopsis "OpenSSL bindings for Lua")
396 (description "LuaSec is a binding for OpenSSL library to provide TLS/SSL
397 communication. It takes an already established TCP connection and creates a
398 secure session between the peers.")
399 (license license:expat)))
400
401 (define-public lua5.1-sec
402 (make-lua-sec "lua5.1-sec" lua-5.1))
403
404 (define-public lua5.2-sec
405 (make-lua-sec "lua5.2-sec" lua-5.2))
406
407 (define (make-lua-cqueues name lua lua-ossl)
408 (package
409 (name name)
410 (version "20171014")
411 (source (origin
412 (method url-fetch)
413 (uri (string-append "https://25thandclement.com/~william/"
414 "projects/releases/cqueues-" version ".tgz"))
415 (sha256
416 (base32
417 "1dabhpn6r0hlln8vx9hxm34pfcm46qzgpb2apmziwg5z51fi4ksb"))))
418 (build-system gnu-build-system)
419 (arguments
420 `(#:modules ((guix build gnu-build-system)
421 (guix build utils)
422 (ice-9 string-fun))
423 #:make-flags
424 (let ((out (assoc-ref %outputs "out"))
425 (lua-api-version ,(version-major+minor (package-version lua))))
426 (list "CC=gcc"
427 (string-append "LUA_APIS=" lua-api-version)))
428 #:phases
429 (modify-phases %standard-phases
430 (delete 'configure)
431 (delete 'check)
432 (replace 'install
433 (lambda* (#:key make-flags outputs #:allow-other-keys)
434 (let ((out (assoc-ref outputs "out")))
435 (apply invoke "make" "install"
436 (append make-flags
437 (list (string-append "DESTDIR=" out)
438 "prefix="))))))
439 (add-after 'install 'check
440 (lambda* (#:key inputs outputs make-flags #:allow-other-keys)
441 (let*
442 ((lua-version ,(version-major+minor (package-version lua)))
443 (env-suffix (if (equal? lua-version "5.1")
444 ""
445 (string-append
446 "_"
447 (string-replace-substring lua-version "." "_"))))
448
449 (lua-ossl (assoc-ref inputs "lua-ossl"))
450 (out (assoc-ref outputs "out"))
451
452 (lua-cpath (lambda (p)
453 (string-append p "/lib/lua/" lua-version "/?.so")))
454 (lua-path (lambda (p)
455 (string-append p "/share/lua/" lua-version "/?.lua"))))
456 ;; The test suite sets Lua-version-specific search-path variables
457 ;; when available so we must do the same, as these take
458 ;; precedence over the generic "LUA_CPATH" and "LUA_PATH"
459 (setenv (string-append "LUA_CPATH" env-suffix)
460 (string-append
461 (string-join (map lua-cpath (list out lua-ossl)) ";")
462 ";;"))
463 (setenv (string-append "LUA_PATH" env-suffix)
464 (string-append
465 (string-join (map lua-path (list out lua-ossl)) ";")
466 ";;"))
467
468 ;; Skip regression tests we expect to fail
469 (with-directory-excursion "regress"
470 (for-each (lambda (f)
471 (rename-file f (string-append f ".skip")))
472 (append
473 ;; Regression tests that require network
474 ;; connectivity
475 '("22-client-dtls.lua"
476 "30-starttls-completion.lua"
477 "62-noname.lua"
478 "153-dns-resolvers.lua")
479
480 ;; Regression tests that require LuaJIT
481 '("44-resolvers-gc.lua"
482 "51-join-defunct-thread.lua")
483
484 ;; Regression tests that require Lua 5.3
485 (if (not (equal? lua-version "5.3"))
486 '("152-thread-integer-passing.lua")
487 '()))))
488
489 (apply invoke "make" "check" make-flags)))))))
490 (native-inputs
491 `(("m4" ,m4)))
492 (inputs
493 `(("lua" ,lua)
494 ("openssl" ,openssl)))
495 (propagated-inputs
496 `(("lua-ossl" ,lua-ossl)))
497 (home-page "https://25thandclement.com/~william/projects/cqueues.html")
498 (synopsis "Event loop for Lua using continuation queues")
499 (description "The cqueues extension module for Lua implements an event loop
500 that operates through the yielding and resumption of coroutines. It is designed
501 to be non-intrusive, composable, and embeddable within existing applications.")
502 (license license:expat)))
503
504 (define-public lua-cqueues
505 (make-lua-cqueues "lua-cqueues" lua lua-ossl))
506
507 (define-public lua5.1-cqueues
508 (make-lua-cqueues "lua5.1-cqueues" lua-5.1 lua5.1-ossl))
509
510 (define-public lua5.2-cqueues
511 (make-lua-cqueues "lua5.2-cqueues" lua-5.2 lua5.2-ossl))
512
513 (define-public lua-penlight
514 (package
515 (name "lua-penlight")
516 (version "1.7.0")
517 (source
518 (origin
519 (method git-fetch)
520 (uri (git-reference
521 (url "https://github.com/Tieske/Penlight")
522 (commit version)))
523 (file-name (git-file-name name version))
524 (sha256
525 (base32 "0qc2d1riyr4b5a0gnsmdw2lz5pw65s4ac60hc34w3mmk9l6yg6nl"))))
526 (build-system trivial-build-system)
527 (inputs
528 `(("lua" ,lua)))
529 (propagated-inputs
530 `(("lua-filesystem" ,lua-filesystem)))
531 (arguments
532 `(#:modules ((guix build utils))
533 #:builder
534 (begin
535 (use-modules (guix build utils))
536 (let* ((source (assoc-ref %build-inputs "source"))
537 (lua-version ,(version-major+minor (package-version lua)))
538 (destination (string-append (assoc-ref %outputs "out")
539 "/share/lua/" lua-version)))
540 (mkdir-p destination)
541 (with-directory-excursion source
542 (copy-recursively "lua/" destination)))
543 #t)))
544 (home-page "http://tieske.github.io/Penlight/")
545 (synopsis "Collection of general purpose libraries for the Lua language")
546 (description "Penlight is a set of pure Lua libraries focusing on
547 input data handling (such as reading configuration files), functional
548 programming (such as map, reduce, placeholder expressions,etc), and OS
549 path management. Much of the functionality is inspired by the Python
550 standard libraries.")
551 (license license:expat)))
552
553 (define-public lua-ldoc
554 (package
555 (name "lua-ldoc")
556 (version "1.4.6")
557 (source
558 (origin
559 (method git-fetch)
560 (uri (git-reference
561 (url "https://github.com/stevedonovan/LDoc")
562 (commit version)))
563 (file-name (git-file-name name version))
564 (sha256
565 (base32 "1h0cf7bp4am54r0j8lhjs2l1c7q5vz74ba0jvw9qdbaqimls46g8"))))
566 (build-system gnu-build-system)
567 (inputs
568 `(("lua" ,lua)))
569 (propagated-inputs
570 `(("lua-penlight" ,lua-penlight)))
571 (arguments
572 `(#:tests? #f ;tests must run after installation.
573 #:phases
574 (modify-phases %standard-phases
575 (add-after 'unpack 'fix-installation-directory
576 (lambda* (#:key outputs #:allow-other-keys)
577 (let ((out (assoc-ref outputs "out"))
578 (lua-version ,(version-major+minor (package-version lua))))
579 (substitute* "makefile"
580 (("LUA=.*") "#\n")
581 (("(LUA_PREFIX=).*" _ prefix)
582 (string-append prefix out "\n"))
583 (("(LUA_BINDIR=).*" _ prefix)
584 (string-append prefix out "/bin\n"))
585 (("(LUA_SHAREDIR=).*" _ prefix)
586 (string-append prefix out "/share/lua/" lua-version "\n"))))
587 #t))
588 (delete 'configure)
589 (add-before 'install 'create-bin-directory
590 (lambda* (#:key outputs #:allow-other-keys)
591 (mkdir-p (string-append (assoc-ref outputs "out") "/bin"))
592 #t)))))
593 (home-page "http://stevedonovan.github.io/ldoc/")
594 (synopsis "Lua documentation generator")
595 (description
596 "LDoc is a LuaDoc-compatible documentation generation system for
597 Lua source code. It parses the declaration and documentation comments
598 in a set of Lua source files and produces a set of XHTML pages
599 describing the commented declarations and functions.")
600 (license license:expat)))
601
602 (define (make-lua-lgi name lua)
603 (package
604 (name name)
605 (version "0.9.2")
606 (source
607 (origin
608 (method git-fetch)
609 (uri (git-reference
610 (url "https://github.com/pavouk/lgi")
611 (commit version)))
612 (file-name (git-file-name name version))
613 (sha256
614 (base32 "03rbydnj411xpjvwsyvhwy4plm96481d7jax544mvk7apd8sd5jj"))))
615 (build-system gnu-build-system)
616 (arguments
617 `(#:make-flags
618 (list "CC=gcc"
619 (string-append "PREFIX=" (assoc-ref %outputs "out")))
620 #:phases
621 (modify-phases %standard-phases
622 (delete 'configure) ; no configure script
623 (add-before 'build 'set-env
624 (lambda* (#:key inputs #:allow-other-keys)
625 ;; We need to load cairo dynamically.
626 (let* ((cairo (string-append (assoc-ref inputs "cairo") "/lib")))
627 (setenv "LD_LIBRARY_PATH" cairo)
628 #t)))
629 (add-before 'build 'set-lua-version
630 (lambda _
631 ;; Lua version and therefore install directories are hardcoded.
632 (substitute* "./lgi/Makefile"
633 (("LUA_VERSION=5.1")
634 (format #f
635 "LUA_VERSION=~a"
636 ,(version-major+minor (package-version lua)))))
637 #t))
638 (add-before 'check 'skip-test-gtk
639 (lambda _
640 ;; FIXME: Skip GTK tests:
641 ;; gtk3 - can't get it to run with the xorg-server config below
642 ;; and some non-gtk tests will also fail
643 ;; gtk2 - lots of functions aren't implemented
644 ;; We choose gtk2 as the lesser evil and simply skip the test.
645 ;; Currently, awesome is the only package that uses lua-lgi but
646 ;; it doesn't need or interact with GTK using lua-lgi.
647 (substitute* "./tests/test.lua"
648 (("'gtk.lua',") "-- 'gtk.lua',"))
649 #t))
650 (add-before 'check 'start-xserver-instance
651 (lambda* (#:key inputs #:allow-other-keys)
652 ;; There must be a running X server during tests.
653 (system (format #f "~a/bin/Xvfb :1 &"
654 (assoc-ref inputs "xorg-server")))
655 (setenv "DISPLAY" ":1")
656 #t)))))
657 (native-inputs
658 `(("dbus" ,dbus) ;tests use 'dbus-run-session'
659 ("pkg-config" ,pkg-config)))
660 (inputs
661 `(("cairo" ,cairo)
662 ("glib" ,glib)
663 ("gobject-introspection" ,gobject-introspection)
664 ("gtk" ,gtk+-2)
665 ("libffi" ,libffi)
666 ("lua" ,lua)
667 ("pango" ,pango)
668 ("xorg-server" ,xorg-server)))
669 (home-page "https://github.com/pavouk/lgi/")
670 (synopsis "Lua bridge to GObject based libraries")
671 (description
672 "LGI is gobject-introspection based dynamic Lua binding to GObject based
673 libraries. It allows using GObject-based libraries directly from Lua.
674 Notable examples are GTK+, GStreamer and Webkit.")
675 (license license:expat)))
676
677 (define-public lua-lgi
678 (make-lua-lgi "lua-lgi" lua))
679
680 (define-public lua5.1-lgi
681 (make-lua-lgi "lua5.1-lgi" lua-5.1))
682
683 (define-public lua5.2-lgi
684 (make-lua-lgi "lua5.2-lgi" lua-5.2))
685
686 (define (make-lua-lpeg name lua)
687 (package
688 (name name)
689 (version "1.0.2")
690 (source (origin
691 (method url-fetch)
692 (uri (string-append "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-"
693 version ".tar.gz"))
694 (sha256
695 (base32 "1zjzl7acvcdavmcg5l7wi12jd4rh95q9pl5aiww7hv0v0mv6bmj8"))))
696 (build-system gnu-build-system)
697 (arguments
698 `(#:phases
699 (modify-phases %standard-phases
700 (delete 'configure)
701 ;; `make install` isn't available, so we have to do it manually
702 (replace 'install
703 (lambda* (#:key outputs #:allow-other-keys)
704 (let ((out (assoc-ref outputs "out"))
705 (lua-version ,(version-major+minor (package-version lua))))
706 (install-file "lpeg.so"
707 (string-append out "/lib/lua/" lua-version))
708 (install-file "re.lua"
709 (string-append out "/share/lua/" lua-version))
710 #t))))
711 #:test-target "test"))
712 (inputs `(("lua" ,lua)))
713 (synopsis "Pattern-matching library for Lua")
714 (description
715 "LPeg is a pattern-matching library for Lua, based on Parsing Expression
716 Grammars (PEGs).")
717 (home-page "http://www.inf.puc-rio.br/~roberto/lpeg")
718 (license license:expat)))
719
720 (define-public lua-lpeg
721 (make-lua-lpeg "lua-lpeg" lua))
722
723 (define-public lua5.1-lpeg
724 (make-lua-lpeg "lua5.1-lpeg" lua-5.1))
725
726 (define-public lua5.2-lpeg
727 (make-lua-lpeg "lua5.2-lpeg" lua-5.2))
728
729 (define (make-lua-luv name lua)
730 (package
731 (name name)
732 (version "1.32.0-0")
733 (source (origin
734 ;; The release tarball includes the sources of libuv but does
735 ;; not include the pkg-config files.
736 (method git-fetch)
737 (uri (git-reference
738 (url "https://github.com/luvit/luv")
739 (commit version)))
740 (file-name (git-file-name name version))
741 (sha256
742 (base32
743 "0c65c1lhbl0axnyks3910gjs0z0hw7w6jvl07g8kbpnbvfl4qajh"))))
744 (build-system cmake-build-system)
745 (arguments
746 `(#:tests? #f ; there are none
747 #:configure-flags
748 '("-DWITH_LUA_ENGINE=Lua"
749 "-DWITH_SHARED_LIBUV=On"
750 "-DBUILD_MODULE=Off"
751 "-DBUILD_SHARED_LIBS=On"
752 "-DLUA_BUILD_TYPE=System")
753 #:phases
754 (modify-phases %standard-phases
755 (add-after 'unpack 'copy-lua-compat
756 (lambda* (#:key inputs #:allow-other-keys)
757 (copy-recursively (assoc-ref inputs "lua-compat")
758 "lua-compat")
759 (setenv "CPATH"
760 (string-append (getcwd) "/lua-compat:"
761 (or (getenv "CPATH") "")))
762 #t)))))
763 (inputs
764 `(("lua" ,lua)
765 ("libuv" ,libuv)))
766 (native-inputs
767 `(("lua-compat"
768 ,(origin
769 (method git-fetch)
770 (uri (git-reference
771 (url "https://github.com/keplerproject/lua-compat-5.3")
772 (commit "daebe77a2f498817713df37f0bb316db1d82222f")))
773 (file-name "lua-compat-5.3-checkout")
774 (sha256
775 (base32
776 "02a14nvn7aggg1yikj9h3dcf8aqjbxlws1bfvqbpfxv9d5phnrpz"))))))
777 (home-page "https://github.com/luvit/luv/")
778 (synopsis "Libuv bindings for Lua")
779 (description
780 "This library makes libuv available to Lua scripts.")
781 (license license:asl2.0)))
782
783 (define-public lua-luv
784 (make-lua-luv "lua-luv" lua))
785
786 (define-public lua5.1-luv
787 (make-lua-luv "lua5.1-luv" lua-5.1))
788
789 (define-public lua5.2-luv
790 (make-lua-luv "lua5.2-luv" lua-5.2))
791
792 ;; Lua 5.3 is not supported.
793 (define (make-lua-bitop name lua)
794 (package
795 (name name)
796 (version "1.0.2")
797 (source (origin
798 (method url-fetch)
799 (uri (string-append "http://bitop.luajit.org/download/"
800 "LuaBitOp-" version ".tar.gz"))
801 (sha256
802 (base32
803 "16fffbrgfcw40kskh2bn9q7m3gajffwd2f35rafynlnd7llwj1qj"))))
804 (build-system gnu-build-system)
805 (arguments
806 `(#:test-target "test"
807 #:make-flags
808 (list "INSTALL=install -pD"
809 (string-append "INSTALLPATH=printf "
810 (assoc-ref %outputs "out")
811 "/lib/lua/"
812 ,(version-major+minor (package-version lua))
813 "/bit/bit.so"))
814 #:phases
815 (modify-phases %standard-phases
816 (delete 'configure))))
817 (inputs `(("lua" ,lua)))
818 (home-page "https://bitop.luajit.org/index.html")
819 (synopsis "Bitwise operations on numbers for Lua")
820 (description
821 "Lua BitOp is a C extension module for Lua which adds bitwise operations
822 on numbers.")
823 (license license:expat)))
824
825 (define-public lua5.2-bitop
826 (make-lua-bitop "lua5.2-bitop" lua-5.2))
827
828 (define-public lua5.1-bitop
829 (make-lua-bitop "lua5.1-bitop" lua-5.1))
830
831 (define-public selene
832 (package
833 (name "selene")
834 (version "2017.08.25")
835 (source (origin
836 (method git-fetch)
837 (uri (git-reference
838 (url "https://github.com/jeremyong/Selene")
839 ;; The release is quite old.
840 (commit "ffe1ade2568d4cff5894552be8f43e63e379a4c9")))
841 (file-name "Selene")
842 (sha256
843 (base32
844 "1axrgv3rxxdsaf807lwvklfzicn6x6gpf35narllrnz9lg6hn508"))))
845 (build-system cmake-build-system)
846 (arguments
847 `(#:configure-flags
848 ;; lua pc file in CMakeLists.txt is lua5.3.pc
849 '("-DLUA_PC_CFG=lua;lua-5.3;lua-5.1")
850 #:test-target "all"
851 #:phases
852 ;; This is a header only library
853 (modify-phases %standard-phases
854 (delete 'build)
855 (replace 'install
856 (lambda* (#:key inputs outputs #:allow-other-keys)
857 (let* ((output (assoc-ref outputs "out"))
858 (source (assoc-ref inputs "source"))
859 (includedir (string-append output "/include")))
860 (copy-recursively
861 (string-append source "/include")
862 includedir))
863 #t))
864 ;; The path of test files are hard coded.
865 (replace 'check
866 (lambda* (#:key inputs outputs #:allow-other-keys)
867 (let* ((output (assoc-ref outputs "out"))
868 (source (assoc-ref inputs "source"))
869 (builddir (getcwd))
870 (testdir (string-append builddir "/test")))
871 (copy-recursively (string-append source "/test") testdir)
872 (invoke "make")
873 (mkdir-p "runner")
874 (copy-file "./test_runner" "./runner/test_runner")
875 (chdir "./runner")
876 (invoke "./test_runner")))))))
877 (native-inputs
878 `(("lua" ,lua)
879 ("pkg-config" ,pkg-config)))
880 (home-page "https://github.com/jeremyong/Selene")
881 (synopsis "Lua C++11 bindings")
882 (description
883 "Selene is a simple C++11 header-only library enabling seamless
884 interoperability between C++ and Lua programming language.")
885 (license license:zlib)))
886
887 (define-public lua-resty-core
888 (package
889 (name "lua-resty-core")
890 (version "0.1.18")
891 (source (origin
892 (method git-fetch)
893 (uri (git-reference
894 (url "https://github.com/openresty/lua-resty-core")
895 (commit (string-append "v" version))))
896 (file-name (git-file-name name version))
897 (sha256
898 (base32
899 "1c58hykwpg5zqbyhrcb703pzwbkih409v3bh2gady6z2kj9q32dw"))))
900 (build-system trivial-build-system)
901 (arguments
902 `(#:modules ((guix build utils))
903 #:builder
904 (begin
905 (use-modules (guix build utils))
906 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
907 (package-lua-resty (lambda (input output)
908 (mkdir-p (string-append output "/lib/lua"))
909 (copy-recursively (string-append input "/lib/resty")
910 (string-append output "/lib/lua/resty"))
911 (copy-recursively (string-append input "/lib/ngx")
912 (string-append output "/lib/ngx"))
913 (symlink (string-append output "/lib/lua/resty")
914 (string-append output "/lib/resty")))))
915 (package-lua-resty (assoc-ref %build-inputs "source")
916 (assoc-ref %outputs "out")))
917 #t)))
918 (home-page "https://github.com/openresty/lua-resty-core")
919 (synopsis "Lua API for NGINX")
920 (description "This package provides a FFI-based Lua API for
921 @code{ngx_http_lua_module} or @code{ngx_stream_lua_module}.")
922 (license license:bsd-2)))
923
924 (define-public lua-resty-lrucache
925 (package
926 (name "lua-resty-lrucache")
927 (version "0.10")
928 (source (origin
929 (method git-fetch)
930 (uri (git-reference
931 (url "https://github.com/openresty/lua-resty-lrucache")
932 (commit (string-append "v" version))))
933 (file-name (git-file-name name version))
934 (sha256
935 (base32
936 "1bsc54v1rvxmkwg7a2c01p192lvw5g576f589is8fy1m1c6v4ap8"))))
937 (build-system trivial-build-system)
938 (arguments
939 `(#:modules ((guix build utils))
940 #:builder
941 (begin
942 (use-modules (guix build utils))
943 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
944 (package-lua-resty (lambda (input output)
945 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
946 (copy-recursively (string-append input "/lib/resty")
947 (string-append output "/lib/lua/" luajit-major+minor "/resty"))
948 (symlink (string-append output "/lib/lua/" luajit-major+minor "/resty")
949 (string-append output "/lib/resty")))))
950 (package-lua-resty (assoc-ref %build-inputs "source")
951 (assoc-ref %outputs "out")))
952 #t)))
953 (home-page "https://github.com/openresty/lua-resty-lrucache")
954 (synopsis "Lua LRU cache based on the LuaJIT FFI")
955 (description
956 "This package provides Lua LRU cache based on the LuaJIT FFI.")
957 (license license:bsd-2)))
958
959 (define-public lua-resty-signal
960 (package
961 (name "lua-resty-signal")
962 (version "0.02")
963 (source (origin
964 (method git-fetch)
965 (uri (git-reference
966 (url "https://github.com/openresty/lua-resty-signal")
967 (commit (string-append "v" version))))
968 (file-name (git-file-name name version))
969 (sha256
970 (base32
971 "13y1pqn45y49mhqwywasfdsid46d0c33yi6mrnracbnmvyxz1cif"))))
972 (build-system gnu-build-system)
973 (arguments
974 `(#:tests? #f ;TODO: Run the test suite.
975 #:make-flags (list "CC=gcc"
976 (string-append "PREFIX=" %output))
977 #:phases
978 (modify-phases %standard-phases
979 (delete 'configure)
980 (add-after 'install 'install-lua
981 (lambda* (#:key inputs outputs #:allow-other-keys)
982 (use-modules (guix build utils))
983 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
984 (package-lua-resty (lambda (input output)
985 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
986 (copy-recursively (string-append input "/lib/resty")
987 (string-append output "/lib/lua/" luajit-major+minor "/resty"))
988 (symlink (string-append output "/lib/lua/" luajit-major+minor "/resty")
989 (string-append output "/lib/resty")))))
990 (package-lua-resty (assoc-ref inputs "source")
991 (assoc-ref outputs "out")))
992 #t)))))
993 (home-page "https://github.com/openresty/lua-resty-signal")
994 (synopsis "Lua library for killing or sending signals to Linux processes")
995 (description "This package provides Lua library for killing or sending
996 signals to Linux processes.")
997 (license license:bsd-3)))
998
999 (define-public lua-tablepool
1000 (package
1001 (name "lua-tablepool")
1002 (version "0.01")
1003 (source (origin
1004 (method git-fetch)
1005 (uri (git-reference
1006 (url "https://github.com/openresty/lua-tablepool")
1007 (commit (string-append "v" version))))
1008 (file-name (git-file-name name version))
1009 (sha256
1010 (base32
1011 "03yjj3w6znvj6843prg84m0lkrn49l901f9hj9bgy3cj9s0awl6y"))))
1012 (build-system trivial-build-system)
1013 (arguments
1014 `(#:modules ((guix build utils))
1015 #:builder
1016 (begin
1017 (use-modules (guix build utils))
1018 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1019 (package-lua-resty (lambda (input output)
1020 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1021 (copy-recursively (string-append input "/lib")
1022 (string-append output "/lib")))))
1023 (package-lua-resty (assoc-ref %build-inputs "source")
1024 (assoc-ref %outputs "out")))
1025 #t)))
1026 (home-page "https://github.com/openresty/lua-tablepool")
1027 (synopsis "Lua table recycling pools for LuaJIT")
1028 (description "This package provides Lua table recycling pools for LuaJIT.")
1029 (license license:bsd-2)))
1030
1031 (define-public lua-resty-shell
1032 (package
1033 (name "lua-resty-shell")
1034 (version "0.03")
1035 (source (origin
1036 (method git-fetch)
1037 (uri (git-reference
1038 (url "https://github.com/openresty/lua-resty-shell")
1039 (commit (string-append "v" version))))
1040 (file-name (git-file-name name version))
1041 (sha256
1042 (base32
1043 "1s6g04ip4hr97r2pd8ry3alq063604s9a3l0hn9nsidh81ps4dp7"))))
1044 (build-system trivial-build-system)
1045 (arguments
1046 `(#:modules ((guix build utils))
1047 #:builder
1048 (begin
1049 (use-modules (guix build utils))
1050 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1051 (package-lua-resty (lambda (input output)
1052 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1053 (copy-recursively (string-append input "/lib/resty")
1054 (string-append output "/lib/lua/" luajit-major+minor "/resty"))
1055 (symlink (string-append output "/lib/lua/" luajit-major+minor "/resty")
1056 (string-append output "/lib/resty")))))
1057 (package-lua-resty (assoc-ref %build-inputs "source")
1058 (assoc-ref %outputs "out")))
1059 #t)))
1060 (home-page "https://github.com/openresty/lua-resty-shell")
1061 (synopsis "Lua module for nonblocking system shell command executions")
1062 (description "This package provides Lua module for nonblocking system
1063 shell command executions.")
1064 (license license:bsd-3)))
1065
1066 (define-public fennel
1067 (package
1068 (name "fennel")
1069 (version "0.8.0")
1070 (source (origin
1071 (method git-fetch)
1072 (uri (git-reference
1073 (url "https://git.sr.ht/~technomancy/fennel")
1074 (commit version)))
1075 (file-name (git-file-name name version))
1076 (sha256
1077 (base32
1078 "1jng33vmnk6mi37l3x2z0plng940jpj7kz1s493ki80z3mkaxjfg"))
1079 (modules '((guix build utils)))
1080 (snippet
1081 '(begin
1082 (delete-file "fennelview.lua") #t))))
1083 (build-system gnu-build-system)
1084 (arguments
1085 '(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
1086 #:tests? #t ; even on cross-build
1087 #:test-target "test"
1088 #:phases
1089 (modify-phases %standard-phases
1090 (delete 'configure)
1091 (add-before 'build 'patch-lua-calls
1092 (lambda* (#:key inputs #:allow-other-keys)
1093 (let ((lua (string-append (assoc-ref inputs "lua") "/bin/lua")))
1094 (setenv "LUA" lua)
1095 (substitute* "old/launcher.lua"
1096 (("/usr/bin/env lua") lua))
1097 #t)))
1098 (add-after 'build 'patch-fennel
1099 (lambda* (#:key inputs #:allow-other-keys)
1100 (substitute* "fennel"
1101 (("/usr/bin/env .*lua")
1102 (string-append (assoc-ref inputs "lua") "/bin/lua")))
1103 #t))
1104 (delete 'check)
1105 (add-after 'install 'check
1106 (assoc-ref %standard-phases 'check))
1107 (add-after 'install 'install-manpage
1108 (lambda* (#:key outputs #:allow-other-keys)
1109 (install-file "fennel.1"
1110 (string-append (assoc-ref outputs "out")
1111 "/share/man/man1"))
1112 #t)))))
1113 (inputs `(("lua" ,lua)))
1114 (home-page "https://fennel-lang.org/")
1115 (synopsis "Lisp that compiles to Lua")
1116 (description
1117 "Fennel is a programming language that brings together the speed,
1118 simplicity, and reach of Lua with the flexibility of a Lisp syntax and macro
1119 system.")
1120 (license license:expat)))