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 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
8 ;;; Copyright © 2016 doncatnip <gnopap@gmail.com>
9 ;;; Copyright © 2016, 2017 Clément Lassieur <clement@lassieur.org>
10 ;;; Copyright © 2016 José Miguel Sánchez García <jmi2k@openmailbox.org>
11 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
12 ;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com>
14 ;;; This file is part of GNU Guix.
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.
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.
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/>.
29 (define-module (gnu packages lua)
30 #:use-module ((guix licenses) #:prefix license:)
31 #:use-module (guix packages)
32 #:use-module (guix download)
33 #:use-module (guix git-download)
34 #:use-module (guix utils)
35 #:use-module (guix build utils)
36 #:use-module (guix build-system gnu)
37 #:use-module (guix build-system cmake)
38 #:use-module (gnu packages)
39 #:use-module (gnu packages readline)
40 #:use-module (gnu packages tls)
41 #:use-module (gnu packages xml)
42 #:use-module (gnu packages glib)
43 #:use-module (gnu packages libffi)
44 #:use-module (gnu packages pkg-config)
45 #:use-module (gnu packages xorg)
46 #:use-module (gnu packages gtk))
54 (uri (string-append "https://www.lua.org/ftp/lua-"
57 (base32 "0320a8dg3aci4hxla380dx1ifkw8gj4gbw5c4dz41g1kh98sm0gn"))
58 (patches (search-patches "lua-pkgconfig.patch"
59 "lua-liblua-so.patch"))))
60 (build-system gnu-build-system)
61 (inputs `(("readline" ,readline)))
63 '(#:modules ((guix build gnu-build-system)
68 '("MYCFLAGS=-fPIC -DLUA_DL_DLOPEN"
71 (modify-phases %standard-phases
74 (lambda* (#:key outputs #:allow-other-keys)
75 (let ((out (assoc-ref outputs "out")))
76 (zero? (system* "make" "install"
77 (string-append "INSTALL_TOP=" out)
78 (string-append "INSTALL_MAN=" out
79 "/share/man/man1")))))))))
80 (home-page "https://www.lua.org/")
81 (synopsis "Embeddable scripting language")
83 "Lua is a powerful, fast, lightweight, embeddable scripting language. Lua
84 combines simple procedural syntax with powerful data description constructs
85 based on associative arrays and extensible semantics. Lua is dynamically typed,
86 runs by interpreting bytecode for a register-based virtual machine, and has
87 automatic memory management with incremental garbage collection, making it ideal
88 for configuration, scripting, and rapid prototyping.")
89 (license license:x11)))
91 (define-public lua-5.2
92 (package (inherit lua)
97 (uri (string-append "https://www.lua.org/ftp/lua-"
100 (base32 "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr"))
101 (patches (search-patches "lua-pkgconfig.patch"
102 "lua-liblua-so.patch"))))))
104 (define-public lua-5.1
105 (package (inherit lua)
109 (uri (string-append "https://www.lua.org/ftp/lua-"
112 (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))
113 (patches (search-patches "lua51-liblua-so.patch"
114 "lua-CVE-2014-5461.patch"
115 "lua51-pkgconfig.patch"))))))
117 (define-public luajit
120 (version "2.1.0-beta3")
123 (uri (string-append "http://luajit.org/download/LuaJIT-"
126 (base32 "1hyrhpkwjqsv54hnnx4cl8vk44h9d6c9w0fz1jfjz00w255y7lhs"))
127 (patches (search-patches "luajit-no_ldconfig.patch"))))
128 (build-system gnu-build-system)
130 `(#:tests? #f ; luajit is distributed without tests
132 (modify-phases %standard-phases
133 (delete 'configure) ; no configure script
134 (add-after 'install 'create-luajit-symlink
135 (lambda* (#:key outputs #:allow-other-keys)
136 (let* ((out (assoc-ref outputs "out"))
137 (bin (string-append out "/bin")))
138 (with-directory-excursion bin
139 (symlink ,(string-append name "-" version)
142 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))))
143 (home-page "https://www.luajit.org/")
144 (synopsis "Just in time compiler for Lua programming language version 5.1")
146 "LuaJIT is a Just-In-Time Compiler (JIT) for the Lua
147 programming language. Lua is a powerful, dynamic and light-weight programming
148 language. It may be embedded or used as a general-purpose, stand-alone
150 (license license:x11)))
152 (define-public lua5.1-expat
154 (name "lua5.1-expat")
158 (uri (string-append "https://matthewwild.co.uk/projects/"
159 "luaexpat/luaexpat-" version ".tar.gz"))
162 "1hvxqngn0wf5642i5p3vcyhg3pmp102k63s9ry4jqyyqc1wkjq6h"))))
163 (build-system gnu-build-system)
166 (let ((out (assoc-ref %outputs "out")))
168 (string-append "LUA_LDIR=" out "/share/lua/$(LUA_V)")
169 (string-append "LUA_CDIR=" out "/lib/lua/$(LUA_V)")))
171 (modify-phases %standard-phases
175 (setenv "LUA_CPATH" "src/?.so;;")
176 (setenv "LUA_PATH" "src/?.lua;;")
177 (and (zero? (system* "lua" "tests/test.lua"))
178 (zero? (system* "lua" "tests/test-lom.lua"))))))))
182 (home-page "http://matthewwild.co.uk/projects/luaexpat/")
183 (synopsis "SAX XML parser based on the Expat library")
184 (description "LuaExpat is a SAX XML parser based on the Expat library.")
185 (license (package-license lua-5.1))))
187 (define-public lua5.1-socket
189 (name "lua5.1-socket")
194 "https://github.com/diegonehab/luasocket/archive/v"
196 (file-name (string-append name "-" version ".tar.gz"))
199 "0j8jx8bjicvp9khs26xjya8c495wrpb7parxfnabdqa5nnsxjrwb"))))
200 (build-system gnu-build-system)
203 (let ((out (assoc-ref %outputs "out")))
204 (list (string-append "INSTALL_TOP=" out)))
206 (modify-phases %standard-phases
210 (setenv "LUA_CPATH" (string-append "src/?.so." ,version ";;"))
211 (setenv "LUA_PATH" "src/?.lua;;")
212 (when (zero? (primitive-fork))
213 (system* "lua" "test/testsrvr.lua"))
214 (zero? (system* "lua" "test/testclnt.lua")))))))
217 (home-page "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/")
218 (synopsis "Socket library for Lua")
219 (description "LuaSocket is a Lua extension library that is composed by two
220 parts: a C core that provides support for the TCP and UDP transport layers,
221 and a set of Lua modules that add support for functionality commonly needed by
222 applications that deal with the Internet.
224 Among the supported modules, the most commonly used implement the
225 SMTP (sending e-mails), HTTP (WWW access) and FTP (uploading and downloading
226 files) client protocols. These provide a very natural and generic interface
227 to the functionality defined by each protocol. In addition, you will find
228 that the MIME (common encodings), URL (anything you could possible want to do
229 with one) and LTN12 (filters, sinks, sources and pumps) modules can be very
231 (license (package-license lua-5.1))))
233 (define-public lua5.1-filesystem
235 (name "lua5.1-filesystem")
239 (uri (string-append "https://github.com/keplerproject/"
240 "luafilesystem/archive/v_"
242 (file-name (string-append name "-" version ".tar.gz"))
245 "0s10ckxin0bysd6gaywqhxkpw3ybjhprr8m655b8cx3pxjwd49am"))))
246 (build-system gnu-build-system)
249 (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
252 (modify-phases %standard-phases
253 (delete 'configure))))
256 (home-page "https://keplerproject.github.io/luafilesystem/index.html")
257 (synopsis "File system library for Lua")
258 (description "LuaFileSystem is a Lua library developed to complement the
259 set of functions related to file systems offered by the standard Lua
260 distribution. LuaFileSystem offers a portable way to access the underlying
261 directory structure and file attributes.")
262 (license (package-license lua-5.1))))
264 (define-public lua5.1-sec
270 (uri (string-append "https://github.com/brunoos/luasec/archive/"
271 "luasec-" version ".tar.gz"))
274 "0pgd1anzznl4s0h16wg8dlw9mgdb9h52drlcki6sbf5y31fa7wyf"))))
275 (build-system gnu-build-system)
278 (let ((out (assoc-ref %outputs "out")))
282 (string-append "LUAPATH=" out "/share/lua/5.1")
283 (string-append "LUACPATH=" out "/lib/lua/5.1")))
284 #:tests? #f ; no tests included
286 (modify-phases %standard-phases
287 (delete 'configure))))
290 ("openssl" ,openssl)))
292 `(("lua-socket" ,lua5.1-socket)))
293 (home-page "https://github.com/brunoos/luasec/wiki")
294 (synopsis "OpenSSL bindings for Lua")
295 (description "LuaSec is a binding for OpenSSL library to provide TLS/SSL
296 communication. It takes an already established TCP connection and creates a
297 secure session between the peers.")
298 (license (package-license lua-5.1))))
300 (define-public lua-lgi
308 "https://github.com/pavouk/lgi/archive/"
310 (file-name (string-append name "-" version ".tar.gz"))
313 "0kwcaj3ahi9gxfyp0lr5zgr6vi1mgsg9sz0980x0nwxlh9a11i6g"))))
314 (build-system gnu-build-system)
316 '(#:make-flags (list "CC=gcc"
317 (string-append "PREFIX=" (assoc-ref %outputs "out")))
319 (modify-phases %standard-phases
320 (delete 'configure) ; no configure script
321 (add-before 'build 'set-env
322 (lambda* (#:key inputs #:allow-other-keys)
323 ;; we need to load cairo dynamically
324 (let* ((cairo (string-append
325 (assoc-ref inputs "cairo") "/lib" )))
326 (setenv "LD_LIBRARY_PATH" cairo)
328 (add-before 'build 'set-lua-version
330 ;; lua version and therefore install directories are hardcoded
331 ;; FIXME: This breaks when we update lua to >=5.3
332 (substitute* "./lgi/Makefile"
333 (("LUA_VERSION=5.1") "LUA_VERSION=5.2"))
335 (add-before 'check 'skip-test-gtk
337 ;; FIXME: Skip GTK tests:
338 ;; gtk3 - can't get it to run with the xorg-server config below
339 ;; and some non-gtk tests will also fail
340 ;; gtk2 - lots of functions aren't implemented
341 ;; We choose gtk2 as the lesser evil and simply skip the test.
342 ;; Currently, awesome is the only package that uses lua-lgi but
343 ;; it doesn't need or interact with GTK using lua-lgi.
344 (substitute* "./tests/test.lua"
345 (("'gtk.lua',") "-- 'gtk.lua',"))
347 (add-before 'check 'start-xserver-instance
348 (lambda* (#:key inputs #:allow-other-keys)
349 ;; There must be a running X server during tests.
350 (system (format #f "~a/bin/Xvfb :1 &"
351 (assoc-ref inputs "xorg-server")))
352 (setenv "DISPLAY" ":1")
355 `(("gobject-introspection" ,gobject-introspection)
362 ("xorg-server" ,xorg-server)))
364 `(("pkg-config" ,pkg-config)
365 ("dbus" ,dbus))) ;tests use 'dbus-run-session'
366 (home-page "https://github.com/pavouk/lgi/")
367 (synopsis "Lua bridge to GObject based libraries")
369 "LGI is gobject-introspection based dynamic Lua binding to GObject
370 based libraries. It allows using GObject-based libraries directly from Lua.
371 Notable examples are GTK+, GStreamer and Webkit.")
372 (license license:expat)))
374 (define (make-lua-lpeg name lua)
380 (uri (string-append "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-"
383 (base32 "0sq25z3r324a324ky73izgq9mbf66j2xvjp0fxf227rwxalzgnb2"))))
384 (build-system gnu-build-system)
387 (modify-phases %standard-phases
389 ;; `make install` isn't available, so we have to do it manually
391 (lambda* (#:key outputs #:allow-other-keys)
392 (let ((out (assoc-ref outputs "out"))
393 (lua-version ,(version-major+minor (package-version lua))))
394 (install-file "lpeg.so"
395 (string-append out "/lib/lua/" lua-version))
396 (install-file "re.lua"
397 (string-append out "/share/lua/" lua-version))
399 #:test-target "test"))
400 (inputs `(("lua" ,lua)))
401 (synopsis "Pattern-matching library for Lua")
403 "LPeg is a pattern-matching library for Lua, based on Parsing Expression
405 (home-page "http://www.inf.puc-rio.br/~roberto/lpeg")
406 (license license:expat)))
408 (define-public lua-lpeg
409 (make-lua-lpeg "lua-lpeg" lua))
411 (define-public lua5.2-lpeg
412 (make-lua-lpeg "lua5.2-lpeg" lua-5.2))
414 ;; Lua 5.3 is not supported.
415 (define (make-lua-bitop name lua)
421 (uri (string-append "http://bitop.luajit.org/download/"
422 "LuaBitOp-" version ".tar.gz"))
425 "16fffbrgfcw40kskh2bn9q7m3gajffwd2f35rafynlnd7llwj1qj"))))
426 (build-system gnu-build-system)
428 `(#:test-target "test"
430 (list "INSTALL=install -pD"
431 (string-append "INSTALLPATH=printf "
432 (assoc-ref %outputs "out")
434 ,(version-major+minor (package-version lua))
437 (modify-phases %standard-phases
438 (delete 'configure))))
439 (inputs `(("lua" ,lua)))
440 (home-page "https://bitop.luajit.org/index.html")
441 (synopsis "Bitwise operations on numbers for Lua")
443 "Lua BitOp is a C extension module for Lua which adds bitwise operations
445 (license license:expat)))
447 (define-public lua5.2-bitop
448 (make-lua-bitop "lua5.2-bitop" lua-5.2))
450 (define-public lua5.1-bitop
451 (make-lua-bitop "lua5.1-bitop" lua-5.1))
453 (define-public selene
456 (version "2017.08.25")
460 (url "https://github.com/jeremyong/Selene.git")
461 ;; The release is quite old.
462 (commit "ffe1ade2568d4cff5894552be8f43e63e379a4c9")))
466 "1axrgv3rxxdsaf807lwvklfzicn6x6gpf35narllrnz9lg6hn508"))))
467 (build-system cmake-build-system)
470 ;; lua pc file in CMakeLists.txt is lua5.3.pc
471 '("-DLUA_PC_CFG=lua;lua-5.3;lua-5.1")
474 ;; This is a header only library
475 (modify-phases %standard-phases
478 (lambda* (#:key inputs outputs #:allow-other-keys)
479 (let* ((output (assoc-ref outputs "out"))
480 (source (assoc-ref inputs "source"))
481 (includedir (string-append output "/include")))
483 (string-append source "/include")
486 ;; The path of test files are hard coded.
488 (lambda* (#:key inputs outputs #:allow-other-keys)
489 (let* ((output (assoc-ref outputs "out"))
490 (source (assoc-ref inputs "source"))
492 (testdir (string-append builddir "/test")))
493 (copy-recursively (string-append source "/test") testdir)
496 (copy-file "./test_runner" "./runner/test_runner")
498 (invoke "./test_runner")))))))
501 ("pkg-config" ,pkg-config)))
502 (home-page "https://github.com/jeremyong/Selene")
503 (synopsis "Lua C++11 bindings")
505 "Selene is a simple C++11 header-only library enabling seamless
506 interoperability between C++ and Lua programming language.")
507 (license license:zlib)))