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 Clément Lassieur <clement@lassieur.org>
10 ;;; Copyright © 2016 José Miguel Sánchez García <jmi2k@openmailbox.org>
12 ;;; This file is part of GNU Guix.
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27 (define-module (gnu packages lua)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (guix packages)
30 #:use-module (guix download)
31 #:use-module (guix utils)
32 #:use-module (guix build-system gnu)
33 #:use-module (gnu packages)
34 #:use-module (gnu packages readline)
35 #:use-module (gnu packages tls)
36 #:use-module (gnu packages xml)
37 #:use-module (gnu packages glib)
38 #:use-module (gnu packages libffi)
39 #:use-module (gnu packages pkg-config)
40 #:use-module (gnu packages xorg)
41 #:use-module (gnu packages gtk))
49 (uri (string-append "https://www.lua.org/ftp/lua-"
52 (base32 "0320a8dg3aci4hxla380dx1ifkw8gj4gbw5c4dz41g1kh98sm0gn"))
53 (patches (search-patches "lua-pkgconfig.patch"
54 "lua-liblua-so.patch"))))
55 (build-system gnu-build-system)
56 (inputs `(("readline" ,readline)))
58 '(#:modules ((guix build gnu-build-system)
63 '("MYCFLAGS=-fPIC -DLUA_DL_DLOPEN"
66 (modify-phases %standard-phases
69 (lambda* (#:key outputs #:allow-other-keys)
70 (let ((out (assoc-ref outputs "out")))
71 (zero? (system* "make" "install"
72 (string-append "INSTALL_TOP=" out)
73 (string-append "INSTALL_MAN=" out
74 "/share/man/man1")))))))))
75 (home-page "https://www.lua.org/")
76 (synopsis "Embeddable scripting language")
78 "Lua is a powerful, fast, lightweight, embeddable scripting language. Lua
79 combines simple procedural syntax with powerful data description constructs
80 based on associative arrays and extensible semantics. Lua is dynamically typed,
81 runs by interpreting bytecode for a register-based virtual machine, and has
82 automatic memory management with incremental garbage collection, making it ideal
83 for configuration, scripting, and rapid prototyping.")
84 (license license:x11)))
86 (define-public lua-5.2
87 (package (inherit lua)
92 (uri (string-append "https://www.lua.org/ftp/lua-"
95 (base32 "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr"))
96 (patches (search-patches "lua-pkgconfig.patch"
97 "lua-liblua-so.patch"))))))
99 (define-public lua-5.1
100 (package (inherit lua)
104 (uri (string-append "https://www.lua.org/ftp/lua-"
107 (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))
108 (patches (search-patches "lua51-liblua-so.patch"
109 "lua-CVE-2014-5461.patch"
110 "lua51-pkgconfig.patch"))))))
112 (define-public luajit
115 (version "2.1.0-beta2")
118 (uri (string-append "http://luajit.org/download/LuaJIT-"
121 (base32 "0iyghj1xjlmd9ywa4flf9yszynf3jhbp0yqb9b49k7ab0g528fbi"))
122 (patches (search-patches "luajit-symlinks.patch"
123 "luajit-no_ldconfig.patch"))))
124 (build-system gnu-build-system)
126 '(#:tests? #f ;luajit is distributed without tests
127 #:phases (modify-phases %standard-phases (delete 'configure))
128 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))))
129 (home-page "http://www.luajit.org/")
130 (synopsis "Just in time compiler for Lua programming language version 5.1")
132 "LuaJIT is a Just-In-Time Compiler (JIT) for the Lua
133 programming language. Lua is a powerful, dynamic and light-weight programming
134 language. It may be embedded or used as a general-purpose, stand-alone
136 (license license:x11)))
138 (define-public lua5.1-expat
140 (name "lua5.1-expat")
144 (uri (string-append "https://matthewwild.co.uk/projects/"
145 "luaexpat/luaexpat-" version ".tar.gz"))
148 "1hvxqngn0wf5642i5p3vcyhg3pmp102k63s9ry4jqyyqc1wkjq6h"))))
149 (build-system gnu-build-system)
152 (let ((out (assoc-ref %outputs "out")))
154 (string-append "LUA_LDIR=" out "/share/lua/$(LUA_V)")
155 (string-append "LUA_CDIR=" out "/lib/lua/$(LUA_V)")))
157 (modify-phases %standard-phases
161 (setenv "LUA_CPATH" "src/?.so;;")
162 (setenv "LUA_PATH" "src/?.lua;;")
163 (and (zero? (system* "lua" "tests/test.lua"))
164 (zero? (system* "lua" "tests/test-lom.lua"))))))))
168 (home-page "http://matthewwild.co.uk/projects/luaexpat/")
169 (synopsis "SAX XML parser based on the Expat library")
170 (description "LuaExpat is a SAX XML parser based on the Expat library.")
171 (license (package-license lua-5.1))))
173 (define-public lua5.1-socket
175 (name "lua5.1-socket")
179 (uri (string-append "http://files.luaforge.net/releases/"
180 "luasocket/luasocket/luasocket-"
181 version "/luasocket-" version ".tar.gz"))
184 "19ichkbc4rxv00ggz8gyf29jibvc2wq9pqjik0ll326rrxswgnag"))))
185 (build-system gnu-build-system)
188 (let ((out (assoc-ref %outputs "out")))
189 (list (string-append "INSTALL_TOP_SHARE=" out "/share/lua/5.1")
190 (string-append "INSTALL_TOP_LIB=" out "/lib/lua/5.1")))
192 (modify-phases %standard-phases
196 (setenv "LUA_CPATH" (string-append "src/?.so." ,version ";;"))
197 (setenv "LUA_PATH" "src/?.lua;;")
198 (when (zero? (primitive-fork))
199 (system* "lua" "test/testsrvr.lua"))
200 (zero? (system* "lua" "test/testclnt.lua")))))))
203 (home-page "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/")
204 (synopsis "Socket library for Lua")
205 (description "LuaSocket is a Lua extension library that is composed by two
206 parts: a C core that provides support for the TCP and UDP transport layers,
207 and a set of Lua modules that add support for functionality commonly needed by
208 applications that deal with the Internet.
210 Among the supported modules, the most commonly used implement the
211 SMTP (sending e-mails), HTTP (WWW access) and FTP (uploading and downloading
212 files) client protocols. These provide a very natural and generic interface
213 to the functionality defined by each protocol. In addition, you will find
214 that the MIME (common encodings), URL (anything you could possible want to do
215 with one) and LTN12 (filters, sinks, sources and pumps) modules can be very
217 (license (package-license lua-5.1))))
219 (define-public lua5.1-filesystem
221 (name "lua5.1-filesystem")
225 (uri (string-append "https://github.com/keplerproject/"
226 "luafilesystem/archive/v_"
228 (file-name (string-append name "-" version ".tar.gz"))
231 "0s10ckxin0bysd6gaywqhxkpw3ybjhprr8m655b8cx3pxjwd49am"))))
232 (build-system gnu-build-system)
235 (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
238 (modify-phases %standard-phases
239 (delete 'configure))))
242 (home-page "https://keplerproject.github.io/luafilesystem/index.html")
243 (synopsis "File system library for Lua")
244 (description "LuaFileSystem is a Lua library developed to complement the
245 set of functions related to file systems offered by the standard Lua
246 distribution. LuaFileSystem offers a portable way to access the underlying
247 directory structure and file attributes.")
248 (license (package-license lua-5.1))))
250 (define-public lua5.1-sec
256 (uri (string-append "https://github.com/brunoos/luasec/archive/"
257 "luasec-" version ".tar.gz"))
260 "0pgd1anzznl4s0h16wg8dlw9mgdb9h52drlcki6sbf5y31fa7wyf"))))
261 (build-system gnu-build-system)
264 (let ((out (assoc-ref %outputs "out")))
268 (string-append "LUAPATH=" out "/share/lua/5.1")
269 (string-append "LUACPATH=" out "/lib/lua/5.1")))
270 #:tests? #f ; no tests included
272 (modify-phases %standard-phases
273 (delete 'configure))))
276 ("openssl" ,openssl)))
278 `(("lua-socket" ,lua5.1-socket)))
279 (home-page "https://github.com/brunoos/luasec/wiki")
280 (synopsis "OpenSSL bindings for Lua")
281 (description "LuaSec is a binding for OpenSSL library to provide TLS/SSL
282 communication. It takes an already established TCP connection and creates a
283 secure session between the peers.")
284 (license (package-license lua-5.1))))
286 (define-public lua-lgi
294 "https://github.com/pavouk/lgi/archive/"
296 (file-name (string-append name "-" version ".tar.gz"))
299 "1fmgdl5y4ph3yc6ycg865s3vai1rjkyda61cgqxk6zd13hmznw0c"))))
300 (build-system gnu-build-system)
302 '(#:make-flags (list "CC=gcc"
303 (string-append "PREFIX=" (assoc-ref %outputs "out")))
305 (modify-phases %standard-phases
306 (delete 'configure) ; no configure script
307 (add-before 'build 'set-env
308 (lambda* (#:key inputs #:allow-other-keys)
309 ;; we need to load cairo dynamically
310 (let* ((cairo (string-append
311 (assoc-ref inputs "cairo") "/lib" )))
312 (setenv "LD_LIBRARY_PATH" cairo)
314 (add-before 'build 'set-lua-version
316 ;; lua version and therefore install directories are hardcoded
317 ;; FIXME: This breaks when we update lua to >=5.3
318 (substitute* "./lgi/Makefile"
319 (("LUA_VERSION=5.1") "LUA_VERSION=5.2"))
321 (add-before 'check 'skip-test-gtk
323 ;; FIXME: Skip GTK tests:
324 ;; gtk3 - can't get it to run with the xorg-server config below
325 ;; and some non-gtk tests will also fail
326 ;; gtk2 - lots of functions aren't implemented
327 ;; We choose gtk2 as the lesser evil and simply skip the test.
328 ;; Currently, awesome is the only package that uses lua-lgi but
329 ;; it doesn't need or interact with GTK using lua-lgi.
330 (substitute* "./tests/test.lua"
331 (("'gtk.lua',") "-- 'gtk.lua',"))
333 (add-before 'check 'start-xserver-instance
334 (lambda* (#:key inputs #:allow-other-keys)
335 ;; There must be a running X server during tests.
336 (system (format #f "~a/bin/Xvfb :1 &"
337 (assoc-ref inputs "xorg-server")))
338 (setenv "DISPLAY" ":1")
341 `(("gobject-introspection" ,gobject-introspection)
348 ("xorg-server", xorg-server)))
350 `(("pkg-config" ,pkg-config)))
351 (home-page "https://github.com/pavouk/lgi/")
352 (synopsis "Lua bridge to GObject based libraries")
354 "LGI is gobject-introspection based dynamic Lua binding to GObject
355 based libraries. It allows using GObject-based libraries directly from Lua.
356 Notable examples are GTK+, GStreamer and Webkit.")
357 (license license:expat)))
359 (define-public lua-lpeg
365 (uri (string-append "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-"
368 (base32 "0sq25z3r324a324ky73izgq9mbf66j2xvjp0fxf227rwxalzgnb2"))))
369 (build-system gnu-build-system)
372 (modify-phases %standard-phases
374 ;; `make install` isn't available, so we have to do it manually
376 (lambda* (#:key outputs #:allow-other-keys)
377 (let ((out (assoc-ref outputs "out"))
378 (lua-version ,(version-major+minor (package-version lua))))
379 (install-file "lpeg.so"
380 (string-append out "/lib/lua/" lua-version))
381 (install-file "re.lua"
382 (string-append out "/share/lua/" lua-version))
384 #:test-target "test"))
385 (inputs `(("lua", lua)))
386 (synopsis "Pattern-matching library for Lua")
388 "LPeg is a pattern-matching library for Lua, based on Parsing Expression
390 (home-page "http://www.inf.puc-rio.br/~roberto/lpeg")
391 (license license:expat)))
393 (define-public lua5.2-lpeg
394 (package (inherit lua-lpeg)
396 ;; XXX: The arguments field is almost an exact copy of the field in
397 ;; "lua-lpeg", except for the version string, which was derived from "lua"
398 ;; and now is taken from "lua-5.2". See this discussion for context:
399 ;; http://lists.gnu.org/archive/html/guix-devel/2017-01/msg02048.html
402 (modify-phases %standard-phases
404 ;; `make install` isn't available, so we have to do it manually
406 (lambda* (#:key outputs #:allow-other-keys)
407 (let ((out (assoc-ref outputs "out"))
408 (lua-version ,(version-major+minor (package-version lua-5.2))))
409 (install-file "lpeg.so"
410 (string-append out "/lib/lua/" lua-version))
411 (install-file "re.lua"
412 (string-append out "/share/lua/" lua-version))
414 #:test-target "test"))
415 (inputs `(("lua", lua-5.2)))))
417 ;; Lua 5.3 is not supported.
418 (define-public lua5.2-bitop
420 (name "lua5.2-bitop")
424 (uri (string-append "http://bitop.luajit.org/download/"
425 "LuaBitOp-" version ".tar.gz"))
428 "16fffbrgfcw40kskh2bn9q7m3gajffwd2f35rafynlnd7llwj1qj"))))
429 (build-system gnu-build-system)
431 `(#:test-target "test"
433 (list "INSTALL=install -pD"
434 (string-append "INSTALLPATH=printf "
435 (assoc-ref %outputs "out")
437 ,(version-major+minor (package-version lua-5.2))
440 (modify-phases %standard-phases
441 (delete 'configure))))
442 (inputs `(("lua", lua-5.2)))
443 (home-page "http://bitop.luajit.org/index.html")
444 (synopsis "Bitwise operations on numbers for Lua")
446 "Lua BitOp is a C extension module for Lua which adds bitwise operations
448 (license license:expat)))