projects/guix·blob haskell-team · refs

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