lua.scm 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  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>
  11. ;;;
  12. ;;; This file is part of GNU Guix.
  13. ;;;
  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.
  18. ;;;
  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.
  23. ;;;
  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/>.
  26. (define-module (gnu packages lua)
  27. #:use-module ((guix licenses) #:prefix license:)
  28. #:use-module (guix packages)
  29. #:use-module (guix download)
  30. #:use-module (guix utils)
  31. #:use-module (guix build-system gnu)
  32. #:use-module (gnu packages)
  33. #:use-module (gnu packages readline)
  34. #:use-module (gnu packages tls)
  35. #:use-module (gnu packages xml)
  36. #:use-module (gnu packages glib)
  37. #:use-module (gnu packages libffi)
  38. #:use-module (gnu packages pkg-config)
  39. #:use-module (gnu packages xorg)
  40. #:use-module (gnu packages gtk))
  41. (define-public lua
  42. (package
  43. (name "lua")
  44. (version "5.3.4")
  45. (source (origin
  46. (method url-fetch)
  47. (uri (string-append "https://www.lua.org/ftp/lua-"
  48. version ".tar.gz"))
  49. (sha256
  50. (base32 "0320a8dg3aci4hxla380dx1ifkw8gj4gbw5c4dz41g1kh98sm0gn"))
  51. (patches (search-patches "lua-pkgconfig.patch"
  52. "lua-liblua-so.patch"))))
  53. (build-system gnu-build-system)
  54. (inputs `(("readline" ,readline)))
  55. (arguments
  56. '(#:modules ((guix build gnu-build-system)
  57. (guix build utils)
  58. (srfi srfi-1))
  59. #:test-target "test"
  60. #:make-flags
  61. '("MYCFLAGS=-fPIC -DLUA_DL_DLOPEN"
  62. "linux")
  63. #:phases
  64. (modify-phases %standard-phases
  65. (delete 'configure)
  66. (replace 'install
  67. (lambda* (#:key outputs #:allow-other-keys)
  68. (let ((out (assoc-ref outputs "out")))
  69. (zero? (system* "make" "install"
  70. (string-append "INSTALL_TOP=" out)
  71. (string-append "INSTALL_MAN=" out
  72. "/share/man/man1")))))))))
  73. (home-page "https://www.lua.org/")
  74. (synopsis "Embeddable scripting language")
  75. (description
  76. "Lua is a powerful, fast, lightweight, embeddable scripting language. Lua
  77. combines simple procedural syntax with powerful data description constructs
  78. based on associative arrays and extensible semantics. Lua is dynamically typed,
  79. runs by interpreting bytecode for a register-based virtual machine, and has
  80. automatic memory management with incremental garbage collection, making it ideal
  81. for configuration, scripting, and rapid prototyping.")
  82. (license license:x11)))
  83. (define-public lua-5.2
  84. (package (inherit lua)
  85. (version "5.2.4")
  86. (source
  87. (origin
  88. (method url-fetch)
  89. (uri (string-append "https://www.lua.org/ftp/lua-"
  90. version ".tar.gz"))
  91. (sha256
  92. (base32 "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr"))
  93. (patches (search-patches "lua-pkgconfig.patch"
  94. "lua-liblua-so.patch"))))))
  95. (define-public lua-5.1
  96. (package (inherit lua)
  97. (version "5.1.5")
  98. (source (origin
  99. (method url-fetch)
  100. (uri (string-append "https://www.lua.org/ftp/lua-"
  101. version ".tar.gz"))
  102. (sha256
  103. (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))
  104. (patches (search-patches "lua51-liblua-so.patch"
  105. "lua-CVE-2014-5461.patch"
  106. "lua51-pkgconfig.patch"))))))
  107. (define-public luajit
  108. (package
  109. (name "luajit")
  110. (version "2.1.0-beta2")
  111. (source (origin
  112. (method url-fetch)
  113. (uri (string-append "http://luajit.org/download/LuaJIT-"
  114. version ".tar.gz"))
  115. (sha256
  116. (base32 "0iyghj1xjlmd9ywa4flf9yszynf3jhbp0yqb9b49k7ab0g528fbi"))
  117. (patches (search-patches "luajit-symlinks.patch"
  118. "luajit-no_ldconfig.patch"))))
  119. (build-system gnu-build-system)
  120. (arguments
  121. '(#:tests? #f ;luajit is distributed without tests
  122. #:phases (alist-delete 'configure %standard-phases)
  123. #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))))
  124. (home-page "http://www.luajit.org/")
  125. (synopsis "Just in time compiler for Lua programming language version 5.1")
  126. (description
  127. "LuaJIT is a Just-In-Time Compiler (JIT) for the Lua
  128. programming language. Lua is a powerful, dynamic and light-weight programming
  129. language. It may be embedded or used as a general-purpose, stand-alone
  130. language.")
  131. (license license:x11)))
  132. (define-public lua5.1-expat
  133. (package
  134. (name "lua5.1-expat")
  135. (version "1.3.0")
  136. (source (origin
  137. (method url-fetch)
  138. (uri (string-append "https://matthewwild.co.uk/projects/"
  139. "luaexpat/luaexpat-" version ".tar.gz"))
  140. (sha256
  141. (base32
  142. "1hvxqngn0wf5642i5p3vcyhg3pmp102k63s9ry4jqyyqc1wkjq6h"))))
  143. (build-system gnu-build-system)
  144. (arguments
  145. `(#:make-flags
  146. (let ((out (assoc-ref %outputs "out")))
  147. (list "CC=gcc"
  148. (string-append "LUA_LDIR=" out "/share/lua/$(LUA_V)")
  149. (string-append "LUA_CDIR=" out "/lib/lua/$(LUA_V)")))
  150. #:phases
  151. (modify-phases %standard-phases
  152. (delete 'configure)
  153. (replace 'check
  154. (lambda _
  155. (setenv "LUA_CPATH" "src/?.so;;")
  156. (setenv "LUA_PATH" "src/?.lua;;")
  157. (and (zero? (system* "lua" "tests/test.lua"))
  158. (zero? (system* "lua" "tests/test-lom.lua"))))))))
  159. (inputs
  160. `(("lua" ,lua-5.1)
  161. ("expat" ,expat)))
  162. (home-page "http://matthewwild.co.uk/projects/luaexpat/")
  163. (synopsis "SAX XML parser based on the Expat library")
  164. (description "LuaExpat is a SAX XML parser based on the Expat library.")
  165. (license (package-license lua-5.1))))
  166. (define-public lua5.1-socket
  167. (package
  168. (name "lua5.1-socket")
  169. (version "2.0.2")
  170. (source (origin
  171. (method url-fetch)
  172. (uri (string-append "http://files.luaforge.net/releases/"
  173. "luasocket/luasocket/luasocket-"
  174. version "/luasocket-" version ".tar.gz"))
  175. (sha256
  176. (base32
  177. "19ichkbc4rxv00ggz8gyf29jibvc2wq9pqjik0ll326rrxswgnag"))))
  178. (build-system gnu-build-system)
  179. (arguments
  180. `(#:make-flags
  181. (let ((out (assoc-ref %outputs "out")))
  182. (list (string-append "INSTALL_TOP_SHARE=" out "/share/lua/5.1")
  183. (string-append "INSTALL_TOP_LIB=" out "/lib/lua/5.1")))
  184. #:phases
  185. (modify-phases %standard-phases
  186. (delete 'configure)
  187. (replace 'check
  188. (lambda _
  189. (setenv "LUA_CPATH" (string-append "src/?.so." ,version ";;"))
  190. (setenv "LUA_PATH" "src/?.lua;;")
  191. (when (zero? (primitive-fork))
  192. (system* "lua" "test/testsrvr.lua"))
  193. (zero? (system* "lua" "test/testclnt.lua")))))))
  194. (inputs
  195. `(("lua" ,lua-5.1)))
  196. (home-page "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/")
  197. (synopsis "Socket library for Lua")
  198. (description "LuaSocket is a Lua extension library that is composed by two
  199. parts: a C core that provides support for the TCP and UDP transport layers,
  200. and a set of Lua modules that add support for functionality commonly needed by
  201. applications that deal with the Internet.
  202. Among the supported modules, the most commonly used implement the
  203. SMTP (sending e-mails), HTTP (WWW access) and FTP (uploading and downloading
  204. files) client protocols. These provide a very natural and generic interface
  205. to the functionality defined by each protocol. In addition, you will find
  206. that the MIME (common encodings), URL (anything you could possible want to do
  207. with one) and LTN12 (filters, sinks, sources and pumps) modules can be very
  208. handy.")
  209. (license (package-license lua-5.1))))
  210. (define-public lua5.1-filesystem
  211. (package
  212. (name "lua5.1-filesystem")
  213. (version "1.6.3")
  214. (source (origin
  215. (method url-fetch)
  216. (uri (string-append "https://github.com/keplerproject/"
  217. "luafilesystem/archive/v_"
  218. "1_6_3" ".tar.gz"))
  219. (file-name (string-append name "-" version ".tar.gz"))
  220. (sha256
  221. (base32
  222. "0s10ckxin0bysd6gaywqhxkpw3ybjhprr8m655b8cx3pxjwd49am"))))
  223. (build-system gnu-build-system)
  224. (arguments
  225. `(#:make-flags
  226. (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
  227. #:test-target "test"
  228. #:phases
  229. (modify-phases %standard-phases
  230. (delete 'configure))))
  231. (inputs
  232. `(("lua" ,lua-5.1)))
  233. (home-page "https://keplerproject.github.io/luafilesystem/index.html")
  234. (synopsis "File system library for Lua")
  235. (description "LuaFileSystem is a Lua library developed to complement the
  236. set of functions related to file systems offered by the standard Lua
  237. distribution. LuaFileSystem offers a portable way to access the underlying
  238. directory structure and file attributes.")
  239. (license (package-license lua-5.1))))
  240. (define-public lua5.1-sec
  241. (package
  242. (name "lua5.1-sec")
  243. (version "0.6")
  244. (source (origin
  245. (method url-fetch)
  246. (uri (string-append "https://github.com/brunoos/luasec/archive/"
  247. "luasec-" version ".tar.gz"))
  248. (sha256
  249. (base32
  250. "0pgd1anzznl4s0h16wg8dlw9mgdb9h52drlcki6sbf5y31fa7wyf"))))
  251. (build-system gnu-build-system)
  252. (arguments
  253. `(#:make-flags
  254. (let ((out (assoc-ref %outputs "out")))
  255. (list "linux"
  256. "CC=gcc"
  257. "LD=gcc"
  258. (string-append "LUAPATH=" out "/share/lua/5.1")
  259. (string-append "LUACPATH=" out "/lib/lua/5.1")))
  260. #:tests? #f ; no tests included
  261. #:phases
  262. (modify-phases %standard-phases
  263. (delete 'configure))))
  264. (inputs
  265. `(("lua" ,lua-5.1)
  266. ("openssl" ,openssl)))
  267. (propagated-inputs
  268. `(("lua-socket" ,lua5.1-socket)))
  269. (home-page "https://github.com/brunoos/luasec/wiki")
  270. (synopsis "OpenSSL bindings for Lua")
  271. (description "LuaSec is a binding for OpenSSL library to provide TLS/SSL
  272. communication. It takes an already established TCP connection and creates a
  273. secure session between the peers.")
  274. (license (package-license lua-5.1))))
  275. (define-public lua-lgi
  276. (package
  277. (name "lua-lgi")
  278. (version "0.9.1")
  279. (source
  280. (origin
  281. (method url-fetch)
  282. (uri (string-append
  283. "https://github.com/pavouk/lgi/archive/"
  284. version ".tar.gz"))
  285. (file-name (string-append name "-" version ".tar.gz"))
  286. (sha256
  287. (base32
  288. "1fmgdl5y4ph3yc6ycg865s3vai1rjkyda61cgqxk6zd13hmznw0c"))))
  289. (build-system gnu-build-system)
  290. (arguments
  291. '(#:make-flags (list "CC=gcc"
  292. (string-append "PREFIX=" (assoc-ref %outputs "out")))
  293. #:phases
  294. (modify-phases %standard-phases
  295. (delete 'configure) ; no configure script
  296. (add-before 'build 'set-env
  297. (lambda* (#:key inputs #:allow-other-keys)
  298. ;; we need to load cairo dynamically
  299. (let* ((cairo (string-append
  300. (assoc-ref inputs "cairo") "/lib" )))
  301. (setenv "LD_LIBRARY_PATH" cairo)
  302. #t)))
  303. (add-before 'build 'set-lua-version
  304. (lambda _
  305. ;; lua version and therefore install directories are hardcoded
  306. ;; FIXME: This breaks when we update lua to >=5.3
  307. (substitute* "./lgi/Makefile"
  308. (("LUA_VERSION=5.1") "LUA_VERSION=5.2"))
  309. #t))
  310. (add-before 'check 'skip-test-gtk
  311. (lambda _
  312. ;; FIXME: Skip GTK tests:
  313. ;; gtk3 - can't get it to run with the xorg-server config below
  314. ;; and some non-gtk tests will also fail
  315. ;; gtk2 - lots of functions aren't implemented
  316. ;; We choose gtk2 as the lesser evil and simply skip the test.
  317. ;; Currently, awesome is the only package that uses lua-lgi but
  318. ;; it doesn't need or interact with GTK using lua-lgi.
  319. (substitute* "./tests/test.lua"
  320. (("'gtk.lua',") "-- 'gtk.lua',"))
  321. #t))
  322. (add-before 'check 'start-xserver-instance
  323. (lambda* (#:key inputs #:allow-other-keys)
  324. ;; There must be a running X server during tests.
  325. (system (format #f "~a/bin/Xvfb :1 &"
  326. (assoc-ref inputs "xorg-server")))
  327. (setenv "DISPLAY" ":1")
  328. #t)))))
  329. (inputs
  330. `(("gobject-introspection" ,gobject-introspection)
  331. ("glib" ,glib)
  332. ("pango", pango)
  333. ("gtk", gtk+-2)
  334. ("lua" ,lua)
  335. ("cairo" ,cairo)
  336. ("libffi" ,libffi)
  337. ("xorg-server", xorg-server)))
  338. (native-inputs
  339. `(("pkg-config" ,pkg-config)))
  340. (home-page "https://github.com/pavouk/lgi/")
  341. (synopsis "Lua bridge to GObject based libraries")
  342. (description
  343. "LGI is gobject-introspection based dynamic Lua binding to GObject
  344. based libraries. It allows using GObject-based libraries directly from Lua.
  345. Notable examples are GTK+, GStreamer and Webkit.")
  346. (license license:expat)))
  347. (define-public lua-lpeg
  348. (package
  349. (name "lua-lpeg")
  350. (version "1.0.1")
  351. (source (origin
  352. (method url-fetch)
  353. (uri (string-append "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-"
  354. version ".tar.gz"))
  355. (sha256
  356. (base32 "0sq25z3r324a324ky73izgq9mbf66j2xvjp0fxf227rwxalzgnb2"))))
  357. (build-system gnu-build-system)
  358. (arguments
  359. `(#:phases
  360. (modify-phases %standard-phases
  361. (delete 'configure)
  362. ;; `make install` isn't available, so we have to do it manually
  363. (replace 'install
  364. (lambda* (#:key outputs #:allow-other-keys)
  365. (let ((out (assoc-ref outputs "out"))
  366. (lua-version ,(version-major+minor (package-version lua))))
  367. (install-file "lpeg.so"
  368. (string-append out "/lib/lua/" lua-version))
  369. (install-file "re.lua"
  370. (string-append out "/share/lua/" lua-version))
  371. #t))))
  372. #:test-target "test"))
  373. (inputs `(("lua", lua)))
  374. (synopsis "Pattern-matching library for Lua")
  375. (description
  376. "LPeg is a pattern-matching library for Lua, based on Parsing Expression
  377. Grammars (PEGs).")
  378. (home-page "http://www.inf.puc-rio.br/~roberto/lpeg")
  379. (license license:expat)))
  380. (define-public lua5.2-lpeg
  381. (package (inherit lua-lpeg)
  382. (name "lua5.2-lpeg")
  383. ;; XXX: The arguments field is almost an exact copy of the field in
  384. ;; "lua-lpeg", except for the version string, which was derived from "lua"
  385. ;; and now is taken from "lua-5.2". See this discussion for context:
  386. ;; http://lists.gnu.org/archive/html/guix-devel/2017-01/msg02048.html
  387. (arguments
  388. `(#:phases
  389. (modify-phases %standard-phases
  390. (delete 'configure)
  391. ;; `make install` isn't available, so we have to do it manually
  392. (replace 'install
  393. (lambda* (#:key outputs #:allow-other-keys)
  394. (let ((out (assoc-ref outputs "out"))
  395. (lua-version ,(version-major+minor (package-version lua-5.2))))
  396. (install-file "lpeg.so"
  397. (string-append out "/lib/lua/" lua-version))
  398. (install-file "re.lua"
  399. (string-append out "/share/lua/" lua-version))
  400. #t))))
  401. #:test-target "test"))
  402. (inputs `(("lua", lua-5.2)))))
  403. ;; Lua 5.3 is not supported.
  404. (define-public lua5.2-bitop
  405. (package
  406. (name "lua5.2-bitop")
  407. (version "1.0.2")
  408. (source (origin
  409. (method url-fetch)
  410. (uri (string-append "http://bitop.luajit.org/download/"
  411. "LuaBitOp-" version ".tar.gz"))
  412. (sha256
  413. (base32
  414. "16fffbrgfcw40kskh2bn9q7m3gajffwd2f35rafynlnd7llwj1qj"))))
  415. (build-system gnu-build-system)
  416. (arguments
  417. `(#:test-target "test"
  418. #:make-flags
  419. (list "INSTALL=install -pD"
  420. (string-append "INSTALLPATH=printf "
  421. (assoc-ref %outputs "out")
  422. "/lib/lua/"
  423. ,(version-major+minor (package-version lua-5.2))
  424. "/bit/bit.so"))
  425. #:phases
  426. (modify-phases %standard-phases
  427. (delete 'configure))))
  428. (inputs `(("lua", lua-5.2)))
  429. (home-page "http://bitop.luajit.org/index.html")
  430. (synopsis "Bitwise operations on numbers for Lua")
  431. (description
  432. "Lua BitOp is a C extension module for Lua which adds bitwise operations
  433. on numbers.")
  434. (license license:expat)))