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