gnu: Add lua-ldoc.
[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 ;;;
15 ;;; This file is part of GNU Guix.
16 ;;;
17 ;;; GNU Guix is free software; you can redistribute it and/or modify it
18 ;;; under the terms of the GNU General Public License as published by
19 ;;; the Free Software Foundation; either version 3 of the License, or (at
20 ;;; your option) any later version.
21 ;;;
22 ;;; GNU Guix is distributed in the hope that it will be useful, but
23 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
24 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 ;;; GNU General Public License for more details.
26 ;;;
27 ;;; You should have received a copy of the GNU General Public License
28 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
29
30 (define-module (gnu packages lua)
31 #:use-module ((guix licenses) #:prefix license:)
32 #:use-module (guix packages)
33 #:use-module (guix download)
34 #:use-module (guix git-download)
35 #:use-module (guix utils)
36 #:use-module (guix build-system gnu)
37 #:use-module (guix build-system cmake)
38 #:use-module (guix build-system trivial)
39 #:use-module (gnu packages)
40 #:use-module (gnu packages readline)
41 #:use-module (gnu packages tls)
42 #:use-module (gnu packages xml)
43 #:use-module (gnu packages glib)
44 #:use-module (gnu packages libevent)
45 #:use-module (gnu packages libffi)
46 #:use-module (gnu packages pkg-config)
47 #:use-module (gnu packages xorg)
48 #:use-module (gnu packages gtk))
49
50 (define-public lua
51 (package
52 (name "lua")
53 (version "5.3.5")
54 (source (origin
55 (method url-fetch)
56 (uri (string-append "https://www.lua.org/ftp/lua-"
57 version ".tar.gz"))
58 (sha256
59 (base32 "1b2qn2rv96nmbm6zab4l877bd4zq7wpwm8drwjiy2ih4jqzysbhc"))
60 (patches (search-patches "lua-pkgconfig.patch"
61 "lua-liblua-so.patch"))))
62 (build-system gnu-build-system)
63 (inputs `(("readline" ,readline)))
64 (arguments
65 '(#:modules ((guix build gnu-build-system)
66 (guix build utils)
67 (srfi srfi-1))
68 #:test-target "test"
69 #:make-flags
70 '("MYCFLAGS=-fPIC -DLUA_DL_DLOPEN"
71 "linux")
72 #:phases
73 (modify-phases %standard-phases
74 (delete 'configure)
75 (replace 'install
76 (lambda* (#:key outputs #:allow-other-keys)
77 (let ((out (assoc-ref outputs "out")))
78 (invoke "make" "install"
79 (string-append "INSTALL_TOP=" out)
80 (string-append "INSTALL_MAN=" out
81 "/share/man/man1"))))))))
82 (home-page "https://www.lua.org/")
83 (synopsis "Embeddable scripting language")
84 (description
85 "Lua is a powerful, fast, lightweight, embeddable scripting language. Lua
86 combines simple procedural syntax with powerful data description constructs
87 based on associative arrays and extensible semantics. Lua is dynamically typed,
88 runs by interpreting bytecode for a register-based virtual machine, and has
89 automatic memory management with incremental garbage collection, making it ideal
90 for configuration, scripting, and rapid prototyping.")
91 (license license:x11)))
92
93 (define-public lua-5.2
94 (package (inherit lua)
95 (version "5.2.4")
96 (source
97 (origin
98 (method url-fetch)
99 (uri (string-append "https://www.lua.org/ftp/lua-"
100 version ".tar.gz"))
101 (sha256
102 (base32 "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr"))
103 (patches (search-patches "lua-pkgconfig.patch"
104 "lua-liblua-so.patch"))))))
105
106 (define-public lua-5.1
107 (package (inherit lua)
108 (version "5.1.5")
109 (source (origin
110 (method url-fetch)
111 (uri (string-append "https://www.lua.org/ftp/lua-"
112 version ".tar.gz"))
113 (sha256
114 (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))
115 (patches (search-patches "lua51-liblua-so.patch"
116 "lua-CVE-2014-5461.patch"
117 "lua51-pkgconfig.patch"))))))
118
119 (define-public luajit
120 (package
121 (name "luajit")
122 (version "2.1.0-beta3")
123 (source (origin
124 (method url-fetch)
125 (uri (string-append "http://luajit.org/download/LuaJIT-"
126 version ".tar.gz"))
127 (sha256
128 (base32 "1hyrhpkwjqsv54hnnx4cl8vk44h9d6c9w0fz1jfjz00w255y7lhs"))
129 (patches (search-patches "luajit-no_ldconfig.patch"))))
130 (build-system gnu-build-system)
131 (arguments
132 `(#:tests? #f ; luajit is distributed without tests
133 #:phases
134 (modify-phases %standard-phases
135 (delete 'configure) ; no configure script
136 (add-after 'install 'create-luajit-symlink
137 (lambda* (#:key outputs #:allow-other-keys)
138 (let* ((out (assoc-ref outputs "out"))
139 (bin (string-append out "/bin")))
140 (with-directory-excursion bin
141 (symlink ,(string-append name "-" version)
142 ,name)
143 #t)))))
144 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))))
145 (home-page "https://www.luajit.org/")
146 (synopsis "Just in time compiler for Lua programming language version 5.1")
147 (description
148 "LuaJIT is a Just-In-Time Compiler (JIT) for the Lua
149 programming language. Lua is a powerful, dynamic and light-weight programming
150 language. It may be embedded or used as a general-purpose, stand-alone
151 language.")
152 (license license:x11)))
153
154 (define (make-lua-expat name lua)
155 (package
156 (name name)
157 (version "1.3.0")
158 (source (origin
159 (method url-fetch)
160 (uri (string-append "https://matthewwild.co.uk/projects/"
161 "luaexpat/luaexpat-" version ".tar.gz"))
162 (sha256
163 (base32
164 "1hvxqngn0wf5642i5p3vcyhg3pmp102k63s9ry4jqyyqc1wkjq6h"))))
165 (build-system gnu-build-system)
166 (arguments
167 `(#:make-flags
168 (let ((out (assoc-ref %outputs "out"))
169 (lua-version ,(version-major+minor (package-version lua))))
170 (list "CC=gcc"
171 (string-append "LUA_LDIR=" out "/share/lua/" lua-version)
172 (string-append "LUA_CDIR=" out "/lib/lua/" lua-version)))
173 #:phases
174 (modify-phases %standard-phases
175 (delete 'configure)
176 (replace 'check
177 (lambda _
178 (setenv "LUA_CPATH" "src/?.so;;")
179 (setenv "LUA_PATH" "src/?.lua;;")
180 (invoke "lua" "tests/test.lua")
181 (invoke "lua" "tests/test-lom.lua"))))))
182 (inputs
183 `(("lua" ,lua)
184 ("expat" ,expat)))
185 (home-page "http://matthewwild.co.uk/projects/luaexpat/")
186 (synopsis "SAX XML parser based on the Expat library")
187 (description "LuaExpat is a SAX XML parser based on the Expat library.")
188 (license (package-license lua-5.1))))
189
190 (define-public lua5.1-expat
191 (make-lua-expat "lua5.1-expat" lua-5.1))
192
193 (define-public lua5.2-expat
194 (make-lua-expat "lua5.2-expat" lua-5.2))
195
196 (define (make-lua-socket name lua)
197 (package
198 (name name)
199 (version "3.0-rc1")
200 (source (origin
201 (method git-fetch)
202 (uri (git-reference
203 (url "https://github.com/diegonehab/luasocket")
204 (commit (string-append "v" version))))
205 (file-name (git-file-name name version))
206 (sha256
207 (base32
208 "1chs7z7a3i3lck4x7rz60ziwbf793gw169hpjdfca8y4yf1hzsxk"))))
209 (build-system gnu-build-system)
210 (arguments
211 `(#:make-flags
212 (let ((out (assoc-ref %outputs "out"))
213 (lua-version ,(version-major+minor (package-version lua))))
214 (list (string-append "INSTALL_TOP=" out)
215 (string-append "LUAV?=" lua-version)))
216 #:phases
217 (modify-phases %standard-phases
218 (delete 'configure)
219 (replace 'check
220 (lambda _
221 (setenv "LUA_CPATH" (string-append "src/?.so." ,version ";;"))
222 (setenv "LUA_PATH" "src/?.lua;;")
223 (when (zero? (primitive-fork))
224 (invoke "lua" "test/testsrvr.lua"))
225 (invoke "lua" "test/testclnt.lua"))))))
226 (inputs
227 `(("lua" ,lua)))
228 (home-page "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/")
229 (synopsis "Socket library for Lua")
230 (description "LuaSocket is a Lua extension library that is composed by two
231 parts: a C core that provides support for the TCP and UDP transport layers,
232 and a set of Lua modules that add support for functionality commonly needed by
233 applications that deal with the Internet.
234
235 Among the supported modules, the most commonly used implement the
236 SMTP (sending e-mails), HTTP (WWW access) and FTP (uploading and downloading
237 files) client protocols. These provide a very natural and generic interface
238 to the functionality defined by each protocol. In addition, you will find
239 that the MIME (common encodings), URL (anything you could possible want to do
240 with one) and LTN12 (filters, sinks, sources and pumps) modules can be very
241 handy.")
242 (license license:expat)))
243
244 (define-public lua5.1-socket
245 (make-lua-socket "lua5.1-socket" lua-5.1))
246
247 (define-public lua5.2-socket
248 (make-lua-socket "lua5.2-socket" lua-5.2))
249
250 (define (make-lua-filesystem name lua)
251 (package
252 (name name)
253 (version "1.7.0.2")
254 (source (origin
255 (method git-fetch)
256 (uri (git-reference
257 (url "https://github.com/keplerproject/luafilesystem")
258 (commit (string-append "v"
259 (string-join
260 (string-split version #\.) "_")))))
261 (file-name (git-file-name name version))
262 (sha256
263 (base32
264 "0zmprgkm9zawdf9wnw0v3w6ibaj442wlc6alp39hmw610fl4vghi"))))
265 (build-system gnu-build-system)
266 (arguments
267 `(#:make-flags
268 (let ((out (assoc-ref %outputs "out"))
269 (lua-version ,(version-major+minor (package-version lua))))
270 (list (string-append "PREFIX=" out)
271 (string-append "LUA_LIBDIR=" out "/lib/lua/" lua-version)))
272 #:test-target "test"
273 #:phases
274 (modify-phases %standard-phases
275 (delete 'configure))))
276 (inputs
277 `(("lua" ,lua)))
278 (home-page "https://keplerproject.github.io/luafilesystem/index.html")
279 (synopsis "File system library for Lua")
280 (description "LuaFileSystem is a Lua library developed to complement the
281 set of functions related to file systems offered by the standard Lua
282 distribution. LuaFileSystem offers a portable way to access the underlying
283 directory structure and file attributes.")
284 (license (package-license lua-5.1))))
285
286 (define-public lua-filesystem
287 (make-lua-filesystem "lua-filesystem" lua))
288
289 (define-public lua5.1-filesystem
290 (make-lua-filesystem "lua5.1-filesystem" lua-5.1))
291
292 (define-public lua5.2-filesystem
293 (make-lua-filesystem "lua5.2-filesystem" lua-5.2))
294
295 (define (make-lua-sec name lua)
296 (package
297 (name name)
298 (version "0.9")
299 (source (origin
300 (method git-fetch)
301 (uri (git-reference
302 (url "https://github.com/brunoos/luasec")
303 (commit (string-append "v" version))))
304 (file-name (git-file-name name version))
305 (sha256
306 (base32
307 "0ssncgkggyr8i3z6zbvgrgsqj2q8676rnsikhpfwnk9n7sx4gwbl"))))
308 (build-system gnu-build-system)
309 (arguments
310 `(#:make-flags
311 (let ((out (assoc-ref %outputs "out"))
312 (lua-version ,(version-major+minor (package-version lua))))
313 (list "linux"
314 "CC=gcc"
315 "LD=gcc"
316 (string-append "LUAPATH=" out "/share/lua/" lua-version)
317 (string-append "LUACPATH=" out "/lib/lua/" lua-version)))
318 #:tests? #f ; no tests included
319 #:phases
320 (modify-phases %standard-phases
321 (delete 'configure))))
322 (inputs
323 `(("lua" ,lua)
324 ("openssl" ,openssl)))
325 (propagated-inputs
326 `(("lua-socket"
327 ,(make-lua-socket
328 (format #f "lua~a-socket"
329 (version-major+minor (package-version lua))) lua))))
330 (home-page "https://github.com/brunoos/luasec/wiki")
331 (synopsis "OpenSSL bindings for Lua")
332 (description "LuaSec is a binding for OpenSSL library to provide TLS/SSL
333 communication. It takes an already established TCP connection and creates a
334 secure session between the peers.")
335 (license license:expat)))
336
337 (define-public lua5.1-sec
338 (make-lua-sec "lua5.1-sec" lua-5.1))
339
340 (define-public lua5.2-sec
341 (make-lua-sec "lua5.2-sec" lua-5.2))
342
343 (define-public lua-penlight
344 (package
345 (name "lua-penlight")
346 (version "1.7.0")
347 (source
348 (origin
349 (method git-fetch)
350 (uri (git-reference
351 (url "https://github.com/Tieske/Penlight.git")
352 (commit version)))
353 (file-name (git-file-name name version))
354 (sha256
355 (base32 "0qc2d1riyr4b5a0gnsmdw2lz5pw65s4ac60hc34w3mmk9l6yg6nl"))))
356 (build-system trivial-build-system)
357 (inputs
358 `(("lua" ,lua)))
359 (propagated-inputs
360 `(("lua-filesystem" ,lua-filesystem)))
361 (arguments
362 `(#:modules ((guix build utils))
363 #:builder
364 (begin
365 (use-modules (guix build utils))
366 (let* ((source (assoc-ref %build-inputs "source"))
367 (lua-version ,(version-major+minor (package-version lua)))
368 (destination (string-append (assoc-ref %outputs "out")
369 "/share/lua/" lua-version)))
370 (mkdir-p destination)
371 (with-directory-excursion source
372 (copy-recursively "lua/" destination)))
373 #t)))
374 (home-page "http://tieske.github.io/Penlight/")
375 (synopsis "Collection of general purpose libraries for the Lua language")
376 (description "Penlight is a set of pure Lua libraries focusing on
377 input data handling (such as reading configuration files), functional
378 programming (such as map, reduce, placeholder expressions,etc), and OS
379 path management. Much of the functionality is inspired by the Python
380 standard libraries.")
381 (license license:expat)))
382
383 (define-public lua-ldoc
384 (package
385 (name "lua-ldoc")
386 (version "1.4.6")
387 (source
388 (origin
389 (method git-fetch)
390 (uri (git-reference
391 (url "https://github.com/stevedonovan/LDoc.git")
392 (commit version)))
393 (file-name (git-file-name name version))
394 (sha256
395 (base32 "1h0cf7bp4am54r0j8lhjs2l1c7q5vz74ba0jvw9qdbaqimls46g8"))))
396 (build-system gnu-build-system)
397 (inputs
398 `(("lua" ,lua)))
399 (propagated-inputs
400 `(("lua-penlight" ,lua-penlight)))
401 (arguments
402 `(#:tests? #f ;tests must run after installation.
403 #:phases
404 (modify-phases %standard-phases
405 (add-after 'unpack 'fix-installation-directory
406 (lambda* (#:key outputs #:allow-other-keys)
407 (let ((out (assoc-ref outputs "out"))
408 (lua-version ,(version-major+minor (package-version lua))))
409 (substitute* "makefile"
410 (("LUA=.*") "#\n")
411 (("(LUA_PREFIX=).*" _ prefix)
412 (string-append prefix out "\n"))
413 (("(LUA_BINDIR=).*" _ prefix)
414 (string-append prefix out "/bin\n"))
415 (("(LUA_SHAREDIR=).*" _ prefix)
416 (string-append prefix out "/share/lua/" lua-version "\n"))))
417 #t))
418 (delete 'configure)
419 (add-before 'install 'create-bin-directory
420 (lambda* (#:key outputs #:allow-other-keys)
421 (mkdir-p (string-append (assoc-ref outputs "out") "/bin"))
422 #t)))))
423 (home-page "http://stevedonovan.github.io/ldoc/")
424 (synopsis "Lua documentation generator")
425 (description
426 "LDoc is a LuaDoc-compatible documentation generation system for
427 Lua source code. It parses the declaration and documentation comments
428 in a set of Lua source files and produces a set of XHTML pages
429 describing the commented declarations and functions.")
430 (license license:expat)))
431
432 (define (make-lua-lgi name lua)
433 (package
434 (name name)
435 (version "0.9.2")
436 (source
437 (origin
438 (method git-fetch)
439 (uri (git-reference
440 (url "https://github.com/pavouk/lgi")
441 (commit version)))
442 (file-name (git-file-name name version))
443 (sha256
444 (base32 "03rbydnj411xpjvwsyvhwy4plm96481d7jax544mvk7apd8sd5jj"))))
445 (build-system gnu-build-system)
446 (arguments
447 `(#:make-flags
448 (list "CC=gcc"
449 (string-append "PREFIX=" (assoc-ref %outputs "out")))
450 #:phases
451 (modify-phases %standard-phases
452 (delete 'configure) ; no configure script
453 (add-before 'build 'set-env
454 (lambda* (#:key inputs #:allow-other-keys)
455 ;; We need to load cairo dynamically.
456 (let* ((cairo (string-append (assoc-ref inputs "cairo") "/lib")))
457 (setenv "LD_LIBRARY_PATH" cairo)
458 #t)))
459 (add-before 'build 'set-lua-version
460 (lambda _
461 ;; Lua version and therefore install directories are hardcoded.
462 (substitute* "./lgi/Makefile"
463 (("LUA_VERSION=5.1")
464 (format #f
465 "LUA_VERSION=~a"
466 ,(version-major+minor (package-version lua)))))
467 #t))
468 (add-before 'check 'skip-test-gtk
469 (lambda _
470 ;; FIXME: Skip GTK tests:
471 ;; gtk3 - can't get it to run with the xorg-server config below
472 ;; and some non-gtk tests will also fail
473 ;; gtk2 - lots of functions aren't implemented
474 ;; We choose gtk2 as the lesser evil and simply skip the test.
475 ;; Currently, awesome is the only package that uses lua-lgi but
476 ;; it doesn't need or interact with GTK using lua-lgi.
477 (substitute* "./tests/test.lua"
478 (("'gtk.lua',") "-- 'gtk.lua',"))
479 #t))
480 (add-before 'check 'start-xserver-instance
481 (lambda* (#:key inputs #:allow-other-keys)
482 ;; There must be a running X server during tests.
483 (system (format #f "~a/bin/Xvfb :1 &"
484 (assoc-ref inputs "xorg-server")))
485 (setenv "DISPLAY" ":1")
486 #t)))))
487 (native-inputs
488 `(("dbus" ,dbus) ;tests use 'dbus-run-session'
489 ("pkg-config" ,pkg-config)))
490 (inputs
491 `(("cairo" ,cairo)
492 ("glib" ,glib)
493 ("gobject-introspection" ,gobject-introspection)
494 ("gtk" ,gtk+-2)
495 ("libffi" ,libffi)
496 ("lua" ,lua)
497 ("pango" ,pango)
498 ("xorg-server" ,xorg-server)))
499 (home-page "https://github.com/pavouk/lgi/")
500 (synopsis "Lua bridge to GObject based libraries")
501 (description
502 "LGI is gobject-introspection based dynamic Lua binding to GObject based
503 libraries. It allows using GObject-based libraries directly from Lua.
504 Notable examples are GTK+, GStreamer and Webkit.")
505 (license license:expat)))
506
507 (define-public lua-lgi
508 (make-lua-lgi "lua-lgi" lua))
509
510 (define-public lua5.1-lgi
511 (make-lua-lgi "lua5.1-lgi" lua-5.1))
512
513 (define-public lua5.2-lgi
514 (make-lua-lgi "lua5.2-lgi" lua-5.2))
515
516 (define (make-lua-lpeg name lua)
517 (package
518 (name name)
519 (version "1.0.2")
520 (source (origin
521 (method url-fetch)
522 (uri (string-append "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-"
523 version ".tar.gz"))
524 (sha256
525 (base32 "1zjzl7acvcdavmcg5l7wi12jd4rh95q9pl5aiww7hv0v0mv6bmj8"))))
526 (build-system gnu-build-system)
527 (arguments
528 `(#:phases
529 (modify-phases %standard-phases
530 (delete 'configure)
531 ;; `make install` isn't available, so we have to do it manually
532 (replace 'install
533 (lambda* (#:key outputs #:allow-other-keys)
534 (let ((out (assoc-ref outputs "out"))
535 (lua-version ,(version-major+minor (package-version lua))))
536 (install-file "lpeg.so"
537 (string-append out "/lib/lua/" lua-version))
538 (install-file "re.lua"
539 (string-append out "/share/lua/" lua-version))
540 #t))))
541 #:test-target "test"))
542 (inputs `(("lua" ,lua)))
543 (synopsis "Pattern-matching library for Lua")
544 (description
545 "LPeg is a pattern-matching library for Lua, based on Parsing Expression
546 Grammars (PEGs).")
547 (home-page "http://www.inf.puc-rio.br/~roberto/lpeg")
548 (license license:expat)))
549
550 (define-public lua-lpeg
551 (make-lua-lpeg "lua-lpeg" lua))
552
553 (define-public lua5.1-lpeg
554 (make-lua-lpeg "lua5.1-lpeg" lua-5.1))
555
556 (define-public lua5.2-lpeg
557 (make-lua-lpeg "lua5.2-lpeg" lua-5.2))
558
559 (define (make-lua-luv name lua)
560 (package
561 (name name)
562 (version "1.32.0-0")
563 (source (origin
564 ;; The release tarball includes the sources of libuv but does
565 ;; not include the pkg-config files.
566 (method git-fetch)
567 (uri (git-reference
568 (url "https://github.com/luvit/luv.git")
569 (commit version)))
570 (file-name (git-file-name name version))
571 (sha256
572 (base32
573 "0c65c1lhbl0axnyks3910gjs0z0hw7w6jvl07g8kbpnbvfl4qajh"))))
574 (build-system cmake-build-system)
575 (arguments
576 `(#:tests? #f ; there are none
577 #:configure-flags
578 '("-DWITH_LUA_ENGINE=Lua"
579 "-DWITH_SHARED_LIBUV=On"
580 "-DBUILD_MODULE=Off"
581 "-DBUILD_SHARED_LIBS=On"
582 "-DLUA_BUILD_TYPE=System")
583 #:phases
584 (modify-phases %standard-phases
585 (add-after 'unpack 'copy-lua-compat
586 (lambda* (#:key inputs #:allow-other-keys)
587 (copy-recursively (assoc-ref inputs "lua-compat")
588 "lua-compat")
589 (setenv "CPATH"
590 (string-append (getcwd) "/lua-compat:"
591 (or (getenv "CPATH") "")))
592 #t)))))
593 (inputs
594 `(("lua" ,lua)
595 ("libuv" ,libuv)))
596 (native-inputs
597 `(("lua-compat"
598 ,(origin
599 (method git-fetch)
600 (uri (git-reference
601 (url "https://github.com/keplerproject/lua-compat-5.3.git")
602 (commit "daebe77a2f498817713df37f0bb316db1d82222f")))
603 (file-name "lua-compat-5.3-checkout")
604 (sha256
605 (base32
606 "02a14nvn7aggg1yikj9h3dcf8aqjbxlws1bfvqbpfxv9d5phnrpz"))))))
607 (home-page "https://github.com/luvit/luv/")
608 (synopsis "Libuv bindings for Lua")
609 (description
610 "This library makes libuv available to Lua scripts.")
611 (license license:asl2.0)))
612
613 (define-public lua-luv
614 (make-lua-luv "lua-luv" lua))
615
616 (define-public lua5.1-luv
617 (make-lua-luv "lua5.1-luv" lua-5.1))
618
619 (define-public lua5.2-luv
620 (make-lua-luv "lua5.2-luv" lua-5.2))
621
622 ;; Lua 5.3 is not supported.
623 (define (make-lua-bitop name lua)
624 (package
625 (name name)
626 (version "1.0.2")
627 (source (origin
628 (method url-fetch)
629 (uri (string-append "http://bitop.luajit.org/download/"
630 "LuaBitOp-" version ".tar.gz"))
631 (sha256
632 (base32
633 "16fffbrgfcw40kskh2bn9q7m3gajffwd2f35rafynlnd7llwj1qj"))))
634 (build-system gnu-build-system)
635 (arguments
636 `(#:test-target "test"
637 #:make-flags
638 (list "INSTALL=install -pD"
639 (string-append "INSTALLPATH=printf "
640 (assoc-ref %outputs "out")
641 "/lib/lua/"
642 ,(version-major+minor (package-version lua))
643 "/bit/bit.so"))
644 #:phases
645 (modify-phases %standard-phases
646 (delete 'configure))))
647 (inputs `(("lua" ,lua)))
648 (home-page "https://bitop.luajit.org/index.html")
649 (synopsis "Bitwise operations on numbers for Lua")
650 (description
651 "Lua BitOp is a C extension module for Lua which adds bitwise operations
652 on numbers.")
653 (license license:expat)))
654
655 (define-public lua5.2-bitop
656 (make-lua-bitop "lua5.2-bitop" lua-5.2))
657
658 (define-public lua5.1-bitop
659 (make-lua-bitop "lua5.1-bitop" lua-5.1))
660
661 (define-public selene
662 (package
663 (name "selene")
664 (version "2017.08.25")
665 (source (origin
666 (method git-fetch)
667 (uri (git-reference
668 (url "https://github.com/jeremyong/Selene.git")
669 ;; The release is quite old.
670 (commit "ffe1ade2568d4cff5894552be8f43e63e379a4c9")))
671 (file-name "Selene")
672 (sha256
673 (base32
674 "1axrgv3rxxdsaf807lwvklfzicn6x6gpf35narllrnz9lg6hn508"))))
675 (build-system cmake-build-system)
676 (arguments
677 `(#:configure-flags
678 ;; lua pc file in CMakeLists.txt is lua5.3.pc
679 '("-DLUA_PC_CFG=lua;lua-5.3;lua-5.1")
680 #:test-target "all"
681 #:phases
682 ;; This is a header only library
683 (modify-phases %standard-phases
684 (delete 'build)
685 (replace 'install
686 (lambda* (#:key inputs outputs #:allow-other-keys)
687 (let* ((output (assoc-ref outputs "out"))
688 (source (assoc-ref inputs "source"))
689 (includedir (string-append output "/include")))
690 (copy-recursively
691 (string-append source "/include")
692 includedir))
693 #t))
694 ;; The path of test files are hard coded.
695 (replace 'check
696 (lambda* (#:key inputs outputs #:allow-other-keys)
697 (let* ((output (assoc-ref outputs "out"))
698 (source (assoc-ref inputs "source"))
699 (builddir (getcwd))
700 (testdir (string-append builddir "/test")))
701 (copy-recursively (string-append source "/test") testdir)
702 (invoke "make")
703 (mkdir-p "runner")
704 (copy-file "./test_runner" "./runner/test_runner")
705 (chdir "./runner")
706 (invoke "./test_runner")))))))
707 (native-inputs
708 `(("lua" ,lua)
709 ("pkg-config" ,pkg-config)))
710 (home-page "https://github.com/jeremyong/Selene")
711 (synopsis "Lua C++11 bindings")
712 (description
713 "Selene is a simple C++11 header-only library enabling seamless
714 interoperability between C++ and Lua programming language.")
715 (license license:zlib)))