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