gnu: Remove ".git" from "https://github/…/….git".
[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>
5327fbb3 11;;; Copyright © 2018, 2019 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
315 (string-append "DESTDIR=" out)
316 (string-append "LUA_APIS=" lua-api-version)
317 "prefix="))
318 #:phases
319 (modify-phases %standard-phases
320 (delete 'configure)
321 (delete 'check)
322 (add-after 'install 'check
323 (lambda* (#:key outputs #:allow-other-keys)
324 (let ((out (assoc-ref outputs "out"))
325 (lua-version ,(version-major+minor (package-version lua))))
326 (setenv "LUA_CPATH"
327 (string-append out "/lib/lua/" lua-version "/?.so;;"))
328 (setenv "LUA_PATH"
329 (string-append out "/share/lua/" lua-version "/?.lua;;"))
330 (with-directory-excursion "regress"
331 (for-each (lambda (f)
332 (invoke "lua" f))
333 (find-files "." "^[0-9].*\\.lua$"))))
334 #t)))))
335 (inputs
336 `(("lua" ,lua)
337 ("openssl" ,openssl)))
338 (home-page "https://25thandclement.com/~william/projects/luaossl.html")
339 (synopsis "OpenSSL bindings for Lua")
340 (description "The luaossl extension module for Lua provides comprehensive,
341low-level bindings to the OpenSSL library, including support for certificate and
342key management, key generation, signature verification, and deep bindings to the
343distinguished name, alternative name, and X.509v3 extension interfaces. It also
344binds OpenSSL's bignum, message digest, HMAC, cipher, and CSPRNG interfaces.")
345 (license license:expat)))
346
347(define-public lua-ossl
348 (make-lua-ossl "lua-ossl" lua))
349
350(define-public lua5.1-ossl
351 (make-lua-ossl "lua5.1-ossl" lua-5.1))
352
353(define-public lua5.2-ossl
354 (make-lua-ossl "lua5.2-ossl" lua-5.2))
355
eb5b6c57 356(define (make-lua-sec name lua)
d62dc2ae 357 (package
eb5b6c57 358 (name name)
6298f327 359 (version "0.9")
d62dc2ae 360 (source (origin
b63785ec
EF
361 (method git-fetch)
362 (uri (git-reference
363 (url "https://github.com/brunoos/luasec")
6298f327 364 (commit (string-append "v" version))))
b63785ec 365 (file-name (git-file-name name version))
d62dc2ae
RW
366 (sha256
367 (base32
6298f327 368 "0ssncgkggyr8i3z6zbvgrgsqj2q8676rnsikhpfwnk9n7sx4gwbl"))))
d62dc2ae
RW
369 (build-system gnu-build-system)
370 (arguments
371 `(#:make-flags
eb5b6c57
CL
372 (let ((out (assoc-ref %outputs "out"))
373 (lua-version ,(version-major+minor (package-version lua))))
d62dc2ae
RW
374 (list "linux"
375 "CC=gcc"
376 "LD=gcc"
eb5b6c57
CL
377 (string-append "LUAPATH=" out "/share/lua/" lua-version)
378 (string-append "LUACPATH=" out "/lib/lua/" lua-version)))
d62dc2ae
RW
379 #:tests? #f ; no tests included
380 #:phases
381 (modify-phases %standard-phases
382 (delete 'configure))))
383 (inputs
eb5b6c57 384 `(("lua" ,lua)
d62dc2ae
RW
385 ("openssl" ,openssl)))
386 (propagated-inputs
eb5b6c57
CL
387 `(("lua-socket"
388 ,(make-lua-socket
389 (format #f "lua~a-socket"
390 (version-major+minor (package-version lua))) lua))))
d62dc2ae
RW
391 (home-page "https://github.com/brunoos/luasec/wiki")
392 (synopsis "OpenSSL bindings for Lua")
393 (description "LuaSec is a binding for OpenSSL library to provide TLS/SSL
394communication. It takes an already established TCP connection and creates a
395secure session between the peers.")
eb5b6c57
CL
396 (license license:expat)))
397
398(define-public lua5.1-sec
399 (make-lua-sec "lua5.1-sec" lua-5.1))
400
401(define-public lua5.2-sec
402 (make-lua-sec "lua5.2-sec" lua-5.2))
03d8505f 403
7c54e226
SS
404(define (make-lua-cqueues name lua lua-ossl)
405 (package
406 (name name)
407 (version "20171014")
408 (source (origin
409 (method url-fetch)
410 (uri (string-append "https://25thandclement.com/~william/"
411 "projects/releases/cqueues-" version ".tgz"))
412 (sha256
413 (base32
414 "1dabhpn6r0hlln8vx9hxm34pfcm46qzgpb2apmziwg5z51fi4ksb"))))
415 (build-system gnu-build-system)
416 (arguments
417 `(#:modules ((guix build gnu-build-system)
418 (guix build utils)
419 (ice-9 string-fun))
420 #:make-flags
421 (let ((out (assoc-ref %outputs "out"))
422 (lua-api-version ,(version-major+minor (package-version lua))))
423 (list "CC=gcc"
424 (string-append "LUA_APIS=" lua-api-version)))
425 #:phases
426 (modify-phases %standard-phases
427 (delete 'configure)
428 (delete 'check)
429 (replace 'install
430 (lambda* (#:key make-flags outputs #:allow-other-keys)
431 (let ((out (assoc-ref outputs "out")))
432 (apply invoke "make" "install"
433 (append make-flags
434 (list (string-append "DESTDIR=" out)
435 "prefix="))))))
436 (add-after 'install 'check
437 (lambda* (#:key inputs outputs make-flags #:allow-other-keys)
438 (let*
439 ((lua-version ,(version-major+minor (package-version lua)))
440 (env-suffix (if (equal? lua-version "5.1")
441 ""
442 (string-append
443 "_"
444 (string-replace-substring lua-version "." "_"))))
445
446 (lua-ossl (assoc-ref inputs "lua-ossl"))
447 (out (assoc-ref outputs "out"))
448
449 (lua-cpath (lambda (p)
450 (string-append p "/lib/lua/" lua-version "/?.so")))
451 (lua-path (lambda (p)
452 (string-append p "/share/lua/" lua-version "/?.lua"))))
453 ;; The test suite sets Lua-version-specific search-path variables
454 ;; when available so we must do the same, as these take
455 ;; precedence over the generic "LUA_CPATH" and "LUA_PATH"
456 (setenv (string-append "LUA_CPATH" env-suffix)
457 (string-append
458 (string-join (map lua-cpath (list out lua-ossl)) ";")
459 ";;"))
460 (setenv (string-append "LUA_PATH" env-suffix)
461 (string-append
462 (string-join (map lua-path (list out lua-ossl)) ";")
463 ";;"))
464
465 ;; Skip regression tests we expect to fail
466 (with-directory-excursion "regress"
467 (for-each (lambda (f)
468 (rename-file f (string-append f ".skip")))
469 (append
470 ;; Regression tests that require network
471 ;; connectivity
472 '("22-client-dtls.lua"
473 "30-starttls-completion.lua"
474 "62-noname.lua"
475 "153-dns-resolvers.lua")
476
477 ;; Regression tests that require LuaJIT
478 '("44-resolvers-gc.lua"
479 "51-join-defunct-thread.lua")
480
481 ;; Regression tests that require Lua 5.3
482 (if (not (equal? lua-version "5.3"))
483 '("152-thread-integer-passing.lua")
484 '()))))
485
486 (apply invoke "make" "check" make-flags)))))))
487 (native-inputs
488 `(("m4" ,m4)))
489 (inputs
490 `(("lua" ,lua)
491 ("openssl" ,openssl)))
492 (propagated-inputs
493 `(("lua-ossl" ,lua-ossl)))
494 (home-page "https://25thandclement.com/~william/projects/cqueues.html")
495 (synopsis "Event loop for Lua using continuation queues")
496 (description "The cqueues extension module for Lua implements an event loop
497that operates through the yielding and resumption of coroutines. It is designed
498to be non-intrusive, composable, and embeddable within existing applications.")
499 (license license:expat)))
500
501(define-public lua-cqueues
502 (make-lua-cqueues "lua-cqueues" lua lua-ossl))
503
504(define-public lua5.1-cqueues
505 (make-lua-cqueues "lua5.1-cqueues" lua-5.1 lua5.1-ossl))
506
507(define-public lua5.2-cqueues
508 (make-lua-cqueues "lua5.2-cqueues" lua-5.2 lua5.2-ossl))
509
1fd4b99e
NG
510(define-public lua-penlight
511 (package
512 (name "lua-penlight")
513 (version "1.7.0")
514 (source
515 (origin
516 (method git-fetch)
517 (uri (git-reference
b0e7b699 518 (url "https://github.com/Tieske/Penlight")
1fd4b99e
NG
519 (commit version)))
520 (file-name (git-file-name name version))
521 (sha256
522 (base32 "0qc2d1riyr4b5a0gnsmdw2lz5pw65s4ac60hc34w3mmk9l6yg6nl"))))
523 (build-system trivial-build-system)
524 (inputs
525 `(("lua" ,lua)))
526 (propagated-inputs
527 `(("lua-filesystem" ,lua-filesystem)))
528 (arguments
529 `(#:modules ((guix build utils))
530 #:builder
531 (begin
532 (use-modules (guix build utils))
533 (let* ((source (assoc-ref %build-inputs "source"))
534 (lua-version ,(version-major+minor (package-version lua)))
535 (destination (string-append (assoc-ref %outputs "out")
536 "/share/lua/" lua-version)))
537 (mkdir-p destination)
538 (with-directory-excursion source
539 (copy-recursively "lua/" destination)))
540 #t)))
541 (home-page "http://tieske.github.io/Penlight/")
542 (synopsis "Collection of general purpose libraries for the Lua language")
543 (description "Penlight is a set of pure Lua libraries focusing on
544input data handling (such as reading configuration files), functional
545programming (such as map, reduce, placeholder expressions,etc), and OS
546path management. Much of the functionality is inspired by the Python
547standard libraries.")
548 (license license:expat)))
549
4898e06a
NG
550(define-public lua-ldoc
551 (package
552 (name "lua-ldoc")
553 (version "1.4.6")
554 (source
555 (origin
556 (method git-fetch)
557 (uri (git-reference
b0e7b699 558 (url "https://github.com/stevedonovan/LDoc")
4898e06a
NG
559 (commit version)))
560 (file-name (git-file-name name version))
561 (sha256
562 (base32 "1h0cf7bp4am54r0j8lhjs2l1c7q5vz74ba0jvw9qdbaqimls46g8"))))
563 (build-system gnu-build-system)
564 (inputs
565 `(("lua" ,lua)))
566 (propagated-inputs
567 `(("lua-penlight" ,lua-penlight)))
568 (arguments
569 `(#:tests? #f ;tests must run after installation.
570 #:phases
571 (modify-phases %standard-phases
572 (add-after 'unpack 'fix-installation-directory
573 (lambda* (#:key outputs #:allow-other-keys)
574 (let ((out (assoc-ref outputs "out"))
575 (lua-version ,(version-major+minor (package-version lua))))
576 (substitute* "makefile"
577 (("LUA=.*") "#\n")
578 (("(LUA_PREFIX=).*" _ prefix)
579 (string-append prefix out "\n"))
580 (("(LUA_BINDIR=).*" _ prefix)
581 (string-append prefix out "/bin\n"))
582 (("(LUA_SHAREDIR=).*" _ prefix)
583 (string-append prefix out "/share/lua/" lua-version "\n"))))
584 #t))
585 (delete 'configure)
586 (add-before 'install 'create-bin-directory
587 (lambda* (#:key outputs #:allow-other-keys)
588 (mkdir-p (string-append (assoc-ref outputs "out") "/bin"))
589 #t)))))
590 (home-page "http://stevedonovan.github.io/ldoc/")
591 (synopsis "Lua documentation generator")
592 (description
593 "LDoc is a LuaDoc-compatible documentation generation system for
594Lua source code. It parses the declaration and documentation comments
595in a set of Lua source files and produces a set of XHTML pages
596describing the commented declarations and functions.")
597 (license license:expat)))
598
1c58aa6f 599(define (make-lua-lgi name lua)
03d8505f 600 (package
1c58aa6f 601 (name name)
ad514303 602 (version "0.9.2")
03d8505f 603 (source
1c58aa6f
NG
604 (origin
605 (method git-fetch)
606 (uri (git-reference
607 (url "https://github.com/pavouk/lgi")
608 (commit version)))
609 (file-name (git-file-name name version))
610 (sha256
611 (base32 "03rbydnj411xpjvwsyvhwy4plm96481d7jax544mvk7apd8sd5jj"))))
03d8505f 612 (build-system gnu-build-system)
613 (arguments
1c58aa6f
NG
614 `(#:make-flags
615 (list "CC=gcc"
616 (string-append "PREFIX=" (assoc-ref %outputs "out")))
03d8505f 617 #:phases
618 (modify-phases %standard-phases
1c58aa6f 619 (delete 'configure) ; no configure script
03d8505f 620 (add-before 'build 'set-env
621 (lambda* (#:key inputs #:allow-other-keys)
1c58aa6f
NG
622 ;; We need to load cairo dynamically.
623 (let* ((cairo (string-append (assoc-ref inputs "cairo") "/lib")))
03d8505f 624 (setenv "LD_LIBRARY_PATH" cairo)
625 #t)))
626 (add-before 'build 'set-lua-version
627 (lambda _
1c58aa6f 628 ;; Lua version and therefore install directories are hardcoded.
03d8505f 629 (substitute* "./lgi/Makefile"
1c58aa6f
NG
630 (("LUA_VERSION=5.1")
631 (format #f
632 "LUA_VERSION=~a"
633 ,(version-major+minor (package-version lua)))))
03d8505f 634 #t))
635 (add-before 'check 'skip-test-gtk
636 (lambda _
637 ;; FIXME: Skip GTK tests:
638 ;; gtk3 - can't get it to run with the xorg-server config below
639 ;; and some non-gtk tests will also fail
640 ;; gtk2 - lots of functions aren't implemented
641 ;; We choose gtk2 as the lesser evil and simply skip the test.
642 ;; Currently, awesome is the only package that uses lua-lgi but
643 ;; it doesn't need or interact with GTK using lua-lgi.
644 (substitute* "./tests/test.lua"
645 (("'gtk.lua',") "-- 'gtk.lua',"))
646 #t))
647 (add-before 'check 'start-xserver-instance
648 (lambda* (#:key inputs #:allow-other-keys)
649 ;; There must be a running X server during tests.
650 (system (format #f "~a/bin/Xvfb :1 &"
651 (assoc-ref inputs "xorg-server")))
652 (setenv "DISPLAY" ":1")
653 #t)))))
1c58aa6f
NG
654 (native-inputs
655 `(("dbus" ,dbus) ;tests use 'dbus-run-session'
656 ("pkg-config" ,pkg-config)))
03d8505f 657 (inputs
1c58aa6f 658 `(("cairo" ,cairo)
03d8505f 659 ("glib" ,glib)
1c58aa6f 660 ("gobject-introspection" ,gobject-introspection)
c695fb76 661 ("gtk" ,gtk+-2)
03d8505f 662 ("libffi" ,libffi)
1c58aa6f
NG
663 ("lua" ,lua)
664 ("pango" ,pango)
c695fb76 665 ("xorg-server" ,xorg-server)))
03d8505f 666 (home-page "https://github.com/pavouk/lgi/")
667 (synopsis "Lua bridge to GObject based libraries")
668 (description
1c58aa6f
NG
669 "LGI is gobject-introspection based dynamic Lua binding to GObject based
670libraries. It allows using GObject-based libraries directly from Lua.
03d8505f 671Notable examples are GTK+, GStreamer and Webkit.")
672 (license license:expat)))
35cdc267 673
1c58aa6f
NG
674(define-public lua-lgi
675 (make-lua-lgi "lua-lgi" lua))
676
677(define-public lua5.1-lgi
678 (make-lua-lgi "lua5.1-lgi" lua-5.1))
679
680(define-public lua5.2-lgi
681 (make-lua-lgi "lua5.2-lgi" lua-5.2))
682
149b2c43 683(define (make-lua-lpeg name lua)
35cdc267 684 (package
149b2c43 685 (name name)
e3545ffc 686 (version "1.0.2")
35cdc267
JMSG
687 (source (origin
688 (method url-fetch)
689 (uri (string-append "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-"
690 version ".tar.gz"))
691 (sha256
e3545ffc 692 (base32 "1zjzl7acvcdavmcg5l7wi12jd4rh95q9pl5aiww7hv0v0mv6bmj8"))))
35cdc267
JMSG
693 (build-system gnu-build-system)
694 (arguments
695 `(#:phases
696 (modify-phases %standard-phases
697 (delete 'configure)
698 ;; `make install` isn't available, so we have to do it manually
699 (replace 'install
700 (lambda* (#:key outputs #:allow-other-keys)
701 (let ((out (assoc-ref outputs "out"))
702 (lua-version ,(version-major+minor (package-version lua))))
703 (install-file "lpeg.so"
704 (string-append out "/lib/lua/" lua-version))
705 (install-file "re.lua"
706 (string-append out "/share/lua/" lua-version))
707 #t))))
708 #:test-target "test"))
c695fb76 709 (inputs `(("lua" ,lua)))
35cdc267
JMSG
710 (synopsis "Pattern-matching library for Lua")
711 (description
712 "LPeg is a pattern-matching library for Lua, based on Parsing Expression
713Grammars (PEGs).")
714 (home-page "http://www.inf.puc-rio.br/~roberto/lpeg")
715 (license license:expat)))
cf9a788d 716
149b2c43
CL
717(define-public lua-lpeg
718 (make-lua-lpeg "lua-lpeg" lua))
719
01a0a0c4
H
720(define-public lua5.1-lpeg
721 (make-lua-lpeg "lua5.1-lpeg" lua-5.1))
722
d9ed1779 723(define-public lua5.2-lpeg
149b2c43 724 (make-lua-lpeg "lua5.2-lpeg" lua-5.2))
d9ed1779 725
9ad3d679
RW
726(define (make-lua-luv name lua)
727 (package
728 (name name)
251ce98c 729 (version "1.32.0-0")
9ad3d679
RW
730 (source (origin
731 ;; The release tarball includes the sources of libuv but does
732 ;; not include the pkg-config files.
733 (method git-fetch)
734 (uri (git-reference
b0e7b699 735 (url "https://github.com/luvit/luv")
9ad3d679
RW
736 (commit version)))
737 (file-name (git-file-name name version))
738 (sha256
739 (base32
251ce98c 740 "0c65c1lhbl0axnyks3910gjs0z0hw7w6jvl07g8kbpnbvfl4qajh"))))
9ad3d679
RW
741 (build-system cmake-build-system)
742 (arguments
5327fbb3 743 `(#:tests? #f ; there are none
9ad3d679
RW
744 #:configure-flags
745 '("-DWITH_LUA_ENGINE=Lua"
746 "-DWITH_SHARED_LIBUV=On"
747 "-DBUILD_MODULE=Off"
748 "-DBUILD_SHARED_LIBS=On"
749 "-DLUA_BUILD_TYPE=System")
750 #:phases
751 (modify-phases %standard-phases
752 (add-after 'unpack 'copy-lua-compat
753 (lambda* (#:key inputs #:allow-other-keys)
754 (copy-recursively (assoc-ref inputs "lua-compat")
755 "lua-compat")
756 (setenv "CPATH"
757 (string-append (getcwd) "/lua-compat:"
758 (or (getenv "CPATH") "")))
759 #t)))))
760 (inputs
761 `(("lua" ,lua)
762 ("libuv" ,libuv)))
763 (native-inputs
764 `(("lua-compat"
765 ,(origin
766 (method git-fetch)
767 (uri (git-reference
b0e7b699 768 (url "https://github.com/keplerproject/lua-compat-5.3")
9ad3d679
RW
769 (commit "daebe77a2f498817713df37f0bb316db1d82222f")))
770 (file-name "lua-compat-5.3-checkout")
771 (sha256
772 (base32
773 "02a14nvn7aggg1yikj9h3dcf8aqjbxlws1bfvqbpfxv9d5phnrpz"))))))
774 (home-page "https://github.com/luvit/luv/")
775 (synopsis "Libuv bindings for Lua")
776 (description
777 "This library makes libuv available to Lua scripts.")
778 (license license:asl2.0)))
779
780(define-public lua-luv
781 (make-lua-luv "lua-luv" lua))
782
783(define-public lua5.1-luv
784 (make-lua-luv "lua5.1-luv" lua-5.1))
785
786(define-public lua5.2-luv
787 (make-lua-luv "lua5.2-luv" lua-5.2))
788
cf9a788d 789;; Lua 5.3 is not supported.
cb31a524 790(define (make-lua-bitop name lua)
cf9a788d 791 (package
cb31a524 792 (name name)
cf9a788d
RW
793 (version "1.0.2")
794 (source (origin
795 (method url-fetch)
796 (uri (string-append "http://bitop.luajit.org/download/"
797 "LuaBitOp-" version ".tar.gz"))
798 (sha256
799 (base32
800 "16fffbrgfcw40kskh2bn9q7m3gajffwd2f35rafynlnd7llwj1qj"))))
801 (build-system gnu-build-system)
802 (arguments
803 `(#:test-target "test"
804 #:make-flags
805 (list "INSTALL=install -pD"
806 (string-append "INSTALLPATH=printf "
807 (assoc-ref %outputs "out")
808 "/lib/lua/"
cb31a524 809 ,(version-major+minor (package-version lua))
cf9a788d
RW
810 "/bit/bit.so"))
811 #:phases
812 (modify-phases %standard-phases
813 (delete 'configure))))
c695fb76 814 (inputs `(("lua" ,lua)))
0386cdd3 815 (home-page "https://bitop.luajit.org/index.html")
cf9a788d
RW
816 (synopsis "Bitwise operations on numbers for Lua")
817 (description
818 "Lua BitOp is a C extension module for Lua which adds bitwise operations
819on numbers.")
820 (license license:expat)))
cb31a524
CL
821
822(define-public lua5.2-bitop
823 (make-lua-bitop "lua5.2-bitop" lua-5.2))
824
825(define-public lua5.1-bitop
826 (make-lua-bitop "lua5.1-bitop" lua-5.1))
ce577655
FT
827
828(define-public selene
829 (package
830 (name "selene")
831 (version "2017.08.25")
832 (source (origin
833 (method git-fetch)
834 (uri (git-reference
b0e7b699 835 (url "https://github.com/jeremyong/Selene")
ce577655
FT
836 ;; The release is quite old.
837 (commit "ffe1ade2568d4cff5894552be8f43e63e379a4c9")))
838 (file-name "Selene")
839 (sha256
840 (base32
841 "1axrgv3rxxdsaf807lwvklfzicn6x6gpf35narllrnz9lg6hn508"))))
842 (build-system cmake-build-system)
843 (arguments
844 `(#:configure-flags
845 ;; lua pc file in CMakeLists.txt is lua5.3.pc
846 '("-DLUA_PC_CFG=lua;lua-5.3;lua-5.1")
847 #:test-target "all"
848 #:phases
849 ;; This is a header only library
850 (modify-phases %standard-phases
851 (delete 'build)
852 (replace 'install
853 (lambda* (#:key inputs outputs #:allow-other-keys)
854 (let* ((output (assoc-ref outputs "out"))
855 (source (assoc-ref inputs "source"))
856 (includedir (string-append output "/include")))
857 (copy-recursively
858 (string-append source "/include")
859 includedir))
860 #t))
861 ;; The path of test files are hard coded.
862 (replace 'check
863 (lambda* (#:key inputs outputs #:allow-other-keys)
864 (let* ((output (assoc-ref outputs "out"))
865 (source (assoc-ref inputs "source"))
866 (builddir (getcwd))
867 (testdir (string-append builddir "/test")))
868 (copy-recursively (string-append source "/test") testdir)
869 (invoke "make")
870 (mkdir-p "runner")
871 (copy-file "./test_runner" "./runner/test_runner")
872 (chdir "./runner")
873 (invoke "./test_runner")))))))
874 (native-inputs
875 `(("lua" ,lua)
876 ("pkg-config" ,pkg-config)))
877 (home-page "https://github.com/jeremyong/Selene")
878 (synopsis "Lua C++11 bindings")
879 (description
880 "Selene is a simple C++11 header-only library enabling seamless
881 interoperability between C++ and Lua programming language.")
882 (license license:zlib)))