gnu: luajit-lua52-openresty: Use a source file-name.
[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-public luajit-lua52-openresty
161 (package
162 (inherit luajit)
163 (name "luajit-lua52-openresty")
164 (version "2.1-20201229")
165 (source
166 (origin
167 (method git-fetch)
168 (uri (git-reference
169 (url "https://github.com/openresty/luajit2.git")
170 (commit (string-append "v" version))))
171 (file-name (git-file-name name version))
172 (sha256
173 (base32 "07haj27kbpbnkv836c2nd36h2xislrmri52w0zbpxvl68xk6g96p"))))
174 (arguments
175 `(#:tests? #f ;no test
176 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
177 #:phases
178 (modify-phases %standard-phases
179 (delete 'configure) ;no configure script
180 (add-after 'unpack 'enable-lua52-compat
181 (lambda _
182 (substitute* "src/Makefile"
183 (("#(XCFLAGS\\+= -DLUAJIT_ENABLE_LUA52COMPAT)" _ flag) flag))
184 #t)))))
185 (home-page "https://github.com/openresty/luajit2")
186 (synopsis "OpenResty's Branch of LuaJIT 2")
187 (description
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
191 some projects.")))
192
193 (define (make-lua-expat name lua)
194 (package
195 (name name)
196 (version "1.3.0")
197 (source (origin
198 (method url-fetch)
199 (uri (string-append "https://matthewwild.co.uk/projects/"
200 "luaexpat/luaexpat-" version ".tar.gz"))
201 (sha256
202 (base32
203 "1hvxqngn0wf5642i5p3vcyhg3pmp102k63s9ry4jqyyqc1wkjq6h"))))
204 (build-system gnu-build-system)
205 (arguments
206 `(#:make-flags
207 (let ((out (assoc-ref %outputs "out"))
208 (lua-version ,(version-major+minor (package-version lua))))
209 (list "CC=gcc"
210 (string-append "LUA_LDIR=" out "/share/lua/" lua-version)
211 (string-append "LUA_CDIR=" out "/lib/lua/" lua-version)))
212 #:phases
213 (modify-phases %standard-phases
214 (delete 'configure)
215 (replace 'check
216 (lambda _
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"))))))
221 (inputs
222 `(("lua" ,lua)
223 ("expat" ,expat)))
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))))
228
229 (define-public lua5.1-expat
230 (make-lua-expat "lua5.1-expat" lua-5.1))
231
232 (define-public lua5.2-expat
233 (make-lua-expat "lua5.2-expat" lua-5.2))
234
235 (define (make-lua-socket name lua)
236 (package
237 (name name)
238 (version "3.0-rc1")
239 (source (origin
240 (method git-fetch)
241 (uri (git-reference
242 (url "https://github.com/diegonehab/luasocket")
243 (commit (string-append "v" version))))
244 (file-name (git-file-name name version))
245 (sha256
246 (base32
247 "1chs7z7a3i3lck4x7rz60ziwbf793gw169hpjdfca8y4yf1hzsxk"))))
248 (build-system gnu-build-system)
249 (arguments
250 `(#:make-flags
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)))
255 #:phases
256 (modify-phases %standard-phases
257 (delete 'configure)
258 (replace 'check
259 (lambda _
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"))))))
265 (inputs
266 `(("lua" ,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.
273
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
280 handy.")
281 (license license:expat)))
282
283 (define-public lua5.1-socket
284 (make-lua-socket "lua5.1-socket" lua-5.1))
285
286 (define-public lua5.2-socket
287 (make-lua-socket "lua5.2-socket" lua-5.2))
288
289 (define (make-lua-filesystem name lua)
290 (package
291 (name name)
292 (version "1.7.0.2")
293 (source (origin
294 (method git-fetch)
295 (uri (git-reference
296 (url "https://github.com/keplerproject/luafilesystem")
297 (commit (string-append "v"
298 (string-join
299 (string-split version #\.) "_")))))
300 (file-name (git-file-name name version))
301 (sha256
302 (base32
303 "0zmprgkm9zawdf9wnw0v3w6ibaj442wlc6alp39hmw610fl4vghi"))))
304 (build-system gnu-build-system)
305 (arguments
306 `(#:make-flags
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)))
311 #:test-target "test"
312 #:phases
313 (modify-phases %standard-phases
314 (delete 'configure))))
315 (inputs
316 `(("lua" ,lua)))
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))))
324
325 (define-public lua-filesystem
326 (make-lua-filesystem "lua-filesystem" lua))
327
328 (define-public lua5.1-filesystem
329 (make-lua-filesystem "lua5.1-filesystem" lua-5.1))
330
331 (define-public lua5.2-filesystem
332 (make-lua-filesystem "lua5.2-filesystem" lua-5.2))
333
334 (define (make-lua-ossl name lua)
335 (package
336 (name name)
337 (version "20170903")
338 (source (origin
339 (method url-fetch)
340 (uri (string-append "https://25thandclement.com/~william/"
341 "projects/releases/luaossl-" version ".tgz"))
342 (sha256
343 (base32
344 "10392bvd0lzyibipblgiss09zlqh3a5zgqg1b9lgbybpqb9cv2k3"))))
345 (build-system gnu-build-system)
346 (arguments
347 `(#:make-flags
348 (let ((out (assoc-ref %outputs "out"))
349 (lua-api-version ,(version-major+minor (package-version lua))))
350 (list "CC=gcc"
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)))
354 #:phases
355 (modify-phases %standard-phases
356 (delete 'configure)
357 (delete 'check)
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))))
362 (setenv "LUA_CPATH"
363 (string-append out "/lib/lua/" lua-version "/?.so;;"))
364 (setenv "LUA_PATH"
365 (string-append out "/share/lua/" lua-version "/?.lua;;"))
366 (with-directory-excursion "regress"
367 (for-each (lambda (f)
368 (invoke "lua" f))
369 (find-files "." "^[0-9].*\\.lua$"))))
370 #t)))))
371 (inputs
372 `(("lua" ,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)))
382
383 (define-public lua-ossl
384 (make-lua-ossl "lua-ossl" lua))
385
386 (define-public lua5.1-ossl
387 (make-lua-ossl "lua5.1-ossl" lua-5.1))
388
389 (define-public lua5.2-ossl
390 (make-lua-ossl "lua5.2-ossl" lua-5.2))
391
392 (define (make-lua-sec name lua)
393 (package
394 (name name)
395 (version "0.9")
396 (source (origin
397 (method git-fetch)
398 (uri (git-reference
399 (url "https://github.com/brunoos/luasec")
400 (commit (string-append "v" version))))
401 (file-name (git-file-name name version))
402 (sha256
403 (base32
404 "0ssncgkggyr8i3z6zbvgrgsqj2q8676rnsikhpfwnk9n7sx4gwbl"))))
405 (build-system gnu-build-system)
406 (arguments
407 `(#:make-flags
408 (let ((out (assoc-ref %outputs "out"))
409 (lua-version ,(version-major+minor (package-version lua))))
410 (list "linux"
411 "CC=gcc"
412 "LD=gcc"
413 (string-append "LUAPATH=" out "/share/lua/" lua-version)
414 (string-append "LUACPATH=" out "/lib/lua/" lua-version)))
415 #:tests? #f ; no tests included
416 #:phases
417 (modify-phases %standard-phases
418 (delete 'configure))))
419 (inputs
420 `(("lua" ,lua)
421 ("openssl" ,openssl)))
422 (propagated-inputs
423 `(("lua-socket"
424 ,(make-lua-socket
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)))
433
434 (define-public lua5.1-sec
435 (make-lua-sec "lua5.1-sec" lua-5.1))
436
437 (define-public lua5.2-sec
438 (make-lua-sec "lua5.2-sec" lua-5.2))
439
440 (define (make-lua-cqueues name lua lua-ossl)
441 (package
442 (name name)
443 (version "20171014")
444 (source (origin
445 (method url-fetch)
446 (uri (string-append "https://25thandclement.com/~william/"
447 "projects/releases/cqueues-" version ".tgz"))
448 (sha256
449 (base32
450 "1dabhpn6r0hlln8vx9hxm34pfcm46qzgpb2apmziwg5z51fi4ksb"))))
451 (build-system gnu-build-system)
452 (arguments
453 `(#:modules ((guix build gnu-build-system)
454 (guix build utils)
455 (ice-9 string-fun))
456 #:make-flags
457 (let ((out (assoc-ref %outputs "out"))
458 (lua-api-version ,(version-major+minor (package-version lua))))
459 (list "CC=gcc"
460 (string-append "LUA_APIS=" lua-api-version)))
461 #:phases
462 (modify-phases %standard-phases
463 (delete 'configure)
464 (delete 'check)
465 (replace 'install
466 (lambda* (#:key make-flags outputs #:allow-other-keys)
467 (let ((out (assoc-ref outputs "out")))
468 (apply invoke "make" "install"
469 (append make-flags
470 (list (string-append "DESTDIR=" out)
471 "prefix="))))))
472 (add-after 'install 'check
473 (lambda* (#:key inputs outputs make-flags #:allow-other-keys)
474 (let*
475 ((lua-version ,(version-major+minor (package-version lua)))
476 (env-suffix (if (equal? lua-version "5.1")
477 ""
478 (string-append
479 "_"
480 (string-replace-substring lua-version "." "_"))))
481
482 (lua-ossl (assoc-ref inputs "lua-ossl"))
483 (out (assoc-ref outputs "out"))
484
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)
493 (string-append
494 (string-join (map lua-cpath (list out lua-ossl)) ";")
495 ";;"))
496 (setenv (string-append "LUA_PATH" env-suffix)
497 (string-append
498 (string-join (map lua-path (list out lua-ossl)) ";")
499 ";;"))
500
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")))
505 (append
506 ;; Regression tests that require network
507 ;; connectivity
508 '("22-client-dtls.lua"
509 "30-starttls-completion.lua"
510 "62-noname.lua"
511 "153-dns-resolvers.lua")
512
513 ;; Regression tests that require LuaJIT
514 '("44-resolvers-gc.lua"
515 "51-join-defunct-thread.lua")
516
517 ;; Regression tests that require Lua 5.3
518 (if (not (equal? lua-version "5.3"))
519 '("152-thread-integer-passing.lua")
520 '()))))
521
522 (apply invoke "make" "check" make-flags)))))))
523 (native-inputs
524 `(("m4" ,m4)))
525 (inputs
526 `(("lua" ,lua)
527 ("openssl" ,openssl)))
528 (propagated-inputs
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)))
536
537 (define-public lua-cqueues
538 (make-lua-cqueues "lua-cqueues" lua lua-ossl))
539
540 (define-public lua5.1-cqueues
541 (make-lua-cqueues "lua5.1-cqueues" lua-5.1 lua5.1-ossl))
542
543 (define-public lua5.2-cqueues
544 (make-lua-cqueues "lua5.2-cqueues" lua-5.2 lua5.2-ossl))
545
546 (define-public lua-penlight
547 (package
548 (name "lua-penlight")
549 (version "1.7.0")
550 (source
551 (origin
552 (method git-fetch)
553 (uri (git-reference
554 (url "https://github.com/Tieske/Penlight")
555 (commit version)))
556 (file-name (git-file-name name version))
557 (sha256
558 (base32 "0qc2d1riyr4b5a0gnsmdw2lz5pw65s4ac60hc34w3mmk9l6yg6nl"))))
559 (build-system trivial-build-system)
560 (inputs
561 `(("lua" ,lua)))
562 (propagated-inputs
563 `(("lua-filesystem" ,lua-filesystem)))
564 (arguments
565 `(#:modules ((guix build utils))
566 #:builder
567 (begin
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)))
576 #t)))
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)))
585
586 (define-public lua-ldoc
587 (package
588 (name "lua-ldoc")
589 (version "1.4.6")
590 (source
591 (origin
592 (method git-fetch)
593 (uri (git-reference
594 (url "https://github.com/stevedonovan/LDoc")
595 (commit version)))
596 (file-name (git-file-name name version))
597 (sha256
598 (base32 "1h0cf7bp4am54r0j8lhjs2l1c7q5vz74ba0jvw9qdbaqimls46g8"))))
599 (build-system gnu-build-system)
600 (inputs
601 `(("lua" ,lua)))
602 (propagated-inputs
603 `(("lua-penlight" ,lua-penlight)))
604 (arguments
605 `(#:tests? #f ;tests must run after installation.
606 #:phases
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"
613 (("LUA=.*") "#\n")
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"))))
620 #t))
621 (delete 'configure)
622 (add-before 'install 'create-bin-directory
623 (lambda* (#:key outputs #:allow-other-keys)
624 (mkdir-p (string-append (assoc-ref outputs "out") "/bin"))
625 #t)))))
626 (home-page "http://stevedonovan.github.io/ldoc/")
627 (synopsis "Lua documentation generator")
628 (description
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)))
634
635 (define (make-lua-lgi name lua)
636 (package
637 (name name)
638 (version "0.9.2")
639 (source
640 (origin
641 (method git-fetch)
642 (uri (git-reference
643 (url "https://github.com/pavouk/lgi")
644 (commit version)))
645 (file-name (git-file-name name version))
646 (sha256
647 (base32 "03rbydnj411xpjvwsyvhwy4plm96481d7jax544mvk7apd8sd5jj"))))
648 (build-system gnu-build-system)
649 (arguments
650 `(#:make-flags
651 (list "CC=gcc"
652 (string-append "PREFIX=" (assoc-ref %outputs "out")))
653 #:phases
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)
661 #t)))
662 (add-before 'build 'set-lua-version
663 (lambda _
664 ;; Lua version and therefore install directories are hardcoded.
665 (substitute* "./lgi/Makefile"
666 (("LUA_VERSION=5.1")
667 (format #f
668 "LUA_VERSION=~a"
669 ,(version-major+minor (package-version lua)))))
670 #t))
671 (add-before 'check 'skip-test-gtk
672 (lambda _
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',"))
682 #t))
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")
689 #t)))))
690 (native-inputs
691 `(("dbus" ,dbus) ;tests use 'dbus-run-session'
692 ("pkg-config" ,pkg-config)))
693 (inputs
694 `(("cairo" ,cairo)
695 ("glib" ,glib)
696 ("gobject-introspection" ,gobject-introspection)
697 ("gtk" ,gtk+-2)
698 ("libffi" ,libffi)
699 ("lua" ,lua)
700 ("pango" ,pango)
701 ("xorg-server" ,xorg-server)))
702 (home-page "https://github.com/pavouk/lgi/")
703 (synopsis "Lua bridge to GObject based libraries")
704 (description
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)))
709
710 (define-public lua-lgi
711 (make-lua-lgi "lua-lgi" lua))
712
713 (define-public lua5.1-lgi
714 (make-lua-lgi "lua5.1-lgi" lua-5.1))
715
716 (define-public lua5.2-lgi
717 (make-lua-lgi "lua5.2-lgi" lua-5.2))
718
719 (define (make-lua-lpeg name lua)
720 (package
721 (name name)
722 (version "1.0.2")
723 (source (origin
724 (method url-fetch)
725 (uri (string-append "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-"
726 version ".tar.gz"))
727 (sha256
728 (base32 "1zjzl7acvcdavmcg5l7wi12jd4rh95q9pl5aiww7hv0v0mv6bmj8"))))
729 (build-system gnu-build-system)
730 (arguments
731 `(#:phases
732 (modify-phases %standard-phases
733 (delete 'configure)
734 ;; `make install` isn't available, so we have to do it manually
735 (replace 'install
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))
743 #t))))
744 #:test-target "test"))
745 (inputs `(("lua" ,lua)))
746 (synopsis "Pattern-matching library for Lua")
747 (description
748 "LPeg is a pattern-matching library for Lua, based on Parsing Expression
749 Grammars (PEGs).")
750 (home-page "http://www.inf.puc-rio.br/~roberto/lpeg")
751 (license license:expat)))
752
753 (define-public lua-lpeg
754 (make-lua-lpeg "lua-lpeg" lua))
755
756 (define-public lua5.1-lpeg
757 (make-lua-lpeg "lua5.1-lpeg" lua-5.1))
758
759 (define-public lua5.2-lpeg
760 (make-lua-lpeg "lua5.2-lpeg" lua-5.2))
761
762 (define (make-lua-luv name lua)
763 (package
764 (name name)
765 (version "1.32.0-0")
766 (source (origin
767 ;; The release tarball includes the sources of libuv but does
768 ;; not include the pkg-config files.
769 (method git-fetch)
770 (uri (git-reference
771 (url "https://github.com/luvit/luv")
772 (commit version)))
773 (file-name (git-file-name name version))
774 (sha256
775 (base32
776 "0c65c1lhbl0axnyks3910gjs0z0hw7w6jvl07g8kbpnbvfl4qajh"))))
777 (build-system cmake-build-system)
778 (arguments
779 `(#:tests? #f ; there are none
780 #:configure-flags
781 '("-DWITH_LUA_ENGINE=Lua"
782 "-DWITH_SHARED_LIBUV=On"
783 "-DBUILD_MODULE=Off"
784 "-DBUILD_SHARED_LIBS=On"
785 "-DLUA_BUILD_TYPE=System")
786 #:phases
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")
791 "lua-compat")
792 (setenv "CPATH"
793 (string-append (getcwd) "/lua-compat:"
794 (or (getenv "CPATH") "")))
795 #t)))))
796 (inputs
797 `(("lua" ,lua)
798 ("libuv" ,libuv)))
799 (native-inputs
800 `(("lua-compat"
801 ,(origin
802 (method git-fetch)
803 (uri (git-reference
804 (url "https://github.com/keplerproject/lua-compat-5.3")
805 (commit "daebe77a2f498817713df37f0bb316db1d82222f")))
806 (file-name "lua-compat-5.3-checkout")
807 (sha256
808 (base32
809 "02a14nvn7aggg1yikj9h3dcf8aqjbxlws1bfvqbpfxv9d5phnrpz"))))))
810 (home-page "https://github.com/luvit/luv/")
811 (synopsis "Libuv bindings for Lua")
812 (description
813 "This library makes libuv available to Lua scripts.")
814 (license license:asl2.0)))
815
816 (define-public lua-luv
817 (make-lua-luv "lua-luv" lua))
818
819 (define-public lua5.1-luv
820 (make-lua-luv "lua5.1-luv" lua-5.1))
821
822 (define-public lua5.2-luv
823 (make-lua-luv "lua5.2-luv" lua-5.2))
824
825 ;; Lua 5.3 is not supported.
826 (define (make-lua-bitop name lua)
827 (package
828 (name name)
829 (version "1.0.2")
830 (source (origin
831 (method url-fetch)
832 (uri (string-append "http://bitop.luajit.org/download/"
833 "LuaBitOp-" version ".tar.gz"))
834 (sha256
835 (base32
836 "16fffbrgfcw40kskh2bn9q7m3gajffwd2f35rafynlnd7llwj1qj"))))
837 (build-system gnu-build-system)
838 (arguments
839 `(#:test-target "test"
840 #:make-flags
841 (list "INSTALL=install -pD"
842 (string-append "INSTALLPATH=printf "
843 (assoc-ref %outputs "out")
844 "/lib/lua/"
845 ,(version-major+minor (package-version lua))
846 "/bit/bit.so"))
847 #:phases
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")
853 (description
854 "Lua BitOp is a C extension module for Lua which adds bitwise operations
855 on numbers.")
856 (license license:expat)))
857
858 (define-public lua5.2-bitop
859 (make-lua-bitop "lua5.2-bitop" lua-5.2))
860
861 (define-public lua5.1-bitop
862 (make-lua-bitop "lua5.1-bitop" lua-5.1))
863
864 (define-public selene
865 (package
866 (name "selene")
867 (version "2017.08.25")
868 (source (origin
869 (method git-fetch)
870 (uri (git-reference
871 (url "https://github.com/jeremyong/Selene")
872 ;; The release is quite old.
873 (commit "ffe1ade2568d4cff5894552be8f43e63e379a4c9")))
874 (file-name "Selene")
875 (sha256
876 (base32
877 "1axrgv3rxxdsaf807lwvklfzicn6x6gpf35narllrnz9lg6hn508"))))
878 (build-system cmake-build-system)
879 (arguments
880 `(#:configure-flags
881 ;; lua pc file in CMakeLists.txt is lua5.3.pc
882 '("-DLUA_PC_CFG=lua;lua-5.3;lua-5.1")
883 #:test-target "all"
884 #:phases
885 ;; This is a header only library
886 (modify-phases %standard-phases
887 (delete 'build)
888 (replace 'install
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")))
893 (copy-recursively
894 (string-append source "/include")
895 includedir))
896 #t))
897 ;; The path of test files are hard coded.
898 (replace 'check
899 (lambda* (#:key inputs outputs #:allow-other-keys)
900 (let* ((output (assoc-ref outputs "out"))
901 (source (assoc-ref inputs "source"))
902 (builddir (getcwd))
903 (testdir (string-append builddir "/test")))
904 (copy-recursively (string-append source "/test") testdir)
905 (invoke "make")
906 (mkdir-p "runner")
907 (copy-file "./test_runner" "./runner/test_runner")
908 (chdir "./runner")
909 (invoke "./test_runner")))))))
910 (native-inputs
911 `(("lua" ,lua)
912 ("pkg-config" ,pkg-config)))
913 (home-page "https://github.com/jeremyong/Selene")
914 (synopsis "Lua C++11 bindings")
915 (description
916 "Selene is a simple C++11 header-only library enabling seamless
917 interoperability between C++ and Lua programming language.")
918 (license license:zlib)))
919
920 (define-public lua-resty-core
921 (package
922 (name "lua-resty-core")
923 (version "0.1.18")
924 (source (origin
925 (method git-fetch)
926 (uri (git-reference
927 (url "https://github.com/openresty/lua-resty-core")
928 (commit (string-append "v" version))))
929 (file-name (git-file-name name version))
930 (sha256
931 (base32
932 "1c58hykwpg5zqbyhrcb703pzwbkih409v3bh2gady6z2kj9q32dw"))))
933 (build-system trivial-build-system)
934 (arguments
935 `(#:modules ((guix build utils))
936 #:builder
937 (begin
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")))
950 #t)))
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)))
956
957 (define-public lua-resty-lrucache
958 (package
959 (name "lua-resty-lrucache")
960 (version "0.10")
961 (source (origin
962 (method git-fetch)
963 (uri (git-reference
964 (url "https://github.com/openresty/lua-resty-lrucache")
965 (commit (string-append "v" version))))
966 (file-name (git-file-name name version))
967 (sha256
968 (base32
969 "1bsc54v1rvxmkwg7a2c01p192lvw5g576f589is8fy1m1c6v4ap8"))))
970 (build-system trivial-build-system)
971 (arguments
972 `(#:modules ((guix build utils))
973 #:builder
974 (begin
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")))
985 #t)))
986 (home-page "https://github.com/openresty/lua-resty-lrucache")
987 (synopsis "Lua LRU cache based on the LuaJIT FFI")
988 (description
989 "This package provides Lua LRU cache based on the LuaJIT FFI.")
990 (license license:bsd-2)))
991
992 (define-public lua-resty-signal
993 (package
994 (name "lua-resty-signal")
995 (version "0.02")
996 (source (origin
997 (method git-fetch)
998 (uri (git-reference
999 (url "https://github.com/openresty/lua-resty-signal")
1000 (commit (string-append "v" version))))
1001 (file-name (git-file-name name version))
1002 (sha256
1003 (base32
1004 "13y1pqn45y49mhqwywasfdsid46d0c33yi6mrnracbnmvyxz1cif"))))
1005 (build-system gnu-build-system)
1006 (arguments
1007 `(#:tests? #f ;TODO: Run the test suite.
1008 #:make-flags (list "CC=gcc"
1009 (string-append "PREFIX=" %output))
1010 #:phases
1011 (modify-phases %standard-phases
1012 (delete 'configure)
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")))
1025 #t)))))
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)))
1031
1032 (define-public lua-tablepool
1033 (package
1034 (name "lua-tablepool")
1035 (version "0.01")
1036 (source (origin
1037 (method git-fetch)
1038 (uri (git-reference
1039 (url "https://github.com/openresty/lua-tablepool")
1040 (commit (string-append "v" version))))
1041 (file-name (git-file-name name version))
1042 (sha256
1043 (base32
1044 "03yjj3w6znvj6843prg84m0lkrn49l901f9hj9bgy3cj9s0awl6y"))))
1045 (build-system trivial-build-system)
1046 (arguments
1047 `(#:modules ((guix build utils))
1048 #:builder
1049 (begin
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")))
1058 #t)))
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)))
1063
1064 (define-public lua-resty-shell
1065 (package
1066 (name "lua-resty-shell")
1067 (version "0.03")
1068 (source (origin
1069 (method git-fetch)
1070 (uri (git-reference
1071 (url "https://github.com/openresty/lua-resty-shell")
1072 (commit (string-append "v" version))))
1073 (file-name (git-file-name name version))
1074 (sha256
1075 (base32
1076 "1s6g04ip4hr97r2pd8ry3alq063604s9a3l0hn9nsidh81ps4dp7"))))
1077 (build-system trivial-build-system)
1078 (arguments
1079 `(#:modules ((guix build utils))
1080 #:builder
1081 (begin
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")))
1092 #t)))
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)))
1098
1099 (define-public fennel
1100 (package
1101 (name "fennel")
1102 (version "0.8.0")
1103 (source (origin
1104 (method git-fetch)
1105 (uri (git-reference
1106 (url "https://git.sr.ht/~technomancy/fennel")
1107 (commit version)))
1108 (file-name (git-file-name name version))
1109 (sha256
1110 (base32
1111 "1jng33vmnk6mi37l3x2z0plng940jpj7kz1s493ki80z3mkaxjfg"))
1112 (modules '((guix build utils)))
1113 (snippet
1114 '(begin
1115 (delete-file "fennelview.lua") #t))))
1116 (build-system gnu-build-system)
1117 (arguments
1118 '(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
1119 #:tests? #t ; even on cross-build
1120 #:test-target "test"
1121 #:phases
1122 (modify-phases %standard-phases
1123 (delete 'configure)
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")))
1127 (setenv "LUA" lua)
1128 (substitute* "old/launcher.lua"
1129 (("/usr/bin/env lua") lua))
1130 #t)))
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")))
1136 #t))
1137 (delete 'check)
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")
1144 "/share/man/man1"))
1145 #t)))))
1146 (inputs `(("lua" ,lua)))
1147 (home-page "https://fennel-lang.org/")
1148 (synopsis "Lisp that compiles to Lua")
1149 (description
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
1152 system.")
1153 (license license:expat)))