gnu: Add lua-ossl.
[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
1fd4b99e
NG
404(define-public lua-penlight
405 (package
406 (name "lua-penlight")
407 (version "1.7.0")
408 (source
409 (origin
410 (method git-fetch)
411 (uri (git-reference
412 (url "https://github.com/Tieske/Penlight.git")
413 (commit version)))
414 (file-name (git-file-name name version))
415 (sha256
416 (base32 "0qc2d1riyr4b5a0gnsmdw2lz5pw65s4ac60hc34w3mmk9l6yg6nl"))))
417 (build-system trivial-build-system)
418 (inputs
419 `(("lua" ,lua)))
420 (propagated-inputs
421 `(("lua-filesystem" ,lua-filesystem)))
422 (arguments
423 `(#:modules ((guix build utils))
424 #:builder
425 (begin
426 (use-modules (guix build utils))
427 (let* ((source (assoc-ref %build-inputs "source"))
428 (lua-version ,(version-major+minor (package-version lua)))
429 (destination (string-append (assoc-ref %outputs "out")
430 "/share/lua/" lua-version)))
431 (mkdir-p destination)
432 (with-directory-excursion source
433 (copy-recursively "lua/" destination)))
434 #t)))
435 (home-page "http://tieske.github.io/Penlight/")
436 (synopsis "Collection of general purpose libraries for the Lua language")
437 (description "Penlight is a set of pure Lua libraries focusing on
438input data handling (such as reading configuration files), functional
439programming (such as map, reduce, placeholder expressions,etc), and OS
440path management. Much of the functionality is inspired by the Python
441standard libraries.")
442 (license license:expat)))
443
4898e06a
NG
444(define-public lua-ldoc
445 (package
446 (name "lua-ldoc")
447 (version "1.4.6")
448 (source
449 (origin
450 (method git-fetch)
451 (uri (git-reference
452 (url "https://github.com/stevedonovan/LDoc.git")
453 (commit version)))
454 (file-name (git-file-name name version))
455 (sha256
456 (base32 "1h0cf7bp4am54r0j8lhjs2l1c7q5vz74ba0jvw9qdbaqimls46g8"))))
457 (build-system gnu-build-system)
458 (inputs
459 `(("lua" ,lua)))
460 (propagated-inputs
461 `(("lua-penlight" ,lua-penlight)))
462 (arguments
463 `(#:tests? #f ;tests must run after installation.
464 #:phases
465 (modify-phases %standard-phases
466 (add-after 'unpack 'fix-installation-directory
467 (lambda* (#:key outputs #:allow-other-keys)
468 (let ((out (assoc-ref outputs "out"))
469 (lua-version ,(version-major+minor (package-version lua))))
470 (substitute* "makefile"
471 (("LUA=.*") "#\n")
472 (("(LUA_PREFIX=).*" _ prefix)
473 (string-append prefix out "\n"))
474 (("(LUA_BINDIR=).*" _ prefix)
475 (string-append prefix out "/bin\n"))
476 (("(LUA_SHAREDIR=).*" _ prefix)
477 (string-append prefix out "/share/lua/" lua-version "\n"))))
478 #t))
479 (delete 'configure)
480 (add-before 'install 'create-bin-directory
481 (lambda* (#:key outputs #:allow-other-keys)
482 (mkdir-p (string-append (assoc-ref outputs "out") "/bin"))
483 #t)))))
484 (home-page "http://stevedonovan.github.io/ldoc/")
485 (synopsis "Lua documentation generator")
486 (description
487 "LDoc is a LuaDoc-compatible documentation generation system for
488Lua source code. It parses the declaration and documentation comments
489in a set of Lua source files and produces a set of XHTML pages
490describing the commented declarations and functions.")
491 (license license:expat)))
492
1c58aa6f 493(define (make-lua-lgi name lua)
03d8505f 494 (package
1c58aa6f 495 (name name)
ad514303 496 (version "0.9.2")
03d8505f 497 (source
1c58aa6f
NG
498 (origin
499 (method git-fetch)
500 (uri (git-reference
501 (url "https://github.com/pavouk/lgi")
502 (commit version)))
503 (file-name (git-file-name name version))
504 (sha256
505 (base32 "03rbydnj411xpjvwsyvhwy4plm96481d7jax544mvk7apd8sd5jj"))))
03d8505f 506 (build-system gnu-build-system)
507 (arguments
1c58aa6f
NG
508 `(#:make-flags
509 (list "CC=gcc"
510 (string-append "PREFIX=" (assoc-ref %outputs "out")))
03d8505f 511 #:phases
512 (modify-phases %standard-phases
1c58aa6f 513 (delete 'configure) ; no configure script
03d8505f 514 (add-before 'build 'set-env
515 (lambda* (#:key inputs #:allow-other-keys)
1c58aa6f
NG
516 ;; We need to load cairo dynamically.
517 (let* ((cairo (string-append (assoc-ref inputs "cairo") "/lib")))
03d8505f 518 (setenv "LD_LIBRARY_PATH" cairo)
519 #t)))
520 (add-before 'build 'set-lua-version
521 (lambda _
1c58aa6f 522 ;; Lua version and therefore install directories are hardcoded.
03d8505f 523 (substitute* "./lgi/Makefile"
1c58aa6f
NG
524 (("LUA_VERSION=5.1")
525 (format #f
526 "LUA_VERSION=~a"
527 ,(version-major+minor (package-version lua)))))
03d8505f 528 #t))
529 (add-before 'check 'skip-test-gtk
530 (lambda _
531 ;; FIXME: Skip GTK tests:
532 ;; gtk3 - can't get it to run with the xorg-server config below
533 ;; and some non-gtk tests will also fail
534 ;; gtk2 - lots of functions aren't implemented
535 ;; We choose gtk2 as the lesser evil and simply skip the test.
536 ;; Currently, awesome is the only package that uses lua-lgi but
537 ;; it doesn't need or interact with GTK using lua-lgi.
538 (substitute* "./tests/test.lua"
539 (("'gtk.lua',") "-- 'gtk.lua',"))
540 #t))
541 (add-before 'check 'start-xserver-instance
542 (lambda* (#:key inputs #:allow-other-keys)
543 ;; There must be a running X server during tests.
544 (system (format #f "~a/bin/Xvfb :1 &"
545 (assoc-ref inputs "xorg-server")))
546 (setenv "DISPLAY" ":1")
547 #t)))))
1c58aa6f
NG
548 (native-inputs
549 `(("dbus" ,dbus) ;tests use 'dbus-run-session'
550 ("pkg-config" ,pkg-config)))
03d8505f 551 (inputs
1c58aa6f 552 `(("cairo" ,cairo)
03d8505f 553 ("glib" ,glib)
1c58aa6f 554 ("gobject-introspection" ,gobject-introspection)
c695fb76 555 ("gtk" ,gtk+-2)
03d8505f 556 ("libffi" ,libffi)
1c58aa6f
NG
557 ("lua" ,lua)
558 ("pango" ,pango)
c695fb76 559 ("xorg-server" ,xorg-server)))
03d8505f 560 (home-page "https://github.com/pavouk/lgi/")
561 (synopsis "Lua bridge to GObject based libraries")
562 (description
1c58aa6f
NG
563 "LGI is gobject-introspection based dynamic Lua binding to GObject based
564libraries. It allows using GObject-based libraries directly from Lua.
03d8505f 565Notable examples are GTK+, GStreamer and Webkit.")
566 (license license:expat)))
35cdc267 567
1c58aa6f
NG
568(define-public lua-lgi
569 (make-lua-lgi "lua-lgi" lua))
570
571(define-public lua5.1-lgi
572 (make-lua-lgi "lua5.1-lgi" lua-5.1))
573
574(define-public lua5.2-lgi
575 (make-lua-lgi "lua5.2-lgi" lua-5.2))
576
149b2c43 577(define (make-lua-lpeg name lua)
35cdc267 578 (package
149b2c43 579 (name name)
e3545ffc 580 (version "1.0.2")
35cdc267
JMSG
581 (source (origin
582 (method url-fetch)
583 (uri (string-append "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-"
584 version ".tar.gz"))
585 (sha256
e3545ffc 586 (base32 "1zjzl7acvcdavmcg5l7wi12jd4rh95q9pl5aiww7hv0v0mv6bmj8"))))
35cdc267
JMSG
587 (build-system gnu-build-system)
588 (arguments
589 `(#:phases
590 (modify-phases %standard-phases
591 (delete 'configure)
592 ;; `make install` isn't available, so we have to do it manually
593 (replace 'install
594 (lambda* (#:key outputs #:allow-other-keys)
595 (let ((out (assoc-ref outputs "out"))
596 (lua-version ,(version-major+minor (package-version lua))))
597 (install-file "lpeg.so"
598 (string-append out "/lib/lua/" lua-version))
599 (install-file "re.lua"
600 (string-append out "/share/lua/" lua-version))
601 #t))))
602 #:test-target "test"))
c695fb76 603 (inputs `(("lua" ,lua)))
35cdc267
JMSG
604 (synopsis "Pattern-matching library for Lua")
605 (description
606 "LPeg is a pattern-matching library for Lua, based on Parsing Expression
607Grammars (PEGs).")
608 (home-page "http://www.inf.puc-rio.br/~roberto/lpeg")
609 (license license:expat)))
cf9a788d 610
149b2c43
CL
611(define-public lua-lpeg
612 (make-lua-lpeg "lua-lpeg" lua))
613
01a0a0c4
H
614(define-public lua5.1-lpeg
615 (make-lua-lpeg "lua5.1-lpeg" lua-5.1))
616
d9ed1779 617(define-public lua5.2-lpeg
149b2c43 618 (make-lua-lpeg "lua5.2-lpeg" lua-5.2))
d9ed1779 619
9ad3d679
RW
620(define (make-lua-luv name lua)
621 (package
622 (name name)
251ce98c 623 (version "1.32.0-0")
9ad3d679
RW
624 (source (origin
625 ;; The release tarball includes the sources of libuv but does
626 ;; not include the pkg-config files.
627 (method git-fetch)
628 (uri (git-reference
629 (url "https://github.com/luvit/luv.git")
630 (commit version)))
631 (file-name (git-file-name name version))
632 (sha256
633 (base32
251ce98c 634 "0c65c1lhbl0axnyks3910gjs0z0hw7w6jvl07g8kbpnbvfl4qajh"))))
9ad3d679
RW
635 (build-system cmake-build-system)
636 (arguments
5327fbb3 637 `(#:tests? #f ; there are none
9ad3d679
RW
638 #:configure-flags
639 '("-DWITH_LUA_ENGINE=Lua"
640 "-DWITH_SHARED_LIBUV=On"
641 "-DBUILD_MODULE=Off"
642 "-DBUILD_SHARED_LIBS=On"
643 "-DLUA_BUILD_TYPE=System")
644 #:phases
645 (modify-phases %standard-phases
646 (add-after 'unpack 'copy-lua-compat
647 (lambda* (#:key inputs #:allow-other-keys)
648 (copy-recursively (assoc-ref inputs "lua-compat")
649 "lua-compat")
650 (setenv "CPATH"
651 (string-append (getcwd) "/lua-compat:"
652 (or (getenv "CPATH") "")))
653 #t)))))
654 (inputs
655 `(("lua" ,lua)
656 ("libuv" ,libuv)))
657 (native-inputs
658 `(("lua-compat"
659 ,(origin
660 (method git-fetch)
661 (uri (git-reference
662 (url "https://github.com/keplerproject/lua-compat-5.3.git")
663 (commit "daebe77a2f498817713df37f0bb316db1d82222f")))
664 (file-name "lua-compat-5.3-checkout")
665 (sha256
666 (base32
667 "02a14nvn7aggg1yikj9h3dcf8aqjbxlws1bfvqbpfxv9d5phnrpz"))))))
668 (home-page "https://github.com/luvit/luv/")
669 (synopsis "Libuv bindings for Lua")
670 (description
671 "This library makes libuv available to Lua scripts.")
672 (license license:asl2.0)))
673
674(define-public lua-luv
675 (make-lua-luv "lua-luv" lua))
676
677(define-public lua5.1-luv
678 (make-lua-luv "lua5.1-luv" lua-5.1))
679
680(define-public lua5.2-luv
681 (make-lua-luv "lua5.2-luv" lua-5.2))
682
cf9a788d 683;; Lua 5.3 is not supported.
cb31a524 684(define (make-lua-bitop name lua)
cf9a788d 685 (package
cb31a524 686 (name name)
cf9a788d
RW
687 (version "1.0.2")
688 (source (origin
689 (method url-fetch)
690 (uri (string-append "http://bitop.luajit.org/download/"
691 "LuaBitOp-" version ".tar.gz"))
692 (sha256
693 (base32
694 "16fffbrgfcw40kskh2bn9q7m3gajffwd2f35rafynlnd7llwj1qj"))))
695 (build-system gnu-build-system)
696 (arguments
697 `(#:test-target "test"
698 #:make-flags
699 (list "INSTALL=install -pD"
700 (string-append "INSTALLPATH=printf "
701 (assoc-ref %outputs "out")
702 "/lib/lua/"
cb31a524 703 ,(version-major+minor (package-version lua))
cf9a788d
RW
704 "/bit/bit.so"))
705 #:phases
706 (modify-phases %standard-phases
707 (delete 'configure))))
c695fb76 708 (inputs `(("lua" ,lua)))
0386cdd3 709 (home-page "https://bitop.luajit.org/index.html")
cf9a788d
RW
710 (synopsis "Bitwise operations on numbers for Lua")
711 (description
712 "Lua BitOp is a C extension module for Lua which adds bitwise operations
713on numbers.")
714 (license license:expat)))
cb31a524
CL
715
716(define-public lua5.2-bitop
717 (make-lua-bitop "lua5.2-bitop" lua-5.2))
718
719(define-public lua5.1-bitop
720 (make-lua-bitop "lua5.1-bitop" lua-5.1))
ce577655
FT
721
722(define-public selene
723 (package
724 (name "selene")
725 (version "2017.08.25")
726 (source (origin
727 (method git-fetch)
728 (uri (git-reference
729 (url "https://github.com/jeremyong/Selene.git")
730 ;; The release is quite old.
731 (commit "ffe1ade2568d4cff5894552be8f43e63e379a4c9")))
732 (file-name "Selene")
733 (sha256
734 (base32
735 "1axrgv3rxxdsaf807lwvklfzicn6x6gpf35narllrnz9lg6hn508"))))
736 (build-system cmake-build-system)
737 (arguments
738 `(#:configure-flags
739 ;; lua pc file in CMakeLists.txt is lua5.3.pc
740 '("-DLUA_PC_CFG=lua;lua-5.3;lua-5.1")
741 #:test-target "all"
742 #:phases
743 ;; This is a header only library
744 (modify-phases %standard-phases
745 (delete 'build)
746 (replace 'install
747 (lambda* (#:key inputs outputs #:allow-other-keys)
748 (let* ((output (assoc-ref outputs "out"))
749 (source (assoc-ref inputs "source"))
750 (includedir (string-append output "/include")))
751 (copy-recursively
752 (string-append source "/include")
753 includedir))
754 #t))
755 ;; The path of test files are hard coded.
756 (replace 'check
757 (lambda* (#:key inputs outputs #:allow-other-keys)
758 (let* ((output (assoc-ref outputs "out"))
759 (source (assoc-ref inputs "source"))
760 (builddir (getcwd))
761 (testdir (string-append builddir "/test")))
762 (copy-recursively (string-append source "/test") testdir)
763 (invoke "make")
764 (mkdir-p "runner")
765 (copy-file "./test_runner" "./runner/test_runner")
766 (chdir "./runner")
767 (invoke "./test_runner")))))))
768 (native-inputs
769 `(("lua" ,lua)
770 ("pkg-config" ,pkg-config)))
771 (home-page "https://github.com/jeremyong/Selene")
772 (synopsis "Lua C++11 bindings")
773 (description
774 "Selene is a simple C++11 header-only library enabling seamless
775 interoperability between C++ and Lua programming language.")
776 (license license:zlib)))