gnu: r-fields: Update to 11.4.
[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 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 '("MYCFLAGS=-fPIC -DLUA_DL_DLOPEN"
73 "linux")
74 #:phases
75 (modify-phases %standard-phases
76 (delete 'configure)
77 (replace 'install
78 (lambda* (#:key outputs #:allow-other-keys)
79 (let ((out (assoc-ref outputs "out")))
80 (invoke "make" "install"
81 (string-append "INSTALL_TOP=" out)
82 (string-append "INSTALL_MAN=" out
83 "/share/man/man1"))))))))
84 (home-page "https://www.lua.org/")
85 (synopsis "Embeddable scripting language")
86 (description
87 "Lua is a powerful, fast, lightweight, embeddable scripting language. Lua
88 combines simple procedural syntax with powerful data description constructs
89 based on associative arrays and extensible semantics. Lua is dynamically typed,
90 runs by interpreting bytecode for a register-based virtual machine, and has
91 automatic memory management with incremental garbage collection, making it ideal
92 for configuration, scripting, and rapid prototyping.")
93 (license license:x11)))
94
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
108 (define-public lua-5.1
109 (package (inherit lua)
110 (version "5.1.5")
111 (source (origin
112 (method url-fetch)
113 (uri (string-append "https://www.lua.org/ftp/lua-"
114 version ".tar.gz"))
115 (sha256
116 (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))
117 (patches (search-patches "lua51-liblua-so.patch"
118 "lua-CVE-2014-5461.patch"
119 "lua51-pkgconfig.patch"))))))
120
121 (define-public luajit
122 (package
123 (name "luajit")
124 (version "2.1.0-beta3")
125 (source (origin
126 (method url-fetch)
127 (uri (string-append "http://luajit.org/download/LuaJIT-"
128 version ".tar.gz"))
129 (sha256
130 (base32 "1hyrhpkwjqsv54hnnx4cl8vk44h9d6c9w0fz1jfjz00w255y7lhs"))
131 (patches (search-patches "luajit-no_ldconfig.patch"))))
132 (build-system gnu-build-system)
133 (arguments
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")))))
147 (home-page "https://www.luajit.org/")
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
151 programming language. Lua is a powerful, dynamic and light-weight programming
152 language. It may be embedded or used as a general-purpose, stand-alone
153 language.")
154 (license license:x11)))
155
156 (define (make-lua-expat name lua)
157 (package
158 (name name)
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
170 (let ((out (assoc-ref %outputs "out"))
171 (lua-version ,(version-major+minor (package-version lua))))
172 (list "CC=gcc"
173 (string-append "LUA_LDIR=" out "/share/lua/" lua-version)
174 (string-append "LUA_CDIR=" out "/lib/lua/" lua-version)))
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;;")
182 (invoke "lua" "tests/test.lua")
183 (invoke "lua" "tests/test-lom.lua"))))))
184 (inputs
185 `(("lua" ,lua)
186 ("expat" ,expat)))
187 (home-page "https://matthewwild.co.uk/projects/luaexpat/")
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))))
191
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
198 (define (make-lua-socket name lua)
199 (package
200 (name name)
201 (version "3.0-rc1")
202 (source (origin
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))
208 (sha256
209 (base32
210 "1chs7z7a3i3lck4x7rz60ziwbf793gw169hpjdfca8y4yf1hzsxk"))))
211 (build-system gnu-build-system)
212 (arguments
213 `(#:make-flags
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)))
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))
226 (invoke "lua" "test/testsrvr.lua"))
227 (invoke "lua" "test/testclnt.lua"))))))
228 (inputs
229 `(("lua" ,lua)))
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
233 parts: a C core that provides support for the TCP and UDP transport layers,
234 and a set of Lua modules that add support for functionality commonly needed by
235 applications that deal with the Internet.
236
237 Among the supported modules, the most commonly used implement the
238 SMTP (sending e-mails), HTTP (WWW access) and FTP (uploading and downloading
239 files) client protocols. These provide a very natural and generic interface
240 to the functionality defined by each protocol. In addition, you will find
241 that the MIME (common encodings), URL (anything you could possible want to do
242 with one) and LTN12 (filters, sinks, sources and pumps) modules can be very
243 handy.")
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))
251
252 (define (make-lua-filesystem name lua)
253 (package
254 (name name)
255 (version "1.7.0.2")
256 (source (origin
257 (method git-fetch)
258 (uri (git-reference
259 (url "https://github.com/keplerproject/luafilesystem")
260 (commit (string-append "v"
261 (string-join
262 (string-split version #\.) "_")))))
263 (file-name (git-file-name name version))
264 (sha256
265 (base32
266 "0zmprgkm9zawdf9wnw0v3w6ibaj442wlc6alp39hmw610fl4vghi"))))
267 (build-system gnu-build-system)
268 (arguments
269 `(#:make-flags
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)))
274 #:test-target "test"
275 #:phases
276 (modify-phases %standard-phases
277 (delete 'configure))))
278 (inputs
279 `(("lua" ,lua)))
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
283 set of functions related to file systems offered by the standard Lua
284 distribution. LuaFileSystem offers a portable way to access the underlying
285 directory structure and file attributes.")
286 (license (package-license lua-5.1))))
287
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
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,
341 low-level bindings to the OpenSSL library, including support for certificate and
342 key management, key generation, signature verification, and deep bindings to the
343 distinguished name, alternative name, and X.509v3 extension interfaces. It also
344 binds 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
356 (define (make-lua-sec name lua)
357 (package
358 (name name)
359 (version "0.9")
360 (source (origin
361 (method git-fetch)
362 (uri (git-reference
363 (url "https://github.com/brunoos/luasec")
364 (commit (string-append "v" version))))
365 (file-name (git-file-name name version))
366 (sha256
367 (base32
368 "0ssncgkggyr8i3z6zbvgrgsqj2q8676rnsikhpfwnk9n7sx4gwbl"))))
369 (build-system gnu-build-system)
370 (arguments
371 `(#:make-flags
372 (let ((out (assoc-ref %outputs "out"))
373 (lua-version ,(version-major+minor (package-version lua))))
374 (list "linux"
375 "CC=gcc"
376 "LD=gcc"
377 (string-append "LUAPATH=" out "/share/lua/" lua-version)
378 (string-append "LUACPATH=" out "/lib/lua/" lua-version)))
379 #:tests? #f ; no tests included
380 #:phases
381 (modify-phases %standard-phases
382 (delete 'configure))))
383 (inputs
384 `(("lua" ,lua)
385 ("openssl" ,openssl)))
386 (propagated-inputs
387 `(("lua-socket"
388 ,(make-lua-socket
389 (format #f "lua~a-socket"
390 (version-major+minor (package-version lua))) lua))))
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
394 communication. It takes an already established TCP connection and creates a
395 secure session between the peers.")
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))
403
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
497 that operates through the yielding and resumption of coroutines. It is designed
498 to 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
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
518 (url "https://github.com/Tieske/Penlight")
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
544 input data handling (such as reading configuration files), functional
545 programming (such as map, reduce, placeholder expressions,etc), and OS
546 path management. Much of the functionality is inspired by the Python
547 standard libraries.")
548 (license license:expat)))
549
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
558 (url "https://github.com/stevedonovan/LDoc")
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
594 Lua source code. It parses the declaration and documentation comments
595 in a set of Lua source files and produces a set of XHTML pages
596 describing the commented declarations and functions.")
597 (license license:expat)))
598
599 (define (make-lua-lgi name lua)
600 (package
601 (name name)
602 (version "0.9.2")
603 (source
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"))))
612 (build-system gnu-build-system)
613 (arguments
614 `(#:make-flags
615 (list "CC=gcc"
616 (string-append "PREFIX=" (assoc-ref %outputs "out")))
617 #:phases
618 (modify-phases %standard-phases
619 (delete 'configure) ; no configure script
620 (add-before 'build 'set-env
621 (lambda* (#:key inputs #:allow-other-keys)
622 ;; We need to load cairo dynamically.
623 (let* ((cairo (string-append (assoc-ref inputs "cairo") "/lib")))
624 (setenv "LD_LIBRARY_PATH" cairo)
625 #t)))
626 (add-before 'build 'set-lua-version
627 (lambda _
628 ;; Lua version and therefore install directories are hardcoded.
629 (substitute* "./lgi/Makefile"
630 (("LUA_VERSION=5.1")
631 (format #f
632 "LUA_VERSION=~a"
633 ,(version-major+minor (package-version lua)))))
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)))))
654 (native-inputs
655 `(("dbus" ,dbus) ;tests use 'dbus-run-session'
656 ("pkg-config" ,pkg-config)))
657 (inputs
658 `(("cairo" ,cairo)
659 ("glib" ,glib)
660 ("gobject-introspection" ,gobject-introspection)
661 ("gtk" ,gtk+-2)
662 ("libffi" ,libffi)
663 ("lua" ,lua)
664 ("pango" ,pango)
665 ("xorg-server" ,xorg-server)))
666 (home-page "https://github.com/pavouk/lgi/")
667 (synopsis "Lua bridge to GObject based libraries")
668 (description
669 "LGI is gobject-introspection based dynamic Lua binding to GObject based
670 libraries. It allows using GObject-based libraries directly from Lua.
671 Notable examples are GTK+, GStreamer and Webkit.")
672 (license license:expat)))
673
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
683 (define (make-lua-lpeg name lua)
684 (package
685 (name name)
686 (version "1.0.2")
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
692 (base32 "1zjzl7acvcdavmcg5l7wi12jd4rh95q9pl5aiww7hv0v0mv6bmj8"))))
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"))
709 (inputs `(("lua" ,lua)))
710 (synopsis "Pattern-matching library for Lua")
711 (description
712 "LPeg is a pattern-matching library for Lua, based on Parsing Expression
713 Grammars (PEGs).")
714 (home-page "http://www.inf.puc-rio.br/~roberto/lpeg")
715 (license license:expat)))
716
717 (define-public lua-lpeg
718 (make-lua-lpeg "lua-lpeg" lua))
719
720 (define-public lua5.1-lpeg
721 (make-lua-lpeg "lua5.1-lpeg" lua-5.1))
722
723 (define-public lua5.2-lpeg
724 (make-lua-lpeg "lua5.2-lpeg" lua-5.2))
725
726 (define (make-lua-luv name lua)
727 (package
728 (name name)
729 (version "1.32.0-0")
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
735 (url "https://github.com/luvit/luv")
736 (commit version)))
737 (file-name (git-file-name name version))
738 (sha256
739 (base32
740 "0c65c1lhbl0axnyks3910gjs0z0hw7w6jvl07g8kbpnbvfl4qajh"))))
741 (build-system cmake-build-system)
742 (arguments
743 `(#:tests? #f ; there are none
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
768 (url "https://github.com/keplerproject/lua-compat-5.3")
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
789 ;; Lua 5.3 is not supported.
790 (define (make-lua-bitop name lua)
791 (package
792 (name name)
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/"
809 ,(version-major+minor (package-version lua))
810 "/bit/bit.so"))
811 #:phases
812 (modify-phases %standard-phases
813 (delete 'configure))))
814 (inputs `(("lua" ,lua)))
815 (home-page "https://bitop.luajit.org/index.html")
816 (synopsis "Bitwise operations on numbers for Lua")
817 (description
818 "Lua BitOp is a C extension module for Lua which adds bitwise operations
819 on numbers.")
820 (license license:expat)))
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))
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
835 (url "https://github.com/jeremyong/Selene")
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)))