projects/guix·blob beam-team · refs

2316 lines · 95.8 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013 Cyril Roelandt <[email protected]>
3;;; Copyright © 2014 Raimon Grau <[email protected]>
4;;; Copyright © 2014 Mark H Weaver <[email protected]>
5;;; Copyright © 2014 Andreas Enge <[email protected]>
6;;; Copyright © 2016, 2017, 2020-2022 Efraim Flashner <[email protected]>
7;;; Copyright © 2016, 2019, 2024 Ricardo Wurmus <[email protected]>
8;;; Copyright © 2016 doncatnip <[email protected]>
9;;; Copyright © 2016, 2017, 2019 Clément Lassieur <[email protected]>
10;;; Copyright © 2016 José Miguel Sánchez García <[email protected]>
11;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <[email protected]>
12;;; Copyright © 2018 Fis Trivial <[email protected]>
13;;; Copyright © 2020 Nicolas Goaziou <[email protected]>
14;;; Copyright © 2020 Simon South <[email protected]>
15;;; Copyright © 2020 Paul A. Patience <[email protected]>
16;;; Copyright © 2021 Vinícius dos Santos Oliveira <[email protected]>
17;;; Copyright © 2021 Greg Hogan <[email protected]>
18;;; Copyright © 2022 Brandon Lucas <[email protected]>
19;;; Copyright © 2022 Luis Henrique Gomes Higino <[email protected]>
20;;; Copyright © 2022 Leo Nikkilä <[email protected]>
21;;; Copyright © 2023 Yovan Naumovski <[email protected]>
22;;; Copyright © 2023 Valter Nazianzeno <[email protected]>
23;;; Copyright © 2023 Timo Wilken <[email protected]>
24;;; Copyright © 2024 Jan Wielkiewicz <[email protected]>
25;;; Copyright © 2024, 2026 Maxim Cournoyer <[email protected]>
26;;; Copyright © 2025 Zheng Junjie <[email protected]>
27;;; Copyright © 2025 Ashish SHUKLA <[email protected]>
28;;; Copyright © 2025 Aaron Boyd <[email protected]>
29;;; Copyright © 2026 Nguyễn Gia Phong <[email protected]>
30;;;
31;;; This file is part of GNU Guix.
32;;;
33;;; GNU Guix is free software; you can redistribute it and/or modify it
34;;; under the terms of the GNU General Public License as published by
35;;; the Free Software Foundation; either version 3 of the License, or (at
36;;; your option) any later version.
37;;;
38;;; GNU Guix is distributed in the hope that it will be useful, but
39;;; WITHOUT ANY WARRANTY; without even the implied warranty of
40;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41;;; GNU General Public License for more details.
42;;;
43;;; You should have received a copy of the GNU General Public License
44;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
45
46(define-module (gnu packages lua)
47 #:use-module ((guix licenses) #:prefix license:)
48 #:use-module (guix packages)
49 #:use-module (guix download)
50 #:use-module (guix git-download)
51 #:use-module (guix gexp)
52 #:use-module (guix hg-download)
53 #:use-module (guix utils)
54 #:use-module (guix build-system gnu)
55 #:use-module (guix build-system cmake)
56 #:use-module (guix build-system meson)
57 #:use-module (guix build-system trivial)
58 #:use-module (gnu packages)
59 #:use-module (gnu packages autotools)
60 #:use-module (gnu packages base)
61 #:use-module (gnu packages bash)
62 #:use-module (gnu packages boost)
63 #:use-module (gnu packages curl)
64 #:use-module (gnu packages build-tools)
65 #:use-module (gnu packages check)
66 #:use-module (gnu packages compression)
67 #:use-module (gnu packages dns)
68 #:use-module (gnu packages gcc)
69 #:use-module (gnu packages glib)
70 #:use-module (gnu packages gperf)
71 #:use-module (gnu packages gnupg)
72 #:use-module (gnu packages gtk)
73 #:use-module (gnu packages haskell-xyz)
74 #:use-module (gnu packages libevent)
75 #:use-module (gnu packages libffi)
76 #:use-module (gnu packages linux)
77 #:use-module (gnu packages m4)
78 #:use-module (gnu packages ncurses)
79 #:use-module (gnu packages pkg-config)
80 #:use-module (gnu packages pretty-print)
81 #:use-module (gnu packages rdf)
82 #:use-module (gnu packages compiler-tools)
83 #:use-module (gnu packages readline)
84 #:use-module (gnu packages rsync)
85 #:use-module (gnu packages ssh)
86 #:use-module (gnu packages sqlite)
87 #:use-module (gnu packages tls)
88 #:use-module (gnu packages version-control)
89 #:use-module (gnu packages vim)
90 #:use-module (gnu packages wget)
91 #:use-module (gnu packages xml)
92 #:use-module (gnu packages xorg)
93 #:use-module (ice-9 match)
94 #:use-module ((srfi srfi-1) #:hide (zip)))
95
96(define (lua-search-paths version)
97 (list (search-path-specification
98 (variable "GUIX_LUA_PATH")
99 (separator ";")
100 (files (list (string-append "share/lua/" version))))
101 (search-path-specification
102 (variable "GUIX_LUA_CPATH")
103 (separator ";")
104 (files (list (string-append "lib/lua/" version))))))
105
106(define-public lua-5.3
107 (package
108 (name "lua")
109 (version "5.3.5")
110 (source (origin
111 (method url-fetch)
112 (uri (string-append "https://www.lua.org/ftp/lua-"
113 version ".tar.gz"))
114 (sha256
115 (base32 "1b2qn2rv96nmbm6zab4l877bd4zq7wpwm8drwjiy2ih4jqzysbhc"))
116 (patches (search-patches "lua-pkgconfig.patch"
117 "lua-liblua-so.patch"
118 "lua-5.x-search-path-helpers.patch"
119 "lua-5.3-search-paths.patch"))))
120 (build-system gnu-build-system)
121 (inputs (list readline))
122 (arguments
123 `(#:modules ((guix build gnu-build-system)
124 (guix build utils)
125 (srfi srfi-1))
126 #:test-target "test"
127 #:make-flags
128 (list "MYCFLAGS=-fPIC -DLUA_DL_DLOPEN"
129 (string-append "CC=" ,(cc-for-target))
130 (string-append "SYSLIBS=-L" (assoc-ref %build-inputs "readline")
131 "/lib")
132 "linux")
133 #:phases
134 (modify-phases %standard-phases
135 (delete 'configure)
136 (replace 'install
137 (lambda* (#:key outputs #:allow-other-keys)
138 (let ((out (assoc-ref outputs "out")))
139 (invoke "make" "install"
140 (string-append "INSTALL_TOP=" out)
141 (string-append "INSTALL_MAN=" out
142 "/share/man/man1"))))))))
143 (native-search-paths (lua-search-paths "5.3"))
144 (home-page "https://www.lua.org/")
145 (synopsis "Embeddable scripting language")
146 (description
147 "Lua is a powerful, fast, lightweight, embeddable scripting language. Lua
148combines simple procedural syntax with powerful data description constructs
149based on associative arrays and extensible semantics. Lua is dynamically typed,
150runs by interpreting bytecode for a register-based virtual machine, and has
151automatic memory management with incremental garbage collection, making it ideal
152for configuration, scripting, and rapid prototyping.")
153 (license license:x11)))
154
155(define-public lua lua-5.3)
156
157(define-public lua-5.5
158 (package (inherit lua)
159 (version "5.5.0")
160 (source (origin
161 (method url-fetch)
162 (uri (string-append "https://www.lua.org/ftp/lua-"
163 version ".tar.gz"))
164 (sha256
165 (base32 "0gcbsr00difm2s82pflxg28zcnjka9048lncbfvwl1fhpcmw7k2p"))
166 ;; Note: Some lua-5.4 patches seem to apply without issues
167 (patches (search-patches "lua-5.4-pkgconfig.patch"
168 "lua-5.4-liblua-so.patch"
169 "lua-5.x-search-path-helpers.patch"
170 "lua-5.5-search-paths.patch"))))
171 (native-search-paths (lua-search-paths "5.5"))))
172
173(define-public lua-5.4
174 (package (inherit lua)
175 (version "5.4.8")
176 (arguments
177 (substitute-keyword-arguments arguments
178 ((#:make-flags flags)
179 (append (delete "linux" flags)
180 '("linux-readline")))))
181 (source (origin
182 (method url-fetch)
183 (uri (string-append "https://www.lua.org/ftp/lua-"
184 version ".tar.gz"))
185 (sha256
186 (base32 "1bi90r9nzmqhjwhr8ysffhmhq30wxxcpqwmbxr33wyaf2npds62g"))
187 (patches (search-patches "lua-5.4-pkgconfig.patch"
188 "lua-5.4-liblua-so.patch"
189 "lua-5.x-search-path-helpers.patch"
190 "lua-5.4-search-paths.patch"))))
191 (native-search-paths (lua-search-paths "5.4"))))
192
193
194(define-public lua-5.4-for-c++
195 (let ((lua-pkg lua-5.4))
196 (hidden-package
197 (package/inherit lua-pkg
198 (name (string-append (package-name lua-pkg) "-for-c++"))
199 (arguments
200 (substitute-keyword-arguments (package-arguments lua-pkg)
201 ((#:make-flags old-flags)
202 (map
203 (match-lambda
204 ((string-append "CC=" _)
205 `(string-append "CC=" ,(cxx-for-target)))
206 (else else))
207 old-flags))))))))
208
209(define-public lua-5.2
210 (package (inherit lua)
211 (version "5.2.4")
212 (source
213 (origin
214 (method url-fetch)
215 (uri (string-append "https://www.lua.org/ftp/lua-"
216 version ".tar.gz"))
217 (sha256
218 (base32 "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr"))
219 (patches (search-patches "lua-pkgconfig.patch"
220 "lua-liblua-so.patch"
221 "lua-5.x-search-path-helpers.patch"
222 "lua-5.2-search-paths.patch"))))
223 (native-search-paths (lua-search-paths "5.2"))))
224
225(define-public lua-5.1
226 (package (inherit lua)
227 (version "5.1.5")
228 (source (origin
229 (method url-fetch)
230 (uri (string-append "https://www.lua.org/ftp/lua-"
231 version ".tar.gz"))
232 (sha256
233 (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))
234 (patches (search-patches "lua51-liblua-so.patch"
235 "lua-CVE-2014-5461.patch"
236 "lua51-pkgconfig.patch"
237 "lua-5.x-search-path-helpers.patch"
238 "lua-5.1-search-paths.patch"))))
239 (native-search-paths (lua-search-paths "5.1"))))
240
241(define-public luajit
242 (let ((branch "v2.1")
243 (commit "04dca7911ea255f37be799c18d74c305b921c1a6"))
244 (package
245 (name "luajit")
246 (version (git-version branch "0" commit))
247 (source (origin
248 (method git-fetch)
249 (uri (git-reference
250 (url "https://luajit.org/git/luajit.git")
251 (commit commit)))
252 (file-name (git-file-name name version))
253 (sha256
254 (base32
255 "0srwk9nmiz8a93f70inq2597ff6xy203ckr4c0k7jcksdixymi9v"))
256 (patches (search-patches "lua-5.x-search-path-helpers.patch"
257 "luajit-search-paths.patch"))))
258 (build-system gnu-build-system)
259 (arguments
260 (list #:tests? #f ; luajit is distributed without tests
261 #:phases
262 #~(modify-phases %standard-phases
263 #$@(if (target-riscv64?)
264 #~((add-after 'unpack 'patch
265 (lambda _
266 (invoke
267 "patch" "--force" "-p1" "-i"
268 #$(local-file
269 (search-patch
270 "luajit-add-riscv64-support.patch"))))))
271 #~())
272 (delete 'configure)) ; no configure script
273 #:make-flags #~(list (string-append "PREFIX="
274 (assoc-ref %outputs "out")))))
275 (native-search-paths
276 (list (search-path-specification
277 (variable "GUIX_LUA_PATH")
278 (separator ";")
279 (files (list "share/lua/5.1"
280 "share/luajit-2.1")))
281 (search-path-specification
282 (variable "GUIX_LUA_CPATH")
283 (separator ";")
284 (files (list "lib/lua/5.1")))))
285 (home-page "https://www.luajit.org/")
286 (synopsis
287 "Just in time compiler for Lua programming language version 5.1")
288 ;; On powerpc64le-linux, the build fails with an error: "No support for
289 ;; PowerPC 64 bit mode (yet)". See: https://issues.guix.gnu.org/49220
290 (supported-systems (fold delete %supported-systems
291 (list "powerpc64le-linux")))
292 (description
293 "LuaJIT is a Just-In-Time Compiler (JIT) for the Lua
294programming language. Lua is a powerful, dynamic and light-weight programming
295language. It may be embedded or used as a general-purpose, stand-alone
296language.")
297 (license license:x11))))
298
299(define-public luajit-lua52-openresty
300 (package
301 (inherit luajit)
302 (name "luajit-lua52-openresty")
303 (version "2.1-20201229")
304 (source
305 (origin
306 (method git-fetch)
307 (uri (git-reference
308 (url "https://github.com/openresty/luajit2.git")
309 (commit (string-append "v" version))))
310 (file-name (git-file-name name version))
311 (sha256
312 (base32 "07haj27kbpbnkv836c2nd36h2xislrmri52w0zbpxvl68xk6g96p"))))
313 (arguments
314 `(#:tests? #f ;no test
315 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
316 #:phases
317 (modify-phases %standard-phases
318 (delete 'configure) ;no configure script
319 (add-after 'unpack 'enable-lua52-compat
320 (lambda _
321 (substitute* "src/Makefile"
322 (("#(XCFLAGS\\+= -DLUAJIT_ENABLE_LUA52COMPAT)" _ flag) flag))
323 #t)))))
324 (home-page "https://github.com/openresty/luajit2")
325 (synopsis "OpenResty's Branch of LuaJIT 2")
326 (description
327 "This is the official OpenResty branch of LuaJIT. It is not to be
328considered a fork, since changes are regularly synchronized from the upstream
329LuaJIT project. This package also enables the Lua 5.2 compat mode needed by
330some projects.")))
331
332(define (make-lua-rewriter lua-package old-prefix new-prefix)
333 "Define a procedure that replaces lua inputs with LUA-PACKAGE. This only
334operates on packages with a name starting with OLD-PREFIX, which is rewritten to
335NEW-PREFIX."
336 (define (transform-name name)
337 (if (string-prefix? old-prefix name)
338 (string-append new-prefix
339 (substring name (string-length old-prefix)))
340 name))
341
342 (define (rewrite-input-labels inputs)
343 (map (lambda (input)
344 (match input
345 ((label (? package? package) outputs ...)
346 (cons* (transform-name label) package outputs))
347 (_
348 input)))
349 inputs))
350
351 (define (transform package)
352 (if (eq? package lua)
353 lua-package
354 (let* ((old-name (package-name package))
355 (new-name (transform-name old-name)))
356 (if (string= old-name new-name)
357 package
358 (package/inherit package
359 (location (package-location package))
360 (name new-name)
361 (source
362 (cond
363 ;; List of packages that shouldn't have their sources
364 ;; rewritten. Eventually we would like to remove this
365 ;; source rewriting, but we'll do so progressively to avoid
366 ;; the rebuilds.
367 ((member (package-name package) '("lua-lunitx"))
368 (package-source package))
369 ;; If we're using {git,hg}-fetch, then rewrite the file-name
370 ;; of the resulting package. This avoids causing rebuilds
371 ;; when migrating from the older method of defining Lua
372 ;; packages.
373 ((eq? (origin-method (package-source package)) git-fetch)
374 (origin
375 (inherit (package-source package))
376 (file-name (git-file-name name (package-version package)))))
377 ((eq? (origin-method (package-source package)) hg-fetch)
378 (origin
379 (inherit (package-source package))
380 (file-name (hg-file-name name (package-version package)))))
381 (else
382 (package-source package))))
383 ;; We also need to rewrite the input labels, otherwise the
384 ;; differences cause rebuilds.
385 (inputs (rewrite-input-labels (package-inputs package)))
386 (native-inputs (rewrite-input-labels (package-native-inputs package)))
387 (propagated-inputs (rewrite-input-labels (package-propagated-inputs package))))))))
388
389 (define (cut? package)
390 (or (eq? package lua)
391 (eq? package lua-package)))
392
393 (package-mapping transform cut?))
394
395(define package-with-lua-5.5 (make-lua-rewriter lua-5.5 "lua-" "lua5.5-"))
396(define package-with-lua-5.4 (make-lua-rewriter lua-5.4 "lua-" "lua5.4-"))
397(define package-with-lua-5.3 (make-lua-rewriter lua "lua-" "lua5.3-"))
398(define package-with-lua-5.2 (make-lua-rewriter lua-5.2 "lua-" "lua5.2-"))
399(define package-with-lua-5.1 (make-lua-rewriter lua-5.1 "lua-" "lua5.1-"))
400
401(define-syntax define-public-lua-variant
402 (syntax-rules (lua-5.5 lua-5.4 lua-5.3 lua-5.2 lua-5.1)
403 "Helper to define a single variant for PACKAGE, called NEW-PACKAGE, for the
404specified lua version. We explicitly match the lua package name as a symbol, so
405we can pick the rewriting function to rewrite package names appropriately."
406 ((_ package (lua-5.5 new-package))
407 (define-public new-package (package-with-lua-5.5 package)))
408 ((_ package (lua-5.4 new-package))
409 (define-public new-package (package-with-lua-5.4 package)))
410 ((_ package (lua-5.3 new-package))
411 (define-public new-package (package-with-lua-5.3 package)))
412 ((_ package (lua-5.2 new-package))
413 (define-public new-package (package-with-lua-5.2 package)))
414 ((_ package (lua-5.1 new-package))
415 (define-public new-package (package-with-lua-5.1 package)))))
416
417(define-syntax-rule (define-public-lua-variants package (lua-version new-package) ...)
418 "Define variants of PACKAGE for each LUA-VERSION, naming the corresponding
419package NEW-PACKAGE."
420 (begin (define-public-lua-variant package (lua-version new-package)) ...))
421
422(define-syntax-rule (this-lua-version)
423 "Return the major+minor version string of the current package's lua input."
424 (version-major+minor (package-version (or (this-package-input "lua")
425 (this-package-native-input "lua")))))
426
427(define-syntax-rule (this-lua-input name)
428 "Return the package input which matches NAME, after replacing any lua- prefix
429with the appropriate luaX.X- prefix for this package."
430 (this-package-input
431 (if (string-prefix? "lua-" name)
432 (string-append "lua" (this-lua-version) "-" (substring name 4))
433 name)))
434
435(define-public lua-expat
436 (package
437 (name "lua-expat")
438 (version "1.5.2")
439 (source
440 (origin
441 (method git-fetch)
442 (uri (git-reference
443 (url "https://github.com/lunarmodules/luaexpat")
444 (commit version)))
445 (file-name (git-file-name name version))
446 (sha256
447 (base32
448 "03wb1rr739qh9xvvi762kpiw5bs99m2plypq5caaan3qacm73rry"))))
449 (build-system gnu-build-system)
450 (arguments
451 (list
452 #:tests? #f ;tests require "busted"
453 #:make-flags
454 #~(let ((lua-version #$(this-lua-version)))
455 (list (string-append "CC=" #$(cc-for-target))
456 (string-append "LUA_LDIR=" #$output "/share/lua/" lua-version)
457 (string-append "LUA_CDIR=" #$output "/lib/lua/" lua-version)))
458 #:phases
459 #~(modify-phases %standard-phases
460 (delete 'configure))))
461 (inputs
462 (list lua expat))
463 (home-page "https://github.com/lunarmodules/luaexpat")
464 (synopsis "SAX XML parser based on the Expat library")
465 (description "LuaExpat is a SAX XML parser based on the Expat library.")
466 (license (package-license lua-5.1))))
467
468(define-public-lua-variants lua-expat
469 (lua-5.5 lua5.5-expat)
470 (lua-5.4 lua5.4-expat)
471 (lua-5.3 lua5.3-expat)
472 (lua-5.2 lua5.2-expat)
473 (lua-5.1 lua5.1-expat))
474
475(define-public lua-socket
476 ;; The 3.1.0 tag still has 3.0.0 in a bunch of places.
477 (let ((commit "de359ea4083ac6d944216229e4104dc36537c29c")
478 (revision "1"))
479 (package
480 (name "lua-socket")
481 (version (git-version "3.1.0" revision commit))
482 (source
483 (origin
484 (method git-fetch)
485 (uri
486 (git-reference
487 (url "https://github.com/lunarmodules/luasocket")
488 (commit commit)))
489 (file-name (git-file-name name version))
490 (sha256
491 (base32 "1bdcdad8fq2p193jcvsv59wm5mifb07alvrxm8qq31qmgs1q4mpw"))))
492 (build-system gnu-build-system)
493 (arguments
494 (list
495 #:make-flags
496 #~(list (string-append "INSTALL_TOP=" #$output)
497 (string-append "LUAV=" #$(this-lua-version))
498 "MYCFLAGS=-DLUASOCKET_DEBUG")
499 #:modules
500 (cons '(ice-9 threads) %default-gnu-modules)
501 #:phases
502 #~(modify-phases %standard-phases
503 (delete 'configure)
504 (delete 'check)
505 (add-after 'install 'install-unix
506 (lambda* (#:key make-flags #:allow-other-keys)
507 (apply invoke "make" "install-unix" make-flags)))
508 (add-after 'install-unix 'check
509 (lambda _
510 (setenv "GUIX_LUA_CPATH"
511 (string-append #$output "/lib/lua/" #$(this-lua-version)))
512 (setenv "GUIX_LUA_PATH"
513 (string-append #$output "/share/lua/" #$(this-lua-version)))
514 (with-directory-excursion "test"
515 (make-thread invoke "lua" "testsrvr.lua")
516 (make-thread invoke "lua" "utestsrvr.lua")
517 (for-each
518 (lambda (test)
519 (invoke "lua" (string-append test ".lua")))
520 '("hello" "stufftest" "excepttest" "test_bind"
521 "test_getaddrinfo" "ltn12test" "mimetest" "urltest"
522 "test_socket_error" "testclnt" "utestclnt"))))))))
523 (inputs (list lua))
524 (home-page "https://lunarmodules.github.io/luasocket")
525 (synopsis "Network support for the Lua language")
526 (description
527 "LuaSocket is a Lua extension library that is composed by two parts:
528a C core that provides support for the TCP and UDP transport layers,
529and a set of Lua modules that add support for functionality commonly needed by
530applications that deal with the Internet.
531
532Among the supported modules, the most commonly used implement the
533SMTP (sending e-mails), HTTP (WWW access) and FTP (uploading and downloading
534files) client protocols. These provide a very natural and generic interface
535to the functionality defined by each protocol. In addition, you will find
536that the MIME (common encodings), URL (anything you could possible want to do
537with one) and LTN12 (filters, sinks, sources and pumps) modules can be very
538handy.")
539 (license (package-license lua-5.1)))))
540
541(define-public-lua-variants lua-socket
542 (lua-5.5 lua5.5-socket)
543 (lua-5.4 lua5.4-socket)
544 (lua-5.3 lua5.3-socket)
545 (lua-5.2 lua5.2-socket)
546 (lua-5.1 lua5.1-socket))
547
548(define-public lua-filesystem
549 (package
550 (name "lua-filesystem")
551 (version "1.9.0")
552 (source (origin
553 (method git-fetch)
554 (uri (git-reference
555 (url "https://github.com/keplerproject/luafilesystem")
556 (commit (string-append "v"
557 (string-join
558 (string-split version #\.) "_")))))
559 (file-name (git-file-name name version))
560 (sha256
561 (base32
562 "0vd1b9rnbjl24bbnk91jrkli81dc1b2kvpjlsx319azjmynlk0y6"))))
563 (build-system gnu-build-system)
564 (arguments
565 `(#:make-flags
566 (let ((out (assoc-ref %outputs "out"))
567 (lua-version ,(this-lua-version)))
568 (list (string-append "PREFIX=" out)
569 (string-append "LUA_LIBDIR=" out "/lib/lua/" lua-version)))
570 #:test-target "test"
571 #:phases
572 (modify-phases %standard-phases
573 (delete 'configure))))
574 (inputs
575 (list lua))
576 (home-page "https://keplerproject.github.io/luafilesystem/index.html")
577 (synopsis "File system library for Lua")
578 (description "LuaFileSystem is a Lua library developed to complement the
579set of functions related to file systems offered by the standard Lua
580distribution. LuaFileSystem offers a portable way to access the underlying
581directory structure and file attributes.")
582 (license (package-license lua-5.1))))
583
584(define-public-lua-variants lua-filesystem
585 (lua-5.4 lua5.4-filesystem)
586 (lua-5.3 lua5.3-filesystem)
587 (lua-5.2 lua5.2-filesystem)
588 (lua-5.1 lua5.1-filesystem))
589
590(define-public lua-bee
591 ;; There are no releases; use the commit known to work with the packaged
592 ;; luamake.
593 (let ((commit "fe3feb2b62e8f0179dad5abb438ed4df39f675d4")
594 (revision "0"))
595 (package
596 (name "lua-bee")
597 (version (git-version "0.0.0" revision commit))
598 (source (origin
599 (method git-fetch)
600 (uri (git-reference
601 (url "https://github.com/actboy168/bee.lua/")
602 (commit commit)
603 ;; Requires a few git submodules such as the Lua
604 ;; sources to patch and a few source libraries.
605 (recursive? #t)))
606 (file-name (git-file-name name version))
607 (sha256
608 (base32
609 "1iv4cdkgcs123zw67ngq4jfbp7p7hkmj8zg2lbblipmm0hivhbd2"))))
610 (build-system gnu-build-system)
611 (arguments
612 (list
613 ;; TODO: Re-enable the tests after luamake can use a newer bee commit
614 ;; (see:
615 ;; <https://github.com/actboy168/bee.lua/commit/679c566f0f26bcf0c19e37066e678993122e1f34>).
616 #:tests? #f
617 #:phases
618 #~(modify-phases %standard-phases
619 (delete 'configure)
620 (replace 'build
621 (lambda* (#:key parallel-build? #:allow-other-keys)
622 (invoke "luamake"
623 "-EXE" "lua"
624 "-notest"
625 "-j" (if parallel-build?
626 (number->string (parallel-job-count))
627 "1")
628 "-v")))
629 (replace 'check
630 (lambda* (#:key parallel-tests? tests? #:allow-other-keys)
631 (when tests?
632 (invoke "luamake"
633 "-EXE" "lua"
634 "-j" (if parallel-tests?
635 (number->string (parallel-job-count))
636 "1")
637 "test" "-v"))))
638 (replace 'install
639 (lambda _
640 (install-file "build/bin/lua"
641 (string-append #$output "/bin"))
642 (install-file "build/bin/bee.so"
643 (string-append #$output "/lib/")))))))
644 (native-inputs (list luamake))
645 (home-page "https://github.com/actboy168/bee.lua/")
646 (synopsis "Lua runtime with a few extra features")
647 (description "The Bee Lua runtime implements a few extra features
648such as:
649@itemize
650@item Deterministic tables traversal
651@item Enable @code{lua_assert} in debug mode
652@item Add error hook (for debugger)
653@item Add resume/yield hook (for debugger)
654@item Disable tail calls in debug mode (for debugger)
655@end itemize")
656 (license license:expat))))
657
658(define-public luamake
659 (package
660 (name "luamake")
661 (version "1.7")
662 (source (origin
663 (method git-fetch)
664 (uri (git-reference
665 (url "https://github.com/actboy168/luamake")
666 (commit (string-append "v" version))))
667 (file-name (git-file-name name version))
668 (sha256
669 (base32
670 "075sp8dpcb81kwrpp843f1y00kvaqan09np6spf6b72z5dhf6aiw"))))
671 (build-system gnu-build-system)
672 (arguments
673 (list
674 #:phases
675 #~(modify-phases %standard-phases
676 (add-after 'unpack 'copy-lua-bee-sources
677 (lambda* (#:key native-inputs inputs #:allow-other-keys)
678 (copy-recursively (dirname
679 (search-input-directory
680 (or native-inputs inputs) "bee"))
681 "bee.lua")))
682 (add-after 'unpack 'patch-commands
683 (lambda* (#:key inputs #:allow-other-keys)
684 (substitute* "scripts/action.lua"
685 (("\"ninja\"")
686 (format #f "~s" (search-input-file inputs "bin/ninja"))))))
687 (delete 'configure)
688 (replace 'build
689 (lambda* (#:key parallel-build? #:allow-other-keys)
690 (invoke "compile/build.sh" "-j"
691 (if parallel-build?
692 (number->string (parallel-job-count))
693 "1")
694 "notest" "-v")))
695 (replace 'check
696 (lambda* (#:key parallel-tests? tests? #:allow-other-keys)
697 (when tests?
698 (invoke "compile/build.sh" "-j"
699 (if parallel-tests?
700 (number->string (parallel-job-count))
701 "1")
702 "test" "-v"))))
703 (replace 'install
704 (lambda _
705 (let ((bin (string-append #$output "/bin"))
706 (lib (string-append #$output "/lib/luamake")))
707 (install-file "luamake" lib)
708 (install-file "main.lua" lib)
709 (copy-recursively "scripts"
710 (string-append lib "/scripts"))
711 (copy-recursively "tools"
712 (string-append lib "/tools"))
713 (mkdir bin)
714 (symlink (string-append lib "/luamake")
715 (string-append bin "/luamake"))))))))
716 (native-inputs (list (package-source lua-bee)
717 ninja))
718 (inputs (list ninja))
719 (home-page "https://github.com/actboy168/luamake")
720 (synopsis "Make-inspired configuration and build system")
721 (description "Luamake is a platform independent configuration and
722build system that uses the standard Lua command-line interpreter.")
723 (license license:expat)))
724
725(define-public lua-language-server
726 (package
727 (name "lua-language-server")
728 (version "3.17.1")
729 (source (origin
730 (method git-fetch)
731 (uri (git-reference
732 (url "https://github.com/LuaLS/lua-language-server")
733 (commit version)
734 ;; There are quite a few bundled Lua libraries under the
735 ;; '3rd' and 'meta/3rd' directories; most are currently
736 ;; not packaged in Guix, and they all track exact
737 ;; commits, so it would be annoying to maintain them as
738 ;; separate origins (on top of having to patch the build
739 ;; system to unbundle them).
740 (recursive? #t)))
741 (file-name (git-file-name name version))
742 (sha256
743 (base32
744 "1fjhh02iph0mplqrgxfrdqfydrppksjsgw3lg6k8y5w6g24l3z1m"))))
745 (build-system gnu-build-system)
746 (arguments
747 (list
748 ;; The test suite currently fails with luamake apparently attempting to
749 ;; find the bee.so shared object (see:
750 ;; <https://github.com/LuaLS/lua-language-server/issues/3325>).
751 #:tests? #f
752 #:phases
753 #~(modify-phases %standard-phases
754 (delete 'configure)
755 (replace 'build
756 (lambda* (#:key parallel-build? #:allow-other-keys)
757 (invoke "luamake"
758 "-notest"
759 "-j" (if parallel-build?
760 (number->string (parallel-job-count))
761 "1")
762 "-v")))
763 (replace 'check
764 (lambda* (#:key parallel-tests? tests? #:allow-other-keys)
765 (when tests?
766 (invoke "luamake"
767 "-j" (if parallel-tests?
768 (number->string (parallel-job-count))
769 "1")
770 "test" "-v"))))
771 (replace 'install
772 ;; This is inspired by the package definition in Slackware.
773 (lambda* (#:key inputs #:allow-other-keys)
774 (let* ((bin (string-append #$output "/bin"))
775 (lib (string-append #$output
776 "/libexec/lua-language-server"))
777 (lib/bin (string-append lib "/bin")))
778 ;; XXX: The binary expects some odd layout to find its resources,
779 ;; hence the bin subdirectory under libexec.
780 (mkdir-p lib)
781 (for-each (lambda (x)
782 (copy-recursively x (string-append lib "/" x)))
783 (list "bin"
784 "debugger.lua"
785 "locale"
786 "main.lua"
787 "meta"
788 "script"))
789 ;; Create a custom wrapper, adjusted to log elsewhere than in
790 ;; its read-only location under the store.
791 (mkdir bin)
792 (call-with-output-file (string-append bin "/lua-language-server")
793 (lambda (p)
794 (format p "#!~a
795exec ~a --logpath=\"/tmp/runtime-$USER/lua-language-server/log\" \
796--metapath=\"/tmp/runtime-$USER/lua-language-server/meta\" \"$@\""
797 (search-input-file inputs "bin/sh")
798 (string-append lib/bin
799 "/lua-language-server"))))
800 (chmod (string-append bin "/lua-language-server") #o755)))))))
801 (native-inputs (list luamake))
802 (inputs (list bash-minimal)) ;for the wrapper
803 (home-page "https://github.com/LuaLS/lua-language-server")
804 (synopsis "Lua language server")
805 (description "The Lua language server provides various language
806 features for Lua to make development easier and faster, including:
807@itemize
808@item Support for all recent versions of Lua, including LuaJIT
809@item Jump to definition
810@item Dynamic type checking
811@item Find references
812@item Diagnostics/Warnings
813@item Syntax checking
814@item Element renaming
815@item Hover to view details on variables, functions, and more
816@item Auto-completion
817@item Support for libraries
818@item Code formatting
819@item Spell checking
820@item Custom plugins
821@item Documentation generation
822@end itemize")
823 (license license:expat)))
824
825(define-public lua-ossl
826 (package
827 (name "lua-ossl")
828 (version "20220711")
829 (source (origin
830 (method git-fetch)
831 (uri (git-reference
832 (url "https://github.com/wahern/luaossl")
833 (commit (string-append "rel-" version))))
834 (file-name (git-file-name name version))
835 (sha256
836 (base32
837 "1a9pgmc6fbhgh1m9ksz9fq057yzz46npqgakcsy9vngg47xacfdb"))))
838 (build-system gnu-build-system)
839 (arguments
840 (list
841 #:make-flags
842 #~(let ((lua-api-version #$(this-lua-version)))
843 (list (string-append "CC=" #$(cc-for-target))
844 "CFLAGS='-D HAVE_SYS_SYSCTL_H=0'" ; sys/sysctl.h is deprecated
845 (string-append "prefix=" #$output)
846 (string-append "LUA_APIS=" lua-api-version)))
847 #:phases
848 #~(modify-phases %standard-phases
849 (delete 'configure)
850 (delete 'check)
851 (add-after 'install 'check
852 (lambda _
853 (let ((lua-version #$(this-lua-version)))
854 (setenv "LUA_CPATH"
855 (string-append #$output "/lib/lua/" lua-version "/?.so;;"))
856 (setenv "LUA_PATH"
857 (string-append #$output "/share/lua/" lua-version "/?.lua;;"))
858 (with-directory-excursion "regress"
859 (for-each (lambda (f)
860 (unless (member f (list
861 ;; This test is for luajit only
862 "./104-interposition-discarded.lua"
863 ;; needs cqueues, which needs ossl
864 "./148-custom-extensions.lua"))
865 (invoke "lua" f)))
866 (find-files "." "^[0-9].*\\.lua$")))))))))
867 (inputs
868 (list lua openssl))
869 (home-page "https://25thandclement.com/~william/projects/luaossl.html")
870 (synopsis "OpenSSL bindings for Lua")
871 (description "The luaossl extension module for Lua provides comprehensive,
872low-level bindings to the OpenSSL library, including support for certificate
873and key management, key generation, signature verification, and deep bindings
874to the distinguished name, alternative name, and X.509v3 extension interfaces.
875It also binds OpenSSL's bignum, message digest, HMAC, cipher, and CSPRNG
876interfaces.")
877 (license license:expat)))
878
879(define-public-lua-variants lua-ossl
880 (lua-5.3 lua5.3-ossl)
881 (lua-5.2 lua5.2-ossl)
882 (lua-5.1 lua5.1-ossl))
883
884(define-public lua-sec
885 (package
886 (name "lua-sec")
887 (version "1.3.2")
888 (source (origin
889 (method git-fetch)
890 (uri (git-reference
891 (url "https://github.com/brunoos/luasec")
892 (commit (string-append "v" version))))
893 (file-name (git-file-name name version))
894 (sha256
895 (base32
896 "0rrdfbnkd8pgqwh3f0iyd5cxy7g1h0568a88m3sq1z7715js4yx3"))))
897 (build-system gnu-build-system)
898 (arguments
899 (list
900 #:tests? #f ;no tests
901 #:make-flags
902 #~(let* ((lua-api-version #$(this-lua-version))
903 (lua-path (string-append #$output "/share/lua/" lua-api-version))
904 (lua-cpath (string-append #$output "/lib/lua/" lua-api-version)))
905 (list "linux"
906 (string-append "CC=" #$(cc-for-target))
907 (string-append "LD=" #$(cc-for-target))
908 (string-append "LUAPATH=" lua-path)
909 (string-append "LUACPATH=" lua-cpath)))
910 #:phases #~(modify-phases %standard-phases
911 (delete 'configure))))
912 (inputs (list lua openssl))
913 (propagated-inputs (list lua-socket))
914 (home-page "https://github.com/brunoos/luasec/wiki")
915 (synopsis "OpenSSL bindings for Lua")
916 (description
917 "LuaSec is a binding for OpenSSL library to provide TLS/SSL communication.
918It takes an already established TCP connection and creates a secure session
919between the peers.")
920 (license license:expat)))
921
922(define-public-lua-variants lua-sec
923 (lua-5.5 lua5.5-sec)
924 (lua-5.4 lua5.4-sec)
925 (lua-5.3 lua5.3-sec)
926 (lua-5.2 lua5.2-sec)
927 (lua-5.1 lua5.1-sec))
928
929(define-public lua-cqueues
930 (package
931 (name "lua-cqueues")
932 (version "20200726")
933 (source (origin
934 (method git-fetch)
935 (uri (git-reference
936 (url "https://github.com/wahern/cqueues")
937 (commit (string-append "rel-" version))))
938 (file-name (git-file-name name version))
939 (sha256
940 (base32
941 "17gwqndlga6gnishgs6wk8cvgwzanddr42yikkg2xd4nanhcg8z9"))))
942 (build-system gnu-build-system)
943 (arguments
944 (list
945 #:modules '((guix build gnu-build-system)
946 (guix build utils)
947 (ice-9 string-fun))
948 #:make-flags
949 #~(let ((lua-api-version #$(this-lua-version)))
950 (list (string-append "CC=" #$(cc-for-target))
951 (string-append "LUA_APIS=" lua-api-version)))
952 #:phases
953 #~(modify-phases %standard-phases
954 (delete 'configure)
955 (delete 'check)
956 (replace 'install
957 (lambda* (#:key make-flags #:allow-other-keys)
958 (apply invoke "make" "install"
959 (append make-flags
960 (list (string-append "DESTDIR=" #$output)
961 "prefix=")))))
962 (add-after 'install 'check
963 (lambda* (#:key make-flags #:allow-other-keys)
964 (let*
965 ((lua-version #$(this-lua-version))
966 (env-suffix (if (equal? lua-version "5.1")
967 ""
968 (string-append
969 "_"
970 (string-replace-substring lua-version "." "_"))))
971
972 (lua-cpath (lambda (p)
973 (string-append p "/lib/lua/" lua-version "/?.so")))
974 (lua-path (lambda (p)
975 (string-append p "/share/lua/" lua-version "/?.lua"))))
976 ;; The test suite sets Lua-version-specific search-path variables
977 ;; when available so we must do the same, as these take
978 ;; precedence over the generic "LUA_CPATH" and "LUA_PATH"
979 (setenv (string-append "LUA_CPATH" env-suffix)
980 (string-append
981 (string-join (map lua-cpath (list #$output #$(this-lua-input "lua-ossl"))) ";")
982 ";;"))
983 (setenv (string-append "LUA_PATH" env-suffix)
984 (string-append
985 (string-join (map lua-path (list #$output #$(this-lua-input "lua-ossl"))) ";")
986 ";;"))
987
988 ;; Skip regression tests we expect to fail
989 (with-directory-excursion "regress"
990 (for-each (lambda (f)
991 (rename-file f (string-append f ".skip")))
992 (append
993 ;; Regression tests that require network
994 ;; connectivity
995 '("22-client-dtls.lua"
996 "30-starttls-completion.lua"
997 "62-noname.lua"
998 "153-dns-resolvers.lua")
999
1000 ;; Regression tests that require LuaJIT
1001 '("44-resolvers-gc.lua"
1002 "51-join-defunct-thread.lua"
1003 ;; These both need the ffi module.
1004 "73-starttls-buffering.lua"
1005 "87-alpn-disappears.lua")
1006
1007 ;; Regression tests that require Lua 5.3
1008 (if (not (equal? lua-version "5.3"))
1009 '("152-thread-integer-passing.lua")
1010 '()))))
1011
1012 (apply invoke "make" "check" make-flags)))))))
1013 (native-inputs
1014 (list m4))
1015 (inputs
1016 (list lua openssl))
1017 (propagated-inputs
1018 (list lua-ossl))
1019 (home-page "https://25thandclement.com/~william/projects/cqueues.html")
1020 (synopsis "Event loop for Lua using continuation queues")
1021 (description "The cqueues extension module for Lua implements an event loop
1022that operates through the yielding and resumption of coroutines. It is designed
1023to be non-intrusive, composable, and embeddable within existing applications.")
1024 (license license:expat)))
1025
1026(define-public-lua-variants lua-cqueues
1027 (lua-5.3 lua5.3-cqueues)
1028 (lua-5.2 lua5.2-cqueues)
1029 (lua-5.1 lua5.1-cqueues))
1030
1031(define-public lua-penlight
1032 (package
1033 (name "lua-penlight")
1034 (version "1.7.0")
1035 (source
1036 (origin
1037 (method git-fetch)
1038 (uri (git-reference
1039 (url "https://github.com/Tieske/Penlight")
1040 (commit version)))
1041 (file-name (git-file-name name version))
1042 (sha256
1043 (base32 "0qc2d1riyr4b5a0gnsmdw2lz5pw65s4ac60hc34w3mmk9l6yg6nl"))))
1044 (build-system trivial-build-system)
1045 (inputs
1046 (list lua))
1047 (propagated-inputs
1048 (list lua-filesystem))
1049 (arguments
1050 `(#:modules ((guix build utils))
1051 #:builder
1052 (begin
1053 (use-modules (guix build utils))
1054 (let* ((source (assoc-ref %build-inputs "source"))
1055 (lua-version ,(version-major+minor (package-version lua)))
1056 (destination (string-append (assoc-ref %outputs "out")
1057 "/share/lua/" lua-version)))
1058 (mkdir-p destination)
1059 (with-directory-excursion source
1060 (copy-recursively "lua/" destination)))
1061 #t)))
1062 (home-page "http://tieske.github.io/Penlight/")
1063 (synopsis "Collection of general purpose libraries for the Lua language")
1064 (description "Penlight is a set of pure Lua libraries focusing on
1065input data handling (such as reading configuration files), functional
1066programming (such as map, reduce, placeholder expressions,etc), and OS
1067path management. Much of the functionality is inspired by the Python
1068standard libraries.")
1069 (license license:expat)))
1070
1071(define-public lua-ldoc
1072 (package
1073 (name "lua-ldoc")
1074 (version "1.4.6")
1075 (source
1076 (origin
1077 (method git-fetch)
1078 (uri (git-reference
1079 (url "https://github.com/stevedonovan/LDoc")
1080 (commit version)))
1081 (file-name (git-file-name name version))
1082 (sha256
1083 (base32 "1h0cf7bp4am54r0j8lhjs2l1c7q5vz74ba0jvw9qdbaqimls46g8"))))
1084 (build-system gnu-build-system)
1085 (inputs
1086 (list lua))
1087 (propagated-inputs
1088 (list lua-penlight))
1089 (arguments
1090 `(#:tests? #f ;tests must run after installation.
1091 #:phases
1092 (modify-phases %standard-phases
1093 (add-after 'unpack 'fix-installation-directory
1094 (lambda* (#:key outputs #:allow-other-keys)
1095 (let ((out (assoc-ref outputs "out"))
1096 (lua-version ,(version-major+minor (package-version lua))))
1097 (substitute* "makefile"
1098 (("LUA=.*") "#\n")
1099 (("(LUA_PREFIX=).*" _ prefix)
1100 (string-append prefix out "\n"))
1101 (("(LUA_BINDIR=).*" _ prefix)
1102 (string-append prefix out "/bin\n"))
1103 (("(LUA_SHAREDIR=).*" _ prefix)
1104 (string-append prefix out "/share/lua/" lua-version "\n"))))
1105 #t))
1106 (delete 'configure)
1107 (add-before 'install 'create-bin-directory
1108 (lambda* (#:key outputs #:allow-other-keys)
1109 (mkdir-p (string-append (assoc-ref outputs "out") "/bin"))
1110 #t)))))
1111 (home-page "https://stevedonovan.github.io/ldoc/")
1112 (synopsis "Lua documentation generator")
1113 (description
1114 "LDoc is a LuaDoc-compatible documentation generation system for
1115Lua source code. It parses the declaration and documentation comments
1116in a set of Lua source files and produces a set of XHTML pages
1117describing the commented declarations and functions.")
1118 (license license:expat)))
1119
1120(define-public lua-lgi
1121 (package
1122 (name "lua-lgi")
1123 (version "0.9.2")
1124 (source
1125 (origin
1126 (method git-fetch)
1127 (uri (git-reference
1128 (url "https://github.com/pavouk/lgi")
1129 (commit version)))
1130 (file-name (git-file-name name version))
1131 (patches (search-patches "lua-lgi-fix-ref.patch"
1132 "lua-lgi-fix-pango.patch"))
1133 (sha256
1134 (base32 "03rbydnj411xpjvwsyvhwy4plm96481d7jax544mvk7apd8sd5jj"))))
1135 (build-system gnu-build-system)
1136 (arguments
1137 `(#:make-flags
1138 (list ,(string-append "CC=" (cc-for-target))
1139 (string-append "PREFIX=" (assoc-ref %outputs "out")))
1140 #:phases
1141 (modify-phases %standard-phases
1142 (delete 'configure) ; no configure script
1143 (add-before 'build 'set-env
1144 (lambda* (#:key inputs #:allow-other-keys)
1145 ;; We need to load cairo dynamically.
1146 (let* ((cairo (string-append (assoc-ref inputs "cairo") "/lib")))
1147 (setenv "LD_LIBRARY_PATH" cairo)
1148 #t)))
1149 (add-before 'build 'set-lua-version
1150 (lambda _
1151 ;; Lua version and therefore install directories are hardcoded.
1152 (substitute* "./lgi/Makefile"
1153 (("LUA_VERSION=5.1")
1154 (format #f
1155 "LUA_VERSION=~a"
1156 ,(this-lua-version))))
1157 #t))
1158 (add-before 'check 'skip-test-gtk
1159 (lambda _
1160 ;; FIXME: Skip GTK tests:
1161 ;; gtk3 - can't get it to run with the xorg-server config below
1162 ;; and some non-gtk tests will also fail
1163 ;; gtk2 - lots of functions aren't implemented
1164 ;; We choose gtk2 as the lesser evil and simply skip the test.
1165 ;; Currently, awesome is the only package that uses lua-lgi but
1166 ;; it doesn't need or interact with GTK using lua-lgi.
1167 (substitute* "./tests/test.lua"
1168 (("'gtk.lua',") "-- 'gtk.lua',"))
1169 #t))
1170 (add-before 'check 'start-xserver-instance
1171 (lambda* (#:key inputs #:allow-other-keys)
1172 ;; There must be a running X server during tests.
1173 (system (format #f "~a/bin/Xvfb :1 &"
1174 (assoc-ref inputs "xorg-server")))
1175 (setenv "DISPLAY" ":1")
1176 #t)))))
1177 (native-inputs
1178 (list dbus ;tests use 'dbus-run-session'
1179 pkg-config))
1180 (inputs
1181 `(("cairo" ,cairo)
1182 ("glib" ,glib)
1183 ("gobject-introspection" ,gobject-introspection)
1184 ("gtk" ,gtk+-2)
1185 ("libffi" ,libffi)
1186 ("lua" ,lua)
1187 ("pango" ,pango)
1188 ("xorg-server" ,xorg-server)))
1189 (home-page "https://github.com/pavouk/lgi/")
1190 (synopsis "Lua bridge to GObject based libraries")
1191 (description
1192 "LGI is gobject-introspection based dynamic Lua binding to GObject based
1193libraries. It allows using GObject-based libraries directly from Lua.
1194Notable examples are GTK+, GStreamer and Webkit.")
1195 (license license:expat)))
1196
1197(define-public-lua-variants lua-lgi
1198 (lua-5.3 lua5.3-lgi)
1199 (lua-5.2 lua5.2-lgi)
1200 (lua-5.1 lua5.1-lgi))
1201
1202(define-public lua-lpeg
1203 (package
1204 (name "lua-lpeg")
1205 (version "1.1.0")
1206 (source (origin
1207 (method url-fetch)
1208 (uri (string-append "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-"
1209 version ".tar.gz"))
1210 (sha256
1211 (base32
1212 "0aimsjpcpkh3kk65f0pg1z2bp6d83rn4dg6pgbx1yv14s9kms5ab"))))
1213 (build-system gnu-build-system)
1214 (arguments
1215 `(#:phases
1216 (modify-phases %standard-phases
1217 (delete 'configure)
1218 ;; `make install` isn't available, so we have to do it manually
1219 (replace 'install
1220 (lambda* (#:key outputs #:allow-other-keys)
1221 (let ((out (assoc-ref outputs "out"))
1222 (lua-version ,(this-lua-version)))
1223 (install-file "lpeg.so"
1224 (string-append out "/lib/lua/" lua-version))
1225 (install-file "re.lua"
1226 (string-append out "/share/lua/" lua-version))
1227 #t))))
1228 #:test-target "test"))
1229 (inputs (list lua))
1230 (synopsis "Pattern-matching library for Lua")
1231 (description
1232 "LPeg is a pattern-matching library for Lua, based on Parsing Expression
1233Grammars (PEGs).")
1234 (home-page "https://www.inf.puc-rio.br/~roberto/lpeg")
1235 (license license:expat)))
1236
1237(define-public-lua-variants lua-lpeg
1238 (lua-5.4 lua5.4-lpeg)
1239 (lua-5.3 lua5.3-lpeg)
1240 (lua-5.2 lua5.2-lpeg)
1241 (lua-5.1 lua5.1-lpeg))
1242
1243(define-public lua-luv
1244 (package
1245 (name "lua-luv")
1246 (version "1.52.1-0")
1247 (source (origin
1248 ;; The release tarball includes the sources of libuv but does
1249 ;; not include the pkg-config files.
1250 (method git-fetch)
1251 (uri (git-reference
1252 (url "https://github.com/luvit/luv")
1253 (commit version)))
1254 (file-name (git-file-name name version))
1255 (sha256
1256 (base32
1257 "109d1g4j8kfjixxnp70wb64wn6rhvpi9amcd71vs5f7398z8d0sr"))))
1258 (build-system cmake-build-system)
1259 (arguments
1260 (list #:tests? #f ; there are none
1261 #:configure-flags
1262 #~'("-DWITH_LUA_ENGINE=Lua"
1263 "-DWITH_SHARED_LIBUV=On"
1264 "-DBUILD_MODULE=Off"
1265 "-DBUILD_SHARED_LIBS=On"
1266 "-DLUA_BUILD_TYPE=System")
1267 #:phases
1268 #~(modify-phases %standard-phases
1269 (add-after 'unpack 'copy-lua-compat
1270 (lambda* _
1271 (copy-recursively #+(this-package-native-input "lua-compat")
1272 "lua-compat")
1273 (setenv "CPATH"
1274 (string-append (getcwd) "/lua-compat/c-api:"
1275 (or (getenv "CPATH") "")))
1276 #t)))))
1277 (inputs
1278 (list lua libuv-for-luv))
1279 (native-inputs
1280 `(("lua-compat"
1281 ,(origin
1282 (method git-fetch)
1283 (uri (git-reference
1284 (url "https://github.com/keplerproject/lua-compat-5.3")
1285 (commit "v0.10")))
1286 (file-name "lua-compat-5.3-checkout")
1287 (sha256
1288 (base32
1289 "1caxn228gx48g6kymp9w7kczgxcg0v0cd5ixsx8viybzkd60dcn4"))))))
1290 (home-page "https://github.com/luvit/luv/")
1291 (synopsis "Libuv bindings for Lua")
1292 (description
1293 "This library makes libuv available to Lua scripts.")
1294 (license license:asl2.0)))
1295
1296(define-public-lua-variants lua-luv
1297 (lua-5.3 lua5.3-luv)
1298 (lua-5.2 lua5.2-luv)
1299 (lua-5.1 lua5.1-luv))
1300
1301;; Lua 5.3 is not supported, so this package is not exported.
1302(define lua-bitop
1303 (package
1304 (name "lua-bitop")
1305 (version "1.0.2")
1306 (source (origin
1307 (method url-fetch)
1308 (uri (string-append "http://bitop.luajit.org/download/"
1309 "LuaBitOp-" version ".tar.gz"))
1310 (sha256
1311 (base32
1312 "16fffbrgfcw40kskh2bn9q7m3gajffwd2f35rafynlnd7llwj1qj"))))
1313 (build-system gnu-build-system)
1314 (arguments
1315 `(#:test-target "test"
1316 #:make-flags
1317 (list "INSTALL=install -pD"
1318 (string-append "INSTALLPATH=printf "
1319 (assoc-ref %outputs "out")
1320 "/lib/lua/"
1321 ,(this-lua-version)
1322 "/bit/bit.so"))
1323 #:phases
1324 (modify-phases %standard-phases
1325 (delete 'configure))))
1326 (inputs (list lua))
1327 (home-page "https://bitop.luajit.org/index.html")
1328 (synopsis "Bitwise operations on numbers for Lua")
1329 (description
1330 "Lua BitOp is a C extension module for Lua which adds bitwise operations
1331on numbers.")
1332 (license license:expat)))
1333
1334(define-public-lua-variants lua-bitop
1335 (lua-5.2 lua5.2-bitop)
1336 (lua-5.1 lua5.1-bitop))
1337
1338(define-public lua-djot
1339 (package
1340 (name "lua-djot")
1341 (version "0.2.1")
1342 (source
1343 (origin
1344 (method git-fetch)
1345 (uri (git-reference
1346 (url "https://github.com/jgm/djot.lua")
1347 (commit version)))
1348 (file-name (git-file-name name version))
1349 (sha256 (base32 "0kivx4yyj2zhj23d93h5rr0ab7gkazd3z7r7aqv1bgmigcw47pj2"))
1350 (modules '((guix build utils)))
1351 (snippet #~(begin
1352 (delete-file-recursively "clib")
1353 (delete-file-recursively "doc/api")
1354 (delete-file "doc/djot.1")))))
1355 (build-system gnu-build-system)
1356 (arguments
1357 (list
1358 #:phases
1359 #~(modify-phases %standard-phases
1360 (add-after 'unpack 'patch-makefile
1361 (lambda _
1362 (substitute* "Makefile"
1363 (("^all: .*") "all:\n"))))
1364 (delete 'configure)
1365 (replace 'check
1366 (lambda* (#:key tests? #:allow-other-keys)
1367 (when tests?
1368 (invoke "lua" "test.lua"))))
1369 (replace 'install
1370 (lambda _
1371 (let ((lua-path
1372 (string-append
1373 #$output
1374 "/share/lua/"
1375 #$(this-lua-version))))
1376 (install-file "djot.lua" lua-path)
1377 (copy-recursively "djot" (string-append lua-path "/djot"))))))))
1378 (native-inputs (list lua))
1379 (home-page "https://github.com/jgm/djot.lua")
1380 (synopsis "Lua parser for the djot light markup language")
1381 (description
1382 "This package provides a Lua parser for djot, a light markup syntax.
1383It can produce an AST, rendered HTML, or a stream of match tokens
1384that identify elements by source position, which could be used
1385for syntax highlighting or a linting tool.")
1386 (license license:expat)))
1387
1388(define-public-lua-variants lua-djot
1389 (lua-5.4 lua5.4-djot)
1390 (lua-5.3 lua5.3-djot)
1391 (lua-5.2 lua5.2-djot)
1392 (lua-5.1 lua5.1-djot))
1393
1394(define-public djot
1395 (package
1396 (inherit lua5.1-djot)
1397 (name "djot")
1398 (arguments
1399 (substitute-keyword-arguments (package-arguments lua5.1-djot)
1400 ((#:phases phases)
1401 #~(modify-phases #$phases
1402 (replace 'patch-makefile
1403 (lambda _
1404 (substitute* "Makefile"
1405 (("^all: .*") "all: doc/djot.1\n"))))
1406 (replace 'check
1407 (lambda* (#:key tests? #:allow-other-keys)
1408 (when tests?
1409 (invoke "luajit" "test.lua"))))
1410 (add-after 'install 'install-bin-and-man
1411 (lambda* (#:key inputs #:allow-other-keys)
1412 (let ((out-lua (string-append #$output "/share/lua/5.1"))
1413 (out-bin (string-append #$output "/bin/djot")))
1414 (copy-file "bin/main.lua" "bin/djot")
1415 (substitute* "bin/djot"
1416 (("^local djot = require" all)
1417 (string-append
1418 "#!"
1419 (search-input-file inputs "bin/luajit")
1420 "\n"
1421 all)))
1422 (install-file "bin/djot" (string-append #$output "/bin"))
1423 (chmod out-bin #o755)
1424 (wrap-program out-bin
1425 `("GUIX_LUA_PATH" ";" = (,out-lua))))
1426 (install-file "doc/djot.1"
1427 (string-append #$output "/share/man/man1"))))))))
1428 (native-inputs (list pandoc))
1429 (inputs (list luajit))))
1430
1431(define-public lua-readline
1432 (package
1433 (name "lua-readline")
1434 (version "3.3")
1435 (source
1436 (origin
1437 (method git-fetch)
1438 (uri (git-reference ;Peter Billam's Lua module monorepo
1439 (url "https://gitlab.com/peterbillam/pjb_lua.git")
1440 (commit "c558b912032cb81508f1f41fcd1fa417ba9ea4f3")))
1441 (file-name (git-file-name "pjb-lua" "2023.11.26"))
1442 (sha256 (base32 "00xwfyf7p6lvm51msv67sjxw3xkjydfr32dq4p0wfn0ig3xz8m63"))))
1443 (build-system gnu-build-system)
1444 (arguments
1445 (list
1446 #:tests? #f ;test_rl.lua is manual
1447 #:phases
1448 #~(let* ((lua-api-version #$(this-lua-version))
1449 (lua-cpath (string-append #$output "/lib/lua/" lua-api-version))
1450 (lua-path (string-append #$output "/share/lua/" lua-api-version))
1451 (shared-object "C-readline.so"))
1452 (modify-phases %standard-phases
1453 (add-after 'unpack 'change-dir
1454 (lambda _
1455 (chdir "readline-0.0")))
1456 (delete 'configure)
1457 (replace 'build
1458 (lambda _
1459 (invoke #$(cc-for-target) "-O2" "-fPIC" "C-readline.c"
1460 "-llua" "-lreadline" "-shared" "-o" shared-object)))
1461 (replace 'install
1462 (lambda _
1463 (install-file shared-object lua-cpath)
1464 (install-file "readline.lua" lua-path)))))))
1465 (inputs (list lua readline))
1466 (home-page "https://peterbillam.gitlab.io/pjb_lua/lua/readline.html")
1467 (synopsis "Simple Lua interface to the readline and history libraries")
1468 (description
1469 "This Lua module offers an interface to the GNU readline library.
1470
1471The function @code{readline()} is a wrapper, which invokes the GNU readline,
1472adds the line to the end of the history list, and then returns the line.
1473Usually you call @code{save_history()} before the program exits,
1474so that the history list is saved to the @code{histfile}.
1475
1476This Lua module can dialogue with the user on the controlling-terminal
1477of the process (typically @file{/dev/tty}) as returned by @code{ctermid()}.
1478It also support most of readline's alternative interface, namely
1479@code{handler_install}, @code{read_char} and @code{handler_remove},
1480and readline's custom completion.")
1481 (license license:expat)))
1482
1483(define-public-lua-variants lua-readline
1484 (lua-5.5 lua5.5-readline)
1485 (lua-5.4 lua5.4-readline)
1486 (lua-5.3 lua5.3-readline)
1487 (lua-5.2 lua5.2-readline)
1488 (lua-5.1 lua5.1-readline))
1489
1490(define-public lua-scintillua
1491 (package
1492 (name "lua-scintillua")
1493 (version "6.6")
1494 (source
1495 (origin
1496 (method git-fetch)
1497 (uri (git-reference
1498 (url "https://github.com/orbitalquark/scintillua")
1499 (commit (string-append "scintillua_" version))))
1500 (file-name (git-file-name name version))
1501 (sha256
1502 (base32 "121ilpy91wyprqp3la4xzbb60i2yp1xpnvjlahzgzg0vck48njm7"))))
1503 (build-system gnu-build-system)
1504 (arguments
1505 (list
1506 #:phases
1507 #~(let* ((lua-api-version #$(this-lua-version))
1508 (lua-cpath (string-append "/lib/lua/" lua-api-version))
1509 (lua-path (string-append "/share/lua/" lua-api-version))
1510 (scintillua (string-append #$output lua-path "/scintillua"))
1511 (lexers (string-append scintillua "/lexers")))
1512 (modify-phases %standard-phases
1513 (delete 'configure)
1514 (delete 'build)
1515 (delete 'check) ;move after install
1516 (replace 'install
1517 (lambda _
1518 (mkdir-p scintillua)
1519 (copy-recursively "lexers" lexers)
1520 (substitute* (string-append lexers "/lexer.lua")
1521 (("package\\.path")
1522 (string-append "('" lexers "/?.lua;' .. package.path)")))
1523 (with-output-to-file (string-append scintillua "/init.lua")
1524 (lambda ()
1525 (display
1526 "return require'scintillua.lexers.lexer'\n")))))
1527 (add-after 'install 'set-lua-path
1528 (lambda* (#:key inputs #:allow-other-keys)
1529 (let ((input-dirs (map cdr (alist-delete "source" inputs))))
1530 (setenv "GUIX_LUA_CPATH"
1531 (string-join
1532 (map (lambda (prefix)
1533 (string-append prefix lua-cpath))
1534 input-dirs)
1535 ";"))
1536 (setenv "GUIX_LUA_PATH"
1537 (string-join
1538 (map (lambda (prefix)
1539 (string-append prefix lua-path))
1540 (cons #$output input-dirs))
1541 ";")))))
1542 (add-after 'set-lua-path 'check
1543 (lambda _
1544 (substitute* "tests.lua"
1545 (("^package\\.path = .*") "")
1546 (("require\\('lexer'\\)") "require'scintillua'")
1547 (("'lexers'") (string-append "'" lexers "'"))
1548 (("test_lua51" all)
1549 (string-append "skip_" all)))
1550 (invoke "lua" "tests.lua")))))))
1551 (native-inputs (list lua))
1552 (propagated-inputs (list lua-lpeg lua-filesystem))
1553 (home-page "https://orbitalquark.github.io/scintillua/")
1554 (synopsis "Collection of LPeg lexer for source code")
1555 (description
1556 "This Lua library provides LPeg lexers for source code syntax
1557highlighting. It can either be used by itself or as a drop-in replacement
1558for Scintilla lexers.")
1559 (license license:expat)))
1560
1561(define-public-lua-variants lua-scintillua
1562 (lua-5.4 lua5.4-scintillua))
1563
1564(define-public lutok
1565 (package
1566 (name "lutok")
1567 (version "0.6.2")
1568 (source (origin
1569 (method git-fetch)
1570 (uri (git-reference
1571 (url "https://github.com/freebsd/lutok")
1572 (commit (string-append name "-" version))))
1573 (file-name (git-file-name name version))
1574 (sha256
1575 (base32
1576 "1hk8shp1vkxa09qxaafcfrgc9098cr75n5zc192bv8yjyvz0hvc3"))))
1577 (build-system gnu-build-system)
1578 ;; Disable the test suite to avoid a circular dependency on kyua.
1579 (arguments (list #:tests? #f))
1580 (native-inputs (list autoconf automake libtool pkg-config))
1581 (inputs (list atf))
1582 (propagated-inputs (list lua-5.4)) ;included in c_gate.hpp
1583 (home-page "https://github.com/freebsd/lutok")
1584 (synopsis "Lightweight C++ API for Lua")
1585 (description "Lutok is a lightweight C++ API library for Lua.
1586
1587Lutok provides thin C++ wrappers around the Lua C API to ease the interaction
1588between C++ and Lua. These wrappers make intensive use of @acronym{RAII,
1589Resource Acquisition is Initialization} to prevent resource leakage, expose
1590C++-friendly data types, report errors by means of exceptions and ensure that
1591the Lua stack is always left untouched in the face of errors. The library
1592also provides a small subset of miscellaneous utility functions built on top
1593of the wrappers.
1594
1595Lutok focuses on providing a clean and safe C++ interface; the drawback is
1596that it is not suitable for performance-critical environments. In order to
1597implement error-safe C++ wrappers on top of a Lua C binary library, Lutok adds
1598several layers or abstraction and error checking that go against the original
1599spirit of the Lua C API and thus degrade performance.")
1600 (license license:bsd-3)))
1601
1602(define-public selene
1603 (package
1604 (name "selene")
1605 (version "2017.08.25")
1606 (source (origin
1607 (method git-fetch)
1608 (uri (git-reference
1609 (url "https://github.com/jeremyong/Selene")
1610 ;; The release is quite old.
1611 (commit "ffe1ade2568d4cff5894552be8f43e63e379a4c9")))
1612 (file-name "Selene")
1613 (sha256
1614 (base32
1615 "1axrgv3rxxdsaf807lwvklfzicn6x6gpf35narllrnz9lg6hn508"))))
1616 (build-system cmake-build-system)
1617 (arguments
1618 `(#:configure-flags
1619 ;; lua pc file in CMakeLists.txt is lua5.3.pc
1620 '("-DLUA_PC_CFG=lua;lua-5.3;lua-5.1")
1621 #:phases
1622 ;; This is a header only library
1623 (modify-phases %standard-phases
1624 (delete 'build)
1625 (replace 'install
1626 (lambda* (#:key inputs outputs #:allow-other-keys)
1627 (let* ((output (assoc-ref outputs "out"))
1628 (source (assoc-ref inputs "source"))
1629 (includedir (string-append output "/include")))
1630 (copy-recursively
1631 (string-append source "/include")
1632 includedir))
1633 #t))
1634 ;; The path of test files are hard coded.
1635 (replace 'check
1636 (lambda* (#:key inputs outputs #:allow-other-keys)
1637 (let* ((output (assoc-ref outputs "out"))
1638 (source (assoc-ref inputs "source"))
1639 (builddir (getcwd))
1640 (testdir (string-append builddir "/test")))
1641 (copy-recursively (string-append source "/test") testdir)
1642 (invoke "make")
1643 (mkdir-p "runner")
1644 (copy-file "./test_runner" "./runner/test_runner")
1645 (chdir "./runner")
1646 (invoke "./test_runner")))))))
1647 (native-inputs
1648 (list lua pkg-config))
1649 (home-page "https://github.com/jeremyong/Selene")
1650 (synopsis "Lua C++11 bindings")
1651 (description
1652 "Selene is a simple C++11 header-only library enabling seamless
1653 interoperability between C++ and Lua programming language.")
1654 (license license:zlib)))
1655
1656(define-public lua-resty-core
1657 (package
1658 (name "lua-resty-core")
1659 (version "0.1.18")
1660 (source (origin
1661 (method git-fetch)
1662 (uri (git-reference
1663 (url "https://github.com/openresty/lua-resty-core")
1664 (commit (string-append "v" version))))
1665 (file-name (git-file-name name version))
1666 (sha256
1667 (base32
1668 "1c58hykwpg5zqbyhrcb703pzwbkih409v3bh2gady6z2kj9q32dw"))))
1669 (build-system trivial-build-system)
1670 (arguments
1671 `(#:modules ((guix build utils))
1672 #:builder
1673 (begin
1674 (use-modules (guix build utils))
1675 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1676 (package-lua-resty (lambda (input output)
1677 (mkdir-p (string-append output "/lib/lua"))
1678 (copy-recursively (string-append input "/lib/resty")
1679 (string-append output "/lib/lua/resty"))
1680 (copy-recursively (string-append input "/lib/ngx")
1681 (string-append output "/lib/ngx"))
1682 (symlink (string-append output "/lib/lua/resty")
1683 (string-append output "/lib/resty")))))
1684 (package-lua-resty (assoc-ref %build-inputs "source")
1685 (assoc-ref %outputs "out")))
1686 #t)))
1687 (home-page "https://github.com/openresty/lua-resty-core")
1688 (synopsis "Lua API for NGINX")
1689 (description "This package provides a FFI-based Lua API for
1690@code{ngx_http_lua_module} or @code{ngx_stream_lua_module}.")
1691 (license license:bsd-2)))
1692
1693(define-public lua-resty-lrucache
1694 (package
1695 (name "lua-resty-lrucache")
1696 (version "0.10")
1697 (source (origin
1698 (method git-fetch)
1699 (uri (git-reference
1700 (url "https://github.com/openresty/lua-resty-lrucache")
1701 (commit (string-append "v" version))))
1702 (file-name (git-file-name name version))
1703 (sha256
1704 (base32
1705 "1bsc54v1rvxmkwg7a2c01p192lvw5g576f589is8fy1m1c6v4ap8"))))
1706 (build-system trivial-build-system)
1707 (arguments
1708 `(#:modules ((guix build utils))
1709 #:builder
1710 (begin
1711 (use-modules (guix build utils))
1712 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1713 (package-lua-resty (lambda (input output)
1714 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1715 (copy-recursively (string-append input "/lib/resty")
1716 (string-append output "/lib/lua/" luajit-major+minor "/resty"))
1717 (symlink (string-append output "/lib/lua/" luajit-major+minor "/resty")
1718 (string-append output "/lib/resty")))))
1719 (package-lua-resty (assoc-ref %build-inputs "source")
1720 (assoc-ref %outputs "out")))
1721 #t)))
1722 (home-page "https://github.com/openresty/lua-resty-lrucache")
1723 (synopsis "Lua LRU cache based on the LuaJIT FFI")
1724 (description
1725 "This package provides Lua LRU cache based on the LuaJIT FFI.")
1726 (license license:bsd-2)))
1727
1728(define-public lua-resty-signal
1729 (package
1730 (name "lua-resty-signal")
1731 (version "0.02")
1732 (source (origin
1733 (method git-fetch)
1734 (uri (git-reference
1735 (url "https://github.com/openresty/lua-resty-signal")
1736 (commit (string-append "v" version))))
1737 (file-name (git-file-name name version))
1738 (sha256
1739 (base32
1740 "13y1pqn45y49mhqwywasfdsid46d0c33yi6mrnracbnmvyxz1cif"))))
1741 (build-system gnu-build-system)
1742 (arguments
1743 `(#:tests? #f ;TODO: Run the test suite.
1744 #:make-flags (list ,(string-append "CC=" (cc-for-target))
1745 (string-append "PREFIX=" %output))
1746 #:phases
1747 (modify-phases %standard-phases
1748 (delete 'configure)
1749 (add-after 'install 'install-lua
1750 (lambda* (#:key inputs outputs #:allow-other-keys)
1751 (use-modules (guix build utils))
1752 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1753 (package-lua-resty (lambda (input output)
1754 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1755 (copy-recursively (string-append input "/lib/resty")
1756 (string-append output "/lib/lua/" luajit-major+minor "/resty"))
1757 (symlink (string-append output "/lib/lua/" luajit-major+minor "/resty")
1758 (string-append output "/lib/resty")))))
1759 (package-lua-resty (assoc-ref inputs "source")
1760 (assoc-ref outputs "out")))
1761 #t)))))
1762 (home-page "https://github.com/openresty/lua-resty-signal")
1763 (synopsis "Lua library for killing or sending signals to Linux processes")
1764 (description "This package provides Lua library for killing or sending
1765signals to Linux processes.")
1766 (license license:bsd-3)))
1767
1768(define-public lua-tablepool
1769 (package
1770 (name "lua-tablepool")
1771 (version "0.01")
1772 (source (origin
1773 (method git-fetch)
1774 (uri (git-reference
1775 (url "https://github.com/openresty/lua-tablepool")
1776 (commit (string-append "v" version))))
1777 (file-name (git-file-name name version))
1778 (sha256
1779 (base32
1780 "03yjj3w6znvj6843prg84m0lkrn49l901f9hj9bgy3cj9s0awl6y"))))
1781 (build-system trivial-build-system)
1782 (arguments
1783 `(#:modules ((guix build utils))
1784 #:builder
1785 (begin
1786 (use-modules (guix build utils))
1787 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1788 (package-lua-resty (lambda (input output)
1789 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1790 (copy-recursively (string-append input "/lib")
1791 (string-append output "/lib")))))
1792 (package-lua-resty (assoc-ref %build-inputs "source")
1793 (assoc-ref %outputs "out")))
1794 #t)))
1795 (home-page "https://github.com/openresty/lua-tablepool")
1796 (synopsis "Lua table recycling pools for LuaJIT")
1797 (description "This package provides Lua table recycling pools for LuaJIT.")
1798 (license license:bsd-2)))
1799
1800(define-public lua-resty-shell
1801 (package
1802 (name "lua-resty-shell")
1803 (version "0.03")
1804 (source (origin
1805 (method git-fetch)
1806 (uri (git-reference
1807 (url "https://github.com/openresty/lua-resty-shell")
1808 (commit (string-append "v" version))))
1809 (file-name (git-file-name name version))
1810 (sha256
1811 (base32
1812 "1s6g04ip4hr97r2pd8ry3alq063604s9a3l0hn9nsidh81ps4dp7"))))
1813 (build-system trivial-build-system)
1814 (arguments
1815 `(#:modules ((guix build utils))
1816 #:builder
1817 (begin
1818 (use-modules (guix build utils))
1819 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1820 (package-lua-resty (lambda (input output)
1821 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1822 (copy-recursively (string-append input "/lib/resty")
1823 (string-append output "/lib/lua/" luajit-major+minor "/resty"))
1824 (symlink (string-append output "/lib/lua/" luajit-major+minor "/resty")
1825 (string-append output "/lib/resty")))))
1826 (package-lua-resty (assoc-ref %build-inputs "source")
1827 (assoc-ref %outputs "out")))
1828 #t)))
1829 (home-page "https://github.com/openresty/lua-resty-shell")
1830 (synopsis "Lua module for nonblocking system shell command executions")
1831 (description "This package provides Lua module for nonblocking system
1832shell command executions.")
1833 (license license:bsd-3)))
1834
1835(define-public luarocks
1836 (package
1837 (name "luarocks")
1838 (version "3.9.2")
1839 (home-page "https://luarocks.org/")
1840 (source (origin
1841 (method url-fetch)
1842 (uri (string-append "https://luarocks.org/releases/luarocks-"
1843 version ".tar.gz"))
1844 (sha256
1845 (base32
1846 "1nsfp7cwqcxa8vmkcqkgi5wc0iax0j3gbdfd183kw81cq3nf99mw"))))
1847 (build-system gnu-build-system)
1848 (arguments
1849 `(#:tests? #f ;upstream has no tests
1850 #:phases
1851 (modify-phases %standard-phases
1852 (add-before 'build 'patch-bin-sh
1853 (lambda* (#:key inputs #:allow-other-keys)
1854 (substitute* '("GNUmakefile" "src/luarocks/fs/unix.lua"
1855 "src/luarocks/core/sysdetect.lua")
1856 (("/bin/sh")
1857 (search-input-file inputs "/bin/sh")))))
1858 (replace 'configure
1859 (lambda* (#:key outputs #:allow-other-keys)
1860 (let ((out (assoc-ref outputs "out")))
1861 (invoke "./configure"
1862 (string-append "--prefix=" out)))))
1863 (add-after 'install 'patch-unzip
1864 (lambda* (#:key inputs outputs #:allow-other-keys)
1865 (substitute*
1866 (string-append
1867 (assoc-ref outputs "out") "/etc/luarocks/config-"
1868 ,(this-lua-version) ".lua") ;e.g. "5.2"
1869 (("variables = \\{")
1870 (string-append
1871 "variables = {\n"
1872 " AR = \"" (search-input-file inputs "/bin/ar") "\";\n"
1873 " BUNZIP2 = \"" (search-input-file inputs "/bin/bunzip2") "\";\n"
1874 " CC = \"" (search-input-file inputs "/bin/gcc") "\";\n"
1875 " CHMOD = \"" (search-input-file inputs "/bin/chmod") "\";\n"
1876 " CP = \"" (search-input-file inputs "/bin/cp") "\";\n"
1877 " CURL = \"" (search-input-file inputs "/bin/curl") "\";\n"
1878 " FIND = \"" (search-input-file inputs "/bin/find") "\";\n"
1879 " GIT = \"" (search-input-file inputs "/bin/git") "\";\n"
1880 " GPG = \"" (search-input-file inputs "/bin/gpg") "\";\n"
1881 " GUNZIP = \"" (search-input-file inputs "/bin/gunzip") "\";\n"
1882 " HG = \"" (search-input-file inputs "/bin/hg") "\";\n"
1883 " LD = \"" (search-input-file inputs "/bin/ld") "\";\n"
1884 " LS = \"" (search-input-file inputs "/bin/ls") "\";\n"
1885 " MAKE = \"" (search-input-file inputs "/bin/make") "\";\n"
1886 " MD5SUM = \"" (search-input-file inputs "/bin/md5sum") "\";\n"
1887 " MKDIR = \"" (search-input-file inputs "/bin/mkdir") "\";\n"
1888 " MKTEMP = \"" (search-input-file inputs "/bin/mktemp") "\";\n"
1889 " OPENSSL = \"" (search-input-file inputs "/bin/openssl") "\";\n"
1890 " PWD = \"" (search-input-file inputs "/bin/pwd") "\";\n"
1891 " RANLIB = \"" (search-input-file inputs "/bin/ranlib") "\";\n"
1892 " RM = \"" (search-input-file inputs "/bin/rm") "\";\n"
1893 " RMDIR = \"" (search-input-file inputs "/bin/rmdir") "\";\n"
1894 " RSYNC = \"" (search-input-file inputs "/bin/rsync") "\";\n"
1895 " SCP = \"" (search-input-file inputs "/bin/scp") "\";\n"
1896 " TAR = \"" (search-input-file inputs "/bin/tar") "\";\n"
1897 " TEST = \"" (search-input-file inputs "/bin/test") "\";\n"
1898 " TOUCH = \"" (search-input-file inputs "/bin/touch") "\";\n"
1899 " UNZIP = \"" (search-input-file inputs "/bin/unzip") " -n\";\n"
1900 " WGET = \"" (search-input-file inputs "/bin/wget") "\";\n"
1901 " ZIP = \"" (search-input-file inputs "/bin/zip") "\";"))))))))
1902 (inputs (list lua
1903 bash-minimal
1904 ;; Executables required by luarocks.
1905 binutils
1906 bzip2
1907 coreutils
1908 curl
1909 findutils
1910 gcc
1911 git
1912 gnupg
1913 gzip
1914 gnu-make
1915 mercurial
1916 openssh
1917 openssl
1918 rsync
1919 tar
1920 unzip
1921 wget
1922 zip))
1923 (native-inputs (list unzip))
1924 (synopsis "Package manager for Lua modules")
1925 (description
1926 "LuaRocks is the package manager for the Lua programming
1927language.
1928
1929It allows you to install Lua modules as self-contained packages called
1930@url{https://luarocks.org/en/Types_of_rocks, @emph{rocks}}, which also contain
1931version @url{https://luarocks.org/en/Dependencies, dependency} information.
1932This information can be used both during installation, so that when one rock
1933is requested all rocks it depends on are installed as well, and also
1934optionally at run time, so that when a module is required, the correct version
1935is loaded. LuaRocks supports both local and
1936@url{http://luarocks.org/en/Rocks_repositories, remote} repositories, and
1937multiple local rocks trees.")
1938 (license license:expat)))
1939
1940;; Luarocks doesn't use the usual "lua-" prefix, so it doesn't play nicely with
1941;; our standard rewriter. Make a custom one just for this case for now.
1942(define luarocks-5.2-rewriter
1943 (make-lua-rewriter lua-5.2 "luarocks" "lua5.2-luarocks"))
1944
1945(define-public lua5.2-luarocks
1946 (luarocks-5.2-rewriter luarocks))
1947
1948(define-public dkjson
1949 (package
1950 (name "dkjson")
1951 (version "2.8")
1952 (source
1953 (origin
1954 (method url-fetch)
1955 (uri (string-append "https://dkolf.de/dkjson-lua/dkjson-" version ".lua"))
1956 (sha256
1957 (base32 "0i3x9qzx2m25fpf1pd6j45imm1gpykpjxibbvfi9bcwgd1hg2fzb"))))
1958 (build-system trivial-build-system)
1959 (arguments
1960 (list
1961 #:modules '((guix build utils))
1962 #:builder
1963 #~(begin
1964 (use-modules (guix build utils))
1965 (let* ((luajit-major+minor
1966 #$(version-major+minor (package-version lua)))
1967 (lua-dir
1968 (string-append #$output "/share/lua/" luajit-major+minor)))
1969 (mkdir-p lua-dir)
1970 (copy-file #$source (string-append lua-dir "/dkjson.lua"))))))
1971 (inputs (list lua))
1972 (synopsis "JSON module for Lua")
1973 (description
1974 "dkjson is a lua module for processing json in lua. It can handle tasks
1975 like encoding or decoding JSON objects to and from lua tables.")
1976 (home-page "https://dkolf.de/dkjson-lua/")
1977 (license license:expat)))
1978
1979(define-public fennel
1980 (package
1981 (name "fennel")
1982 (version "1.6.1")
1983 (source (origin
1984 (method git-fetch)
1985 (uri (git-reference
1986 (url "https://git.sr.ht/~technomancy/fennel")
1987 (commit version)))
1988 (file-name (git-file-name name version))
1989 (sha256
1990 (base32
1991 "0n58410gmxfnmgggdw6ap12fa68z5s7f83487b2apim52a8wpd9h"))))
1992 (build-system gnu-build-system)
1993 (arguments
1994 (list #:make-flags #~(list (string-append "PREFIX=" #$output))
1995 #:test-target "test"
1996 #:phases #~(modify-phases %standard-phases
1997 (delete 'configure)
1998 (add-after 'build 'patch-fennel
1999 (lambda* (#:key inputs #:allow-other-keys)
2000 ;; Remove IRC CI build status reporting
2001 (delete-file "test/irc.lua")
2002 (substitute* "test/init.lua"
2003 ((",\\{hooks=\\{exit=dofile\\(\"test/irc.lua\"\\)\\}\\}")
2004 ""))
2005 (substitute* "fennel"
2006 (("/usr/bin/env .*lua")
2007 (search-input-file inputs "/bin/lua")))))
2008 (delete 'check)
2009 (add-after 'install 'wrap
2010 (lambda _
2011 (wrap-program (string-append #$output "/bin/fennel")
2012 `("GUIX_LUA_CPATH" ";" suffix
2013 (,(getenv "GUIX_LUA_CPATH")))
2014 `("GUIX_LUA_PATH" ";" suffix
2015 (,(getenv "GUIX_LUA_PATH"))))))
2016 (add-after 'wrap 'check
2017 (assoc-ref %standard-phases
2018 'check)))))
2019 (inputs (list lua lua-readline))
2020 (home-page "https://fennel-lang.org/")
2021 (synopsis "Lisp that compiles to Lua")
2022 (description
2023 "Fennel is a programming language that brings together the speed,
2024simplicity, and reach of Lua with the flexibility of a Lisp syntax and macro
2025system.")
2026 (license license:expat)))
2027
2028(define-public antifennel
2029 (package
2030 (version "0.2.0")
2031 (name "antifennel")
2032 (source
2033 (origin
2034 (method git-fetch)
2035 (uri (git-reference
2036 (url "https://git.sr.ht/~technomancy/antifennel")
2037 (commit version)))
2038 (sha256
2039 (base32 "1hd9h17q31b3gg88c657zq4han4air2ag55rrakbmcpy6n8acsqc"))
2040 (file-name (git-file-name name version))))
2041 (build-system gnu-build-system)
2042 (inputs (list luajit))
2043 (arguments
2044 (list
2045 #:phases #~(modify-phases %standard-phases
2046 (delete 'configure)
2047 ;; Tests pass after the fix introduced by the commit
2048 ;; ecd2169fcad1fa6616fdf6e6a8569f5b866601e5
2049 (delete 'check)
2050 (replace 'install
2051 (lambda _
2052 (install-file "antifennel"
2053 (string-append #$output "/bin")))))))
2054 (home-page "https://git.sr.ht/~technomancy/antifennel")
2055 (synopsis "Turn Lua code into Fennel code")
2056 (description
2057 "This package provides a way to turn Lua code into Fennel code.
2058This compiler does the opposite of what the Fennel compiler does.")
2059 (license license:expat)))
2060
2061(define-public fnlfmt
2062 (package
2063 (name "fnlfmt")
2064 (version "0.3.0")
2065 (source (origin
2066 (method git-fetch)
2067 (uri (git-reference
2068 (url "https://git.sr.ht/~technomancy/fnlfmt")
2069 (commit version)))
2070 (file-name (git-file-name name version))
2071 (sha256
2072 (base32
2073 "06gzw7f20yw4192kymr4karxw3ia3apjnjqpm6vxph87c67d1fa3"))
2074 (modules '((guix build utils)))
2075 (snippet
2076 #~(begin
2077 ;; Use input fennel instead of bundled fennel.
2078 (delete-file "fennel")
2079 (delete-file "fennel.lua")
2080 (substitute* "Makefile"
2081 (("./fennel") "fennel"))))))
2082 (build-system gnu-build-system)
2083 (arguments
2084 `(#:modules ((guix build gnu-build-system)
2085 (guix build utils)
2086 (ice-9 match))
2087 #:test-target "test"
2088 #:phases
2089 (modify-phases %standard-phases
2090 (delete 'configure)
2091 (add-before 'build 'patch-makefile
2092 (lambda* (#:key native-inputs inputs #:allow-other-keys)
2093 (substitute* "Makefile"
2094 ;; Patch lua shebang that gets inserted to fnlfmt.
2095 (("/usr/bin/env lua")
2096 (search-input-file (or native-inputs inputs) "/bin/lua")))))
2097 (replace 'install
2098 ;; There is no install target; manually install the output file.
2099 (lambda* (#:key outputs #:allow-other-keys)
2100 (let* ((out (assoc-ref outputs "out"))
2101 (bin (string-append out "/bin")))
2102 (for-each (lambda (file)
2103 (install-file file bin))
2104 (find-files "." "fnlfmt")))))
2105 (add-after 'install 'wrap
2106 (lambda* (#:key outputs #:allow-other-keys)
2107 (let* ((fnlfmt (assoc-ref outputs "out")))
2108 (wrap-program (string-append fnlfmt "/bin/fnlfmt")
2109 `("GUIX_LUA_PATH" ";" suffix (,(getenv "GUIX_LUA_PATH"))))
2110 #t))))))
2111 (inputs (list bash-minimal))
2112 (native-inputs (list lua fennel))
2113 (home-page "https://git.sr.ht/~technomancy/fnlfmt")
2114 (synopsis "Automatic formatting of Fennel code")
2115 (description
2116 "Fnlfmt is a tool for automatically formatting Fennel code in a consistent
2117way, following established lisp conventions.")
2118 (license license:lgpl3+)))
2119
2120(define-public fennel-ls
2121 (package
2122 (name "fennel-ls")
2123 (version "0.2.3")
2124 (source
2125 (origin
2126 (method git-fetch)
2127 (uri (git-reference
2128 (url "https://git.sr.ht/~xerool/fennel-ls")
2129 (commit version)))
2130 (file-name (git-file-name name version))
2131 (sha256
2132 (base32 "1fyyd6yg8xrb572hvk76yi9ga1ysrn6j40phf8ickav3s28i4k85"))))
2133 (build-system gnu-build-system)
2134 (arguments
2135 (list
2136 #:make-flags #~(list "VENDOR=false")
2137 #:tests? #f ; tests require additional dependencies
2138 #:phases
2139 #~(let ((luajit-major+minor
2140 #$(version-major+minor (package-version lua))))
2141 (modify-phases %standard-phases
2142 (delete 'configure)
2143 (add-before 'build 'rm-vendored-deps
2144 (lambda _
2145 (delete-file-recursively "fennel")
2146 (delete-file-recursively "deps/")))
2147 (replace 'install
2148 (lambda _
2149 (install-file "fennel-ls"
2150 (string-append #$output "/bin"))))
2151 (add-after 'install 'wrap
2152 (lambda _
2153 (wrap-program (string-append #$output "/bin/fennel-ls")
2154 `("GUIX_LUA_PATH" ";" prefix (,(getenv "GUIX_LUA_PATH"))))))))))
2155 (inputs (list bash-minimal lua fennel pandoc dkjson))
2156 (synopsis "Language server for Fennel")
2157 (description
2158 "Fennel Language Server is a language server for the Fennel programming
2159 language.")
2160 (home-page "https://git.sr.ht/~xerool/fennel-ls")
2161 (license license:expat)))
2162
2163(define-public lua-lunitx
2164 (package
2165 (name "lua-lunitx")
2166 (version "0.8.2")
2167 (source (origin
2168 (method git-fetch)
2169 (uri (git-reference
2170 ;; Upstream repository name is "lunit", but it provides
2171 ;; both lunit and lunitx modules.
2172 (url "https://github.com/dcurrie/lunit")
2173 (commit version)))
2174 (file-name (git-file-name name version))
2175 (sha256
2176 (base32
2177 "0y9szbd2g8xk63s8781bjmw8sv3s5m6rnv47kh1sk21ml3mxi69y"))))
2178 (build-system trivial-build-system)
2179 (arguments
2180 (list
2181 #:modules '((guix build utils))
2182 #:builder
2183 #~(begin
2184 (use-modules (guix build utils))
2185 (let* ((lua (string-append #$(this-package-native-input "lua") "/bin/lua"))
2186 (lua-version #$(this-lua-version))
2187 (lua-dir (string-append #$output "/share/lua/" lua-version)))
2188 (when #$(not (%current-target-system))
2189 (with-directory-excursion (string-append #$source "/lua")
2190 (invoke lua "../test/selftest.lua")))
2191 (mkdir-p lua-dir)
2192 (copy-recursively (string-append #$source "/lua") lua-dir)))))
2193 (native-inputs (list lua))
2194 (home-page "https://github.com/dcurrie/lunit")
2195 (synopsis "Unit testing framework for Lua")
2196 (description "Lunit is a unit testing framework for Lua. It includes
2197lunitx extensions adding Lua 5.2 compatibility via @code{lunit.module} and
2198the @code{lunitx} module for running tests automatically at program exit.")
2199 (license license:expat)))
2200
2201(define-public-lua-variants lua-lunitx
2202 (lua-5.4 lua5.4-lunitx)
2203 (lua-5.3 lua5.3-lunitx)
2204 (lua-5.2 lua5.2-lunitx)
2205 (lua-5.1 lua5.1-lunitx))
2206
2207(define-public lua-lsqlite3
2208 (package
2209 (name "lua-lsqlite3")
2210 (version "0.9.6")
2211 (source (origin
2212 (method url-fetch)
2213 (uri "https://lua.sqlite.org/home/zip/lsqlite3_v096.zip")
2214 (file-name (string-append "lsqlite3-v" version ".zip"))
2215 (sha256
2216 (base32
2217 "10md6bfvbzflrhz4n75jr1ppmz86mwsip85llny23w2ld9iygipc"))))
2218 (build-system gnu-build-system)
2219 (arguments
2220 (list
2221 #:tests? (not (%current-target-system))
2222 #:phases
2223 #~(modify-phases %standard-phases
2224 (delete 'configure)
2225 (replace 'build
2226 (lambda _
2227 (invoke #$(cc-for-target) "-fPIC" "-shared" "-O2"
2228 "-o" "lsqlite3.so"
2229 "lsqlite3.c"
2230 "-llua" "-lsqlite3")))
2231 (replace 'install
2232 (lambda* (#:key outputs #:allow-other-keys)
2233 (let* ((out (assoc-ref outputs "out"))
2234 (lua-version #$(this-lua-version))
2235 (cmod-dir (string-append out "/lib/lua/" lua-version)))
2236 (install-file "lsqlite3.so" cmod-dir))))
2237 (delete 'check)
2238 (add-after 'install 'check
2239 (lambda* (#:key tests? outputs #:allow-other-keys)
2240 (when tests?
2241 ;; Built only for the upstream test suite (test-dyld.lua).
2242 (invoke #$(cc-for-target) "-fPIC" "-shared" "-O2"
2243 "-o" "extras/libsqlitefunctions.so"
2244 "extras/extension-functions.c"
2245 "-lsqlite3")
2246 ;; Only test the dynamic lsqlite3 module; lsqlite3complete
2247 ;; (SQLite amalgamation) is not built by this package.
2248 (invoke "lua" "test/tests-sqlite3.lua" "lsqlite3")
2249 (invoke "lua" "test/test.lua")
2250 (invoke "lua" "test/test-dyld.lua")))))))
2251 (native-inputs (list unzip lua-lunitx))
2252 (inputs (list lua sqlite))
2253 (home-page "https://lua.sqlite.org/")
2254 (synopsis "SQLite3 binding for Lua")
2255 (description "LuaSQLite3 is a thin wrapper around the public domain
2256SQLite3 database engine. It provides a complete binding to the SQLite3 C API
2257from within Lua programs.")
2258 (license license:expat)))
2259
2260(define-public-lua-variants lua-lsqlite3
2261 (lua-5.4 lua5.4-lsqlite3)
2262 (lua-5.3 lua5.3-lsqlite3)
2263 (lua-5.2 lua5.2-lsqlite3)
2264 (lua-5.1 lua5.1-lsqlite3))
2265
2266(define-public lua-unbound
2267 (package
2268 (name "lua-unbound")
2269 (version "1.1.0")
2270 (source
2271 (origin
2272 (method hg-fetch)
2273 (uri (hg-reference
2274 (url "https://hg.sr.ht/~zash/luaunbound")
2275 (changeset version)))
2276 (file-name (hg-file-name name version))
2277 (sha256
2278 (base32 "17q5n9h1hnlx00x4k3h93rwyy41gfpd42yyp13rqkhhkmimw6q2y"))))
2279 (build-system gnu-build-system)
2280 (arguments
2281 (list
2282 #:tests? #f ;no test
2283 #:make-flags
2284 #~(let ((lua-version #$(this-lua-version)))
2285 (list
2286 (string-append "CC=" #$(cc-for-target))
2287 (string-append "LUA_VERSION=" lua-version)
2288 (string-append "LUA_LIBDIR=/lib/lua/" lua-version)
2289 (string-append "MYLDFLAGS=-L"
2290 #$(this-package-input "unbound") "/lib")
2291 (string-append "DESTDIR=" #$output)))
2292 #:phases
2293 #~(modify-phases %standard-phases
2294 (delete 'configure))))
2295 (native-inputs (list pkg-config))
2296 (inputs (list lua unbound))
2297 (home-page "https://www.zash.se/luaunbound.html")
2298 (synopsis "Unbound binding for Lua")
2299 (description
2300 "This is a binding to libunbound for Lua, allowing both asynchronous
2301and DNSSEC-secured DNS lookups of arbitrary DNS record types.
2302
2303It was created because Prosody needs an asynchronous DNS library with support
2304for SRV records, and the ones found at the time did one or the other, or was
2305missing DNSSEC that allowed implementing DANE.
2306
2307It originated out of a need in the XMPP server software Prosody for an
2308async-capable resolver library supporting SRV records, as well as a desire to
2309experiment with DNSSEC and new DNS records.")
2310 (license license:expat)))
2311
2312(define-public-lua-variants lua-unbound
2313 (lua-5.5 lua5.5-unbound)
2314 (lua-5.4 lua5.4-unbound)
2315 (lua-5.3 lua5.3-unbound)
2316 (lua-5.2 lua5.2-unbound))