gnu: criu: Update to 3.11.
[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>
864a9590 6;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
07cbe28e 7;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
03d8505f 8;;; Copyright © 2016 doncatnip <gnopap@gmail.com>
cb31a524 9;;; Copyright © 2016, 2017 Clément Lassieur <clement@lassieur.org>
35cdc267 10;;; Copyright © 2016 José Miguel Sánchez García <jmi2k@openmailbox.org>
906f1b48 11;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
ce577655 12;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com>
712e6e68
CR
13;;;
14;;; This file is part of GNU Guix.
15;;;
16;;; GNU Guix is free software; you can redistribute it and/or modify it
17;;; under the terms of the GNU General Public License as published by
18;;; the Free Software Foundation; either version 3 of the License, or (at
19;;; your option) any later version.
20;;;
21;;; GNU Guix is distributed in the hope that it will be useful, but
22;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24;;; GNU General Public License for more details.
25;;;
26;;; You should have received a copy of the GNU General Public License
27;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28
29(define-module (gnu packages lua)
572e433f 30 #:use-module ((guix licenses) #:prefix license:)
712e6e68
CR
31 #:use-module (guix packages)
32 #:use-module (guix download)
ce577655 33 #:use-module (guix git-download)
35cdc267 34 #:use-module (guix utils)
712e6e68 35 #:use-module (guix build-system gnu)
ce577655 36 #:use-module (guix build-system cmake)
712e6e68 37 #:use-module (gnu packages)
fd07a6a6 38 #:use-module (gnu packages readline)
d62dc2ae 39 #:use-module (gnu packages tls)
03d8505f 40 #:use-module (gnu packages xml)
41 #:use-module (gnu packages glib)
42 #:use-module (gnu packages libffi)
43 #:use-module (gnu packages pkg-config)
44 #:use-module (gnu packages xorg)
45 #:use-module (gnu packages gtk))
712e6e68
CR
46
47(define-public lua
48 (package
49 (name "lua")
6094a65e 50 (version "5.3.5")
712e6e68
CR
51 (source (origin
52 (method url-fetch)
6dbf1fec 53 (uri (string-append "https://www.lua.org/ftp/lua-"
712e6e68
CR
54 version ".tar.gz"))
55 (sha256
6094a65e 56 (base32 "1b2qn2rv96nmbm6zab4l877bd4zq7wpwm8drwjiy2ih4jqzysbhc"))
fc1adab1 57 (patches (search-patches "lua-pkgconfig.patch"
6dbf1fec 58 "lua-liblua-so.patch"))))
712e6e68 59 (build-system gnu-build-system)
b3546174 60 (inputs `(("readline" ,readline)))
712e6e68
CR
61 (arguments
62 '(#:modules ((guix build gnu-build-system)
07cbe28e
RW
63 (guix build utils)
64 (srfi srfi-1))
712e6e68 65 #:test-target "test"
07cbe28e 66 #:make-flags
c0d47cad 67 '("MYCFLAGS=-fPIC -DLUA_DL_DLOPEN"
07cbe28e 68 "linux")
a4349e7a
EF
69 #:phases
70 (modify-phases %standard-phases
71 (delete 'configure)
a4349e7a
EF
72 (replace 'install
73 (lambda* (#:key outputs #:allow-other-keys)
74 (let ((out (assoc-ref outputs "out")))
ffa95cf3
MW
75 (invoke "make" "install"
76 (string-append "INSTALL_TOP=" out)
77 (string-append "INSTALL_MAN=" out
78 "/share/man/man1"))))))))
6dbf1fec 79 (home-page "https://www.lua.org/")
9e771e3b 80 (synopsis "Embeddable scripting language")
712e6e68
CR
81 (description
82 "Lua is a powerful, fast, lightweight, embeddable scripting language. Lua
83combines simple procedural syntax with powerful data description constructs
35b9e423 84based on associative arrays and extensible semantics. Lua is dynamically typed,
712e6e68
CR
85runs by interpreting bytecode for a register-based virtual machine, and has
86automatic memory management with incremental garbage collection, making it ideal
87for configuration, scripting, and rapid prototyping.")
572e433f 88 (license license:x11)))
924cd631 89
6dbf1fec
MB
90(define-public lua-5.2
91 (package (inherit lua)
92 (version "5.2.4")
93 (source
94 (origin
95 (method url-fetch)
96 (uri (string-append "https://www.lua.org/ftp/lua-"
97 version ".tar.gz"))
98 (sha256
99 (base32 "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr"))
100 (patches (search-patches "lua-pkgconfig.patch"
101 "lua-liblua-so.patch"))))))
102
01d3f19b
AE
103(define-public lua-5.1
104 (package (inherit lua)
105 (version "5.1.5")
106 (source (origin
107 (method url-fetch)
6dbf1fec 108 (uri (string-append "https://www.lua.org/ftp/lua-"
01d3f19b
AE
109 version ".tar.gz"))
110 (sha256
c361d075 111 (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))
32fddd8e 112 (patches (search-patches "lua51-liblua-so.patch"
a287fafe
DM
113 "lua-CVE-2014-5461.patch"
114 "lua51-pkgconfig.patch"))))))
01d3f19b 115
924cd631
RG
116(define-public luajit
117 (package
118 (name "luajit")
906f1b48 119 (version "2.1.0-beta3")
924cd631
RG
120 (source (origin
121 (method url-fetch)
122 (uri (string-append "http://luajit.org/download/LuaJIT-"
123 version ".tar.gz"))
124 (sha256
906f1b48
TGR
125 (base32 "1hyrhpkwjqsv54hnnx4cl8vk44h9d6c9w0fz1jfjz00w255y7lhs"))
126 (patches (search-patches "luajit-no_ldconfig.patch"))))
924cd631
RG
127 (build-system gnu-build-system)
128 (arguments
a093bb69
TGR
129 `(#:tests? #f ; luajit is distributed without tests
130 #:phases
131 (modify-phases %standard-phases
132 (delete 'configure) ; no configure script
133 (add-after 'install 'create-luajit-symlink
134 (lambda* (#:key outputs #:allow-other-keys)
135 (let* ((out (assoc-ref outputs "out"))
136 (bin (string-append out "/bin")))
137 (with-directory-excursion bin
138 (symlink ,(string-append name "-" version)
139 ,name)
140 #t)))))
141 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))))
0386cdd3 142 (home-page "https://www.luajit.org/")
924cd631
RG
143 (synopsis "Just in time compiler for Lua programming language version 5.1")
144 (description
145 "LuaJIT is a Just-In-Time Compiler (JIT) for the Lua
146programming language. Lua is a powerful, dynamic and light-weight programming
147language. It may be embedded or used as a general-purpose, stand-alone
148language.")
572e433f 149 (license license:x11)))
fd07a6a6
RW
150
151(define-public lua5.1-expat
152 (package
153 (name "lua5.1-expat")
154 (version "1.3.0")
155 (source (origin
156 (method url-fetch)
157 (uri (string-append "https://matthewwild.co.uk/projects/"
158 "luaexpat/luaexpat-" version ".tar.gz"))
159 (sha256
160 (base32
161 "1hvxqngn0wf5642i5p3vcyhg3pmp102k63s9ry4jqyyqc1wkjq6h"))))
162 (build-system gnu-build-system)
163 (arguments
164 `(#:make-flags
165 (let ((out (assoc-ref %outputs "out")))
166 (list "CC=gcc"
167 (string-append "LUA_LDIR=" out "/share/lua/$(LUA_V)")
168 (string-append "LUA_CDIR=" out "/lib/lua/$(LUA_V)")))
169 #:phases
170 (modify-phases %standard-phases
171 (delete 'configure)
172 (replace 'check
173 (lambda _
174 (setenv "LUA_CPATH" "src/?.so;;")
175 (setenv "LUA_PATH" "src/?.lua;;")
12a16602
MW
176 (invoke "lua" "tests/test.lua")
177 (invoke "lua" "tests/test-lom.lua"))))))
fd07a6a6
RW
178 (inputs
179 `(("lua" ,lua-5.1)
180 ("expat" ,expat)))
181 (home-page "http://matthewwild.co.uk/projects/luaexpat/")
182 (synopsis "SAX XML parser based on the Expat library")
183 (description "LuaExpat is a SAX XML parser based on the Expat library.")
184 (license (package-license lua-5.1))))
c21b8261
RW
185
186(define-public lua5.1-socket
187 (package
188 (name "lua5.1-socket")
50269c01 189 (version "3.0-rc1")
c21b8261
RW
190 (source (origin
191 (method url-fetch)
50269c01
CL
192 (uri (string-append
193 "https://github.com/diegonehab/luasocket/archive/v"
194 version ".tar.gz"))
a6888fe3 195 (file-name (string-append name "-" version ".tar.gz"))
c21b8261
RW
196 (sha256
197 (base32
50269c01 198 "0j8jx8bjicvp9khs26xjya8c495wrpb7parxfnabdqa5nnsxjrwb"))))
c21b8261
RW
199 (build-system gnu-build-system)
200 (arguments
201 `(#:make-flags
202 (let ((out (assoc-ref %outputs "out")))
50269c01 203 (list (string-append "INSTALL_TOP=" out)))
c21b8261
RW
204 #:phases
205 (modify-phases %standard-phases
206 (delete 'configure)
207 (replace 'check
208 (lambda _
209 (setenv "LUA_CPATH" (string-append "src/?.so." ,version ";;"))
210 (setenv "LUA_PATH" "src/?.lua;;")
211 (when (zero? (primitive-fork))
6e3fc9ba
MW
212 (invoke "lua" "test/testsrvr.lua"))
213 (invoke "lua" "test/testclnt.lua"))))))
c21b8261
RW
214 (inputs
215 `(("lua" ,lua-5.1)))
216 (home-page "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/")
217 (synopsis "Socket library for Lua")
218 (description "LuaSocket is a Lua extension library that is composed by two
219parts: a C core that provides support for the TCP and UDP transport layers,
220and a set of Lua modules that add support for functionality commonly needed by
221applications that deal with the Internet.
222
223Among the supported modules, the most commonly used implement the
224SMTP (sending e-mails), HTTP (WWW access) and FTP (uploading and downloading
225files) client protocols. These provide a very natural and generic interface
226to the functionality defined by each protocol. In addition, you will find
227that the MIME (common encodings), URL (anything you could possible want to do
228with one) and LTN12 (filters, sinks, sources and pumps) modules can be very
229handy.")
230 (license (package-license lua-5.1))))
182de8fc
RW
231
232(define-public lua5.1-filesystem
233 (package
234 (name "lua5.1-filesystem")
235 (version "1.6.3")
236 (source (origin
237 (method url-fetch)
238 (uri (string-append "https://github.com/keplerproject/"
239 "luafilesystem/archive/v_"
240 "1_6_3" ".tar.gz"))
241 (file-name (string-append name "-" version ".tar.gz"))
242 (sha256
243 (base32
244 "0s10ckxin0bysd6gaywqhxkpw3ybjhprr8m655b8cx3pxjwd49am"))))
245 (build-system gnu-build-system)
246 (arguments
247 `(#:make-flags
248 (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
249 #:test-target "test"
250 #:phases
251 (modify-phases %standard-phases
252 (delete 'configure))))
253 (inputs
254 `(("lua" ,lua-5.1)))
255 (home-page "https://keplerproject.github.io/luafilesystem/index.html")
256 (synopsis "File system library for Lua")
257 (description "LuaFileSystem is a Lua library developed to complement the
258set of functions related to file systems offered by the standard Lua
259distribution. LuaFileSystem offers a portable way to access the underlying
260directory structure and file attributes.")
261 (license (package-license lua-5.1))))
d62dc2ae
RW
262
263(define-public lua5.1-sec
264 (package
265 (name "lua5.1-sec")
266 (version "0.6")
267 (source (origin
268 (method url-fetch)
269 (uri (string-append "https://github.com/brunoos/luasec/archive/"
270 "luasec-" version ".tar.gz"))
271 (sha256
272 (base32
273 "0pgd1anzznl4s0h16wg8dlw9mgdb9h52drlcki6sbf5y31fa7wyf"))))
274 (build-system gnu-build-system)
275 (arguments
276 `(#:make-flags
277 (let ((out (assoc-ref %outputs "out")))
278 (list "linux"
279 "CC=gcc"
280 "LD=gcc"
281 (string-append "LUAPATH=" out "/share/lua/5.1")
282 (string-append "LUACPATH=" out "/lib/lua/5.1")))
283 #:tests? #f ; no tests included
284 #:phases
285 (modify-phases %standard-phases
286 (delete 'configure))))
287 (inputs
288 `(("lua" ,lua-5.1)
289 ("openssl" ,openssl)))
290 (propagated-inputs
291 `(("lua-socket" ,lua5.1-socket)))
292 (home-page "https://github.com/brunoos/luasec/wiki")
293 (synopsis "OpenSSL bindings for Lua")
294 (description "LuaSec is a binding for OpenSSL library to provide TLS/SSL
295communication. It takes an already established TCP connection and creates a
296secure session between the peers.")
297 (license (package-license lua-5.1))))
03d8505f 298
299(define-public lua-lgi
300 (package
301 (name "lua-lgi")
ad514303 302 (version "0.9.2")
03d8505f 303 (source
304 (origin
305 (method url-fetch)
306 (uri (string-append
307 "https://github.com/pavouk/lgi/archive/"
308 version ".tar.gz"))
309 (file-name (string-append name "-" version ".tar.gz"))
310 (sha256
311 (base32
ad514303 312 "0kwcaj3ahi9gxfyp0lr5zgr6vi1mgsg9sz0980x0nwxlh9a11i6g"))))
03d8505f 313 (build-system gnu-build-system)
314 (arguments
315 '(#:make-flags (list "CC=gcc"
316 (string-append "PREFIX=" (assoc-ref %outputs "out")))
317 #:phases
318 (modify-phases %standard-phases
319 (delete 'configure) ; no configure script
320 (add-before 'build 'set-env
321 (lambda* (#:key inputs #:allow-other-keys)
322 ;; we need to load cairo dynamically
323 (let* ((cairo (string-append
324 (assoc-ref inputs "cairo") "/lib" )))
325 (setenv "LD_LIBRARY_PATH" cairo)
326 #t)))
327 (add-before 'build 'set-lua-version
328 (lambda _
329 ;; lua version and therefore install directories are hardcoded
330 ;; FIXME: This breaks when we update lua to >=5.3
331 (substitute* "./lgi/Makefile"
332 (("LUA_VERSION=5.1") "LUA_VERSION=5.2"))
333 #t))
334 (add-before 'check 'skip-test-gtk
335 (lambda _
336 ;; FIXME: Skip GTK tests:
337 ;; gtk3 - can't get it to run with the xorg-server config below
338 ;; and some non-gtk tests will also fail
339 ;; gtk2 - lots of functions aren't implemented
340 ;; We choose gtk2 as the lesser evil and simply skip the test.
341 ;; Currently, awesome is the only package that uses lua-lgi but
342 ;; it doesn't need or interact with GTK using lua-lgi.
343 (substitute* "./tests/test.lua"
344 (("'gtk.lua',") "-- 'gtk.lua',"))
345 #t))
346 (add-before 'check 'start-xserver-instance
347 (lambda* (#:key inputs #:allow-other-keys)
348 ;; There must be a running X server during tests.
349 (system (format #f "~a/bin/Xvfb :1 &"
350 (assoc-ref inputs "xorg-server")))
351 (setenv "DISPLAY" ":1")
352 #t)))))
353 (inputs
354 `(("gobject-introspection" ,gobject-introspection)
355 ("glib" ,glib)
c695fb76
TGR
356 ("pango" ,pango)
357 ("gtk" ,gtk+-2)
03d8505f 358 ("lua" ,lua)
359 ("cairo" ,cairo)
360 ("libffi" ,libffi)
c695fb76 361 ("xorg-server" ,xorg-server)))
03d8505f 362 (native-inputs
ad514303
LC
363 `(("pkg-config" ,pkg-config)
364 ("dbus" ,dbus))) ;tests use 'dbus-run-session'
03d8505f 365 (home-page "https://github.com/pavouk/lgi/")
366 (synopsis "Lua bridge to GObject based libraries")
367 (description
368 "LGI is gobject-introspection based dynamic Lua binding to GObject
369based libraries. It allows using GObject-based libraries directly from Lua.
370Notable examples are GTK+, GStreamer and Webkit.")
371 (license license:expat)))
35cdc267 372
149b2c43 373(define (make-lua-lpeg name lua)
35cdc267 374 (package
149b2c43 375 (name name)
139c8f94 376 (version "1.0.1")
35cdc267
JMSG
377 (source (origin
378 (method url-fetch)
379 (uri (string-append "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-"
380 version ".tar.gz"))
381 (sha256
139c8f94 382 (base32 "0sq25z3r324a324ky73izgq9mbf66j2xvjp0fxf227rwxalzgnb2"))))
35cdc267
JMSG
383 (build-system gnu-build-system)
384 (arguments
385 `(#:phases
386 (modify-phases %standard-phases
387 (delete 'configure)
388 ;; `make install` isn't available, so we have to do it manually
389 (replace 'install
390 (lambda* (#:key outputs #:allow-other-keys)
391 (let ((out (assoc-ref outputs "out"))
392 (lua-version ,(version-major+minor (package-version lua))))
393 (install-file "lpeg.so"
394 (string-append out "/lib/lua/" lua-version))
395 (install-file "re.lua"
396 (string-append out "/share/lua/" lua-version))
397 #t))))
398 #:test-target "test"))
c695fb76 399 (inputs `(("lua" ,lua)))
35cdc267
JMSG
400 (synopsis "Pattern-matching library for Lua")
401 (description
402 "LPeg is a pattern-matching library for Lua, based on Parsing Expression
403Grammars (PEGs).")
404 (home-page "http://www.inf.puc-rio.br/~roberto/lpeg")
405 (license license:expat)))
cf9a788d 406
149b2c43
CL
407(define-public lua-lpeg
408 (make-lua-lpeg "lua-lpeg" lua))
409
01a0a0c4
H
410(define-public lua5.1-lpeg
411 (make-lua-lpeg "lua5.1-lpeg" lua-5.1))
412
d9ed1779 413(define-public lua5.2-lpeg
149b2c43 414 (make-lua-lpeg "lua5.2-lpeg" lua-5.2))
d9ed1779 415
cf9a788d 416;; Lua 5.3 is not supported.
cb31a524 417(define (make-lua-bitop name lua)
cf9a788d 418 (package
cb31a524 419 (name name)
cf9a788d
RW
420 (version "1.0.2")
421 (source (origin
422 (method url-fetch)
423 (uri (string-append "http://bitop.luajit.org/download/"
424 "LuaBitOp-" version ".tar.gz"))
425 (sha256
426 (base32
427 "16fffbrgfcw40kskh2bn9q7m3gajffwd2f35rafynlnd7llwj1qj"))))
428 (build-system gnu-build-system)
429 (arguments
430 `(#:test-target "test"
431 #:make-flags
432 (list "INSTALL=install -pD"
433 (string-append "INSTALLPATH=printf "
434 (assoc-ref %outputs "out")
435 "/lib/lua/"
cb31a524 436 ,(version-major+minor (package-version lua))
cf9a788d
RW
437 "/bit/bit.so"))
438 #:phases
439 (modify-phases %standard-phases
440 (delete 'configure))))
c695fb76 441 (inputs `(("lua" ,lua)))
0386cdd3 442 (home-page "https://bitop.luajit.org/index.html")
cf9a788d
RW
443 (synopsis "Bitwise operations on numbers for Lua")
444 (description
445 "Lua BitOp is a C extension module for Lua which adds bitwise operations
446on numbers.")
447 (license license:expat)))
cb31a524
CL
448
449(define-public lua5.2-bitop
450 (make-lua-bitop "lua5.2-bitop" lua-5.2))
451
452(define-public lua5.1-bitop
453 (make-lua-bitop "lua5.1-bitop" lua-5.1))
ce577655
FT
454
455(define-public selene
456 (package
457 (name "selene")
458 (version "2017.08.25")
459 (source (origin
460 (method git-fetch)
461 (uri (git-reference
462 (url "https://github.com/jeremyong/Selene.git")
463 ;; The release is quite old.
464 (commit "ffe1ade2568d4cff5894552be8f43e63e379a4c9")))
465 (file-name "Selene")
466 (sha256
467 (base32
468 "1axrgv3rxxdsaf807lwvklfzicn6x6gpf35narllrnz9lg6hn508"))))
469 (build-system cmake-build-system)
470 (arguments
471 `(#:configure-flags
472 ;; lua pc file in CMakeLists.txt is lua5.3.pc
473 '("-DLUA_PC_CFG=lua;lua-5.3;lua-5.1")
474 #:test-target "all"
475 #:phases
476 ;; This is a header only library
477 (modify-phases %standard-phases
478 (delete 'build)
479 (replace 'install
480 (lambda* (#:key inputs outputs #:allow-other-keys)
481 (let* ((output (assoc-ref outputs "out"))
482 (source (assoc-ref inputs "source"))
483 (includedir (string-append output "/include")))
484 (copy-recursively
485 (string-append source "/include")
486 includedir))
487 #t))
488 ;; The path of test files are hard coded.
489 (replace 'check
490 (lambda* (#:key inputs outputs #:allow-other-keys)
491 (let* ((output (assoc-ref outputs "out"))
492 (source (assoc-ref inputs "source"))
493 (builddir (getcwd))
494 (testdir (string-append builddir "/test")))
495 (copy-recursively (string-append source "/test") testdir)
496 (invoke "make")
497 (mkdir-p "runner")
498 (copy-file "./test_runner" "./runner/test_runner")
499 (chdir "./runner")
500 (invoke "./test_runner")))))))
501 (native-inputs
502 `(("lua" ,lua)
503 ("pkg-config" ,pkg-config)))
504 (home-page "https://github.com/jeremyong/Selene")
505 (synopsis "Lua C++11 bindings")
506 (description
507 "Selene is a simple C++11 header-only library enabling seamless
508 interoperability between C++ and Lua programming language.")
509 (license license:zlib)))