projects/guix·blob wip-postfix · refs

1290 lines · 52.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 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;;;
23;;; This file is part of GNU Guix.
24;;;
25;;; GNU Guix is free software; you can redistribute it and/or modify it
26;;; under the terms of the GNU General Public License as published by
27;;; the Free Software Foundation; either version 3 of the License, or (at
28;;; your option) any later version.
29;;;
30;;; GNU Guix is distributed in the hope that it will be useful, but
31;;; WITHOUT ANY WARRANTY; without even the implied warranty of
32;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33;;; GNU General Public License for more details.
34;;;
35;;; You should have received a copy of the GNU General Public License
36;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
37
38(define-module (gnu packages lua)
39 #:use-module ((guix licenses) #:prefix license:)
40 #:use-module (guix packages)
41 #:use-module (guix download)
42 #:use-module (guix git-download)
43 #:use-module (guix gexp)
44 #:use-module (guix utils)
45 #:use-module (guix build-system gnu)
46 #:use-module (guix build-system cmake)
47 #:use-module (guix build-system meson)
48 #:use-module (guix build-system trivial)
49 #:use-module (gnu packages)
50 #:use-module (gnu packages bash)
51 #:use-module (gnu packages boost)
52 #:use-module (gnu packages build-tools)
53 #:use-module (gnu packages glib)
54 #:use-module (gnu packages gtk)
55 #:use-module (gnu packages libevent)
56 #:use-module (gnu packages libffi)
57 #:use-module (gnu packages m4)
58 #:use-module (gnu packages ncurses)
59 #:use-module (gnu packages pkg-config)
60 #:use-module (gnu packages pretty-print)
61 #:use-module (gnu packages re2c)
62 #:use-module (gnu packages readline)
63 #:use-module (gnu packages tls)
64 #:use-module (gnu packages vim)
65 #:use-module (gnu packages xml)
66 #:use-module (gnu packages xorg)
67 #:use-module (srfi srfi-1))
68
69(define-public lua
70 (package
71 (name "lua")
72 (version "5.3.5")
73 (source (origin
74 (method url-fetch)
75 (uri (string-append "https://www.lua.org/ftp/lua-"
76 version ".tar.gz"))
77 (sha256
78 (base32 "1b2qn2rv96nmbm6zab4l877bd4zq7wpwm8drwjiy2ih4jqzysbhc"))
79 (patches (search-patches "lua-pkgconfig.patch"
80 "lua-liblua-so.patch"))))
81 (build-system gnu-build-system)
82 (inputs (list readline))
83 (arguments
84 `(#:modules ((guix build gnu-build-system)
85 (guix build utils)
86 (srfi srfi-1))
87 #:test-target "test"
88 #:make-flags
89 (list "MYCFLAGS=-fPIC -DLUA_DL_DLOPEN"
90 (string-append "CC=" ,(cc-for-target))
91 (string-append "SYSLIBS=-L" (assoc-ref %build-inputs "readline")
92 "/lib")
93 "linux")
94 #:phases
95 (modify-phases %standard-phases
96 (delete 'configure)
97 (replace 'install
98 (lambda* (#:key outputs #:allow-other-keys)
99 (let ((out (assoc-ref outputs "out")))
100 (invoke "make" "install"
101 (string-append "INSTALL_TOP=" out)
102 (string-append "INSTALL_MAN=" out
103 "/share/man/man1"))))))))
104 (home-page "https://www.lua.org/")
105 (synopsis "Embeddable scripting language")
106 (description
107 "Lua is a powerful, fast, lightweight, embeddable scripting language. Lua
108combines simple procedural syntax with powerful data description constructs
109based on associative arrays and extensible semantics. Lua is dynamically typed,
110runs by interpreting bytecode for a register-based virtual machine, and has
111automatic memory management with incremental garbage collection, making it ideal
112for configuration, scripting, and rapid prototyping.")
113 (license license:x11)))
114
115(define-public lua-5.4
116 (package (inherit lua)
117 (version "5.4.3")
118 (source (origin
119 (method url-fetch)
120 (uri (string-append "https://www.lua.org/ftp/lua-"
121 version ".tar.gz"))
122 (sha256
123 (base32 "1yxvjvnbg4nyrdv10bq42gz6dr66pyan28lgzfygqfwy2rv24qgq"))
124 (patches (search-patches "lua-5.4-pkgconfig.patch"
125 "lua-5.4-liblua-so.patch"))))))
126
127(define-public lua-5.2
128 (package (inherit lua)
129 (version "5.2.4")
130 (source
131 (origin
132 (method url-fetch)
133 (uri (string-append "https://www.lua.org/ftp/lua-"
134 version ".tar.gz"))
135 (sha256
136 (base32 "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr"))
137 (patches (search-patches "lua-pkgconfig.patch"
138 "lua-liblua-so.patch"))))))
139
140(define-public lua-5.1
141 (package (inherit lua)
142 (version "5.1.5")
143 (source (origin
144 (method url-fetch)
145 (uri (string-append "https://www.lua.org/ftp/lua-"
146 version ".tar.gz"))
147 (sha256
148 (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))
149 (patches (search-patches "lua51-liblua-so.patch"
150 "lua-CVE-2014-5461.patch"
151 "lua51-pkgconfig.patch"))))))
152
153(define-public luajit
154 (let ((branch "2.1.0-beta3")
155 (commit "6c4826f12c4d33b8b978004bc681eb1eef2be977"))
156 (package
157 (name "luajit")
158 (version (git-version branch "0" commit))
159 (source (origin
160 (method git-fetch)
161 (uri (git-reference
162 (url "https://luajit.org/git/luajit.git")
163 (commit commit)))
164 (file-name (git-file-name name version))
165 (sha256
166 (base32
167 "1a002yh8v1i1q9w09494q0b8vsbmw3amn9jgfs5qnz7ba54jij0q"))))
168 (build-system gnu-build-system)
169 (arguments
170 `(#:tests? #f ; luajit is distributed without tests
171 #:phases
172 (modify-phases %standard-phases
173 (delete 'configure) ; no configure script
174 (add-after 'install 'create-luajit-symlink
175 (lambda* (#:key outputs #:allow-other-keys)
176 (let* ((out (assoc-ref outputs "out"))
177 (bin (string-append out "/bin")))
178 (with-directory-excursion bin
179 (symlink ,(string-append name "-" branch)
180 ,name))))))
181 #:make-flags (list (string-append "PREFIX="
182 (assoc-ref %outputs "out")))))
183 (home-page "https://www.luajit.org/")
184 (synopsis
185 "Just in time compiler for Lua programming language version 5.1")
186 ;; On powerpc64le-linux, the build fails with an error: "No support for
187 ;; PowerPC 64 bit mode (yet)". See: https://issues.guix.gnu.org/49220
188 (supported-systems (fold delete %supported-systems
189 (list "powerpc64le-linux" "riscv64-linux")))
190 (description
191 "LuaJIT is a Just-In-Time Compiler (JIT) for the Lua
192programming language. Lua is a powerful, dynamic and light-weight programming
193language. It may be embedded or used as a general-purpose, stand-alone
194language.")
195 (license license:x11))))
196
197(define-public luajit-lua52-openresty
198 (package
199 (inherit luajit)
200 (name "luajit-lua52-openresty")
201 (version "2.1-20201229")
202 (source
203 (origin
204 (method git-fetch)
205 (uri (git-reference
206 (url "https://github.com/openresty/luajit2.git")
207 (commit (string-append "v" version))))
208 (file-name (git-file-name name version))
209 (sha256
210 (base32 "07haj27kbpbnkv836c2nd36h2xislrmri52w0zbpxvl68xk6g96p"))))
211 (arguments
212 `(#:tests? #f ;no test
213 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
214 #:phases
215 (modify-phases %standard-phases
216 (delete 'configure) ;no configure script
217 (add-after 'unpack 'enable-lua52-compat
218 (lambda _
219 (substitute* "src/Makefile"
220 (("#(XCFLAGS\\+= -DLUAJIT_ENABLE_LUA52COMPAT)" _ flag) flag))
221 #t)))))
222 (home-page "https://github.com/openresty/luajit2")
223 (synopsis "OpenResty's Branch of LuaJIT 2")
224 (description
225 "This is the official OpenResty branch of LuaJIT. It is not to be
226considered a fork, since changes are regularly synchronized from the upstream
227LuaJIT project. This package also enables the Lua 5.2 compat mode needed by
228some projects.")))
229
230(define (make-lua-expat name lua)
231 (package
232 (name name)
233 (version "1.3.0")
234 (source (origin
235 (method url-fetch)
236 (uri (string-append "https://matthewwild.co.uk/projects/"
237 "luaexpat/luaexpat-" version ".tar.gz"))
238 (sha256
239 (base32
240 "1hvxqngn0wf5642i5p3vcyhg3pmp102k63s9ry4jqyyqc1wkjq6h"))))
241 (build-system gnu-build-system)
242 (arguments
243 `(#:make-flags
244 (let ((out (assoc-ref %outputs "out"))
245 (lua-version ,(version-major+minor (package-version lua))))
246 (list ,(string-append "CC=" (cc-for-target))
247 (string-append "LUA_LDIR=" out "/share/lua/" lua-version)
248 (string-append "LUA_CDIR=" out "/lib/lua/" lua-version)))
249 #:phases
250 (modify-phases %standard-phases
251 (delete 'configure)
252 (replace 'check
253 (lambda _
254 (setenv "LUA_CPATH" "src/?.so;;")
255 (setenv "LUA_PATH" "src/?.lua;;")
256 (invoke "lua" "tests/test.lua")
257 (invoke "lua" "tests/test-lom.lua"))))))
258 (inputs
259 (list lua expat))
260 (home-page "https://matthewwild.co.uk/projects/luaexpat/")
261 (synopsis "SAX XML parser based on the Expat library")
262 (description "LuaExpat is a SAX XML parser based on the Expat library.")
263 (license (package-license lua-5.1))))
264
265(define-public lua5.1-expat
266 (make-lua-expat "lua5.1-expat" lua-5.1))
267
268(define-public lua5.2-expat
269 (make-lua-expat "lua5.2-expat" lua-5.2))
270
271(define (make-lua-socket name lua)
272 (package
273 (name name)
274 (version "3.0-rc1")
275 (source (origin
276 (method git-fetch)
277 (uri (git-reference
278 (url "https://github.com/diegonehab/luasocket")
279 (commit (string-append "v" version))))
280 (file-name (git-file-name name version))
281 (sha256
282 (base32
283 "1chs7z7a3i3lck4x7rz60ziwbf793gw169hpjdfca8y4yf1hzsxk"))))
284 (build-system gnu-build-system)
285 (arguments
286 `(#:make-flags
287 (let ((out (assoc-ref %outputs "out"))
288 (lua-version ,(version-major+minor (package-version lua))))
289 (list (string-append "INSTALL_TOP=" out)
290 (string-append "LUAV?=" lua-version)))
291 #:phases
292 (modify-phases %standard-phases
293 (delete 'configure)
294 (replace 'check
295 (lambda _
296 (setenv "LUA_CPATH" (string-append "src/?.so." ,version ";;"))
297 (setenv "LUA_PATH" "src/?.lua;;")
298 (when (zero? (primitive-fork))
299 (invoke "lua" "test/testsrvr.lua"))
300 (invoke "lua" "test/testclnt.lua"))))))
301 (inputs
302 (list lua))
303 (home-page "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/")
304 (synopsis "Socket library for Lua")
305 (description "LuaSocket is a Lua extension library that is composed by two
306parts: a C core that provides support for the TCP and UDP transport layers,
307and a set of Lua modules that add support for functionality commonly needed by
308applications that deal with the Internet.
309
310Among the supported modules, the most commonly used implement the
311SMTP (sending e-mails), HTTP (WWW access) and FTP (uploading and downloading
312files) client protocols. These provide a very natural and generic interface
313to the functionality defined by each protocol. In addition, you will find
314that the MIME (common encodings), URL (anything you could possible want to do
315with one) and LTN12 (filters, sinks, sources and pumps) modules can be very
316handy.")
317 (license license:expat)))
318
319(define-public lua5.1-socket
320 (make-lua-socket "lua5.1-socket" lua-5.1))
321
322(define-public lua5.2-socket
323 (make-lua-socket "lua5.2-socket" lua-5.2))
324
325(define (make-lua-filesystem name lua)
326 (package
327 (name name)
328 (version "1.7.0.2")
329 (source (origin
330 (method git-fetch)
331 (uri (git-reference
332 (url "https://github.com/keplerproject/luafilesystem")
333 (commit (string-append "v"
334 (string-join
335 (string-split version #\.) "_")))))
336 (file-name (git-file-name name version))
337 (sha256
338 (base32
339 "0zmprgkm9zawdf9wnw0v3w6ibaj442wlc6alp39hmw610fl4vghi"))))
340 (build-system gnu-build-system)
341 (arguments
342 `(#:make-flags
343 (let ((out (assoc-ref %outputs "out"))
344 (lua-version ,(version-major+minor (package-version lua))))
345 (list (string-append "PREFIX=" out)
346 (string-append "LUA_LIBDIR=" out "/lib/lua/" lua-version)))
347 #:test-target "test"
348 #:phases
349 (modify-phases %standard-phases
350 (delete 'configure))))
351 (inputs
352 (list lua))
353 (home-page "https://keplerproject.github.io/luafilesystem/index.html")
354 (synopsis "File system library for Lua")
355 (description "LuaFileSystem is a Lua library developed to complement the
356set of functions related to file systems offered by the standard Lua
357distribution. LuaFileSystem offers a portable way to access the underlying
358directory structure and file attributes.")
359 (license (package-license lua-5.1))))
360
361(define-public lua-filesystem
362 (make-lua-filesystem "lua-filesystem" lua))
363
364(define-public lua5.1-filesystem
365 (make-lua-filesystem "lua5.1-filesystem" lua-5.1))
366
367(define-public lua5.2-filesystem
368 (make-lua-filesystem "lua5.2-filesystem" lua-5.2))
369
370(define (make-lua-ossl name lua)
371 (package
372 (name name)
373 (version "20170903")
374 (source (origin
375 (method url-fetch)
376 (uri (string-append "https://25thandclement.com/~william/"
377 "projects/releases/luaossl-" version ".tgz"))
378 (sha256
379 (base32
380 "10392bvd0lzyibipblgiss09zlqh3a5zgqg1b9lgbybpqb9cv2k3"))))
381 (build-system gnu-build-system)
382 (arguments
383 `(#:make-flags
384 (let ((out (assoc-ref %outputs "out"))
385 (lua-api-version ,(version-major+minor (package-version lua))))
386 (list ,(string-append "CC=" (cc-for-target))
387 "CFLAGS='-D HAVE_SYS_SYSCTL_H=0'" ; sys/sysctl.h is deprecated
388 (string-append "prefix=" out)
389 (string-append "LUA_APIS=" lua-api-version)))
390 #:phases
391 (modify-phases %standard-phases
392 (delete 'configure)
393 (delete 'check)
394 (add-after 'install 'check
395 (lambda* (#:key outputs #:allow-other-keys)
396 (let ((out (assoc-ref outputs "out"))
397 (lua-version ,(version-major+minor (package-version lua))))
398 (setenv "LUA_CPATH"
399 (string-append out "/lib/lua/" lua-version "/?.so;;"))
400 (setenv "LUA_PATH"
401 (string-append out "/share/lua/" lua-version "/?.lua;;"))
402 (with-directory-excursion "regress"
403 (for-each (lambda (f)
404 (invoke "lua" f))
405 (find-files "." "^[0-9].*\\.lua$"))))
406 #t)))))
407 (inputs
408 (list lua openssl))
409 (home-page "https://25thandclement.com/~william/projects/luaossl.html")
410 (synopsis "OpenSSL bindings for Lua")
411 (description "The luaossl extension module for Lua provides comprehensive,
412low-level bindings to the OpenSSL library, including support for certificate and
413key management, key generation, signature verification, and deep bindings to the
414distinguished name, alternative name, and X.509v3 extension interfaces. It also
415binds OpenSSL's bignum, message digest, HMAC, cipher, and CSPRNG interfaces.")
416 (license license:expat)))
417
418(define-public lua-ossl
419 (make-lua-ossl "lua-ossl" lua))
420
421(define-public lua5.1-ossl
422 (make-lua-ossl "lua5.1-ossl" lua-5.1))
423
424(define-public lua5.2-ossl
425 (make-lua-ossl "lua5.2-ossl" lua-5.2))
426
427(define (make-lua-sec name lua)
428 (package
429 (name name)
430 (version "0.9")
431 (source (origin
432 (method git-fetch)
433 (uri (git-reference
434 (url "https://github.com/brunoos/luasec")
435 (commit (string-append "v" version))))
436 (file-name (git-file-name name version))
437 (sha256
438 (base32
439 "0ssncgkggyr8i3z6zbvgrgsqj2q8676rnsikhpfwnk9n7sx4gwbl"))))
440 (build-system gnu-build-system)
441 (arguments
442 `(#:make-flags
443 (let ((out (assoc-ref %outputs "out"))
444 (lua-version ,(version-major+minor (package-version lua))))
445 (list "linux"
446 ,(string-append "CC=" (cc-for-target))
447 "LD=gcc"
448 (string-append "LUAPATH=" out "/share/lua/" lua-version)
449 (string-append "LUACPATH=" out "/lib/lua/" lua-version)))
450 #:tests? #f ; no tests included
451 #:phases
452 (modify-phases %standard-phases
453 (delete 'configure))))
454 (inputs
455 (list lua openssl))
456 (propagated-inputs
457 `(("lua-socket"
458 ,(make-lua-socket
459 (format #f "lua~a-socket"
460 (version-major+minor (package-version lua))) lua))))
461 (home-page "https://github.com/brunoos/luasec/wiki")
462 (synopsis "OpenSSL bindings for Lua")
463 (description "LuaSec is a binding for OpenSSL library to provide TLS/SSL
464communication. It takes an already established TCP connection and creates a
465secure session between the peers.")
466 (license license:expat)))
467
468(define-public lua5.1-sec
469 (make-lua-sec "lua5.1-sec" lua-5.1))
470
471(define-public lua5.2-sec
472 (make-lua-sec "lua5.2-sec" lua-5.2))
473
474(define (make-lua-cqueues name lua lua-ossl)
475 (package
476 (name name)
477 (version "20171014")
478 (source (origin
479 (method url-fetch)
480 (uri (string-append "https://25thandclement.com/~william/"
481 "projects/releases/cqueues-" version ".tgz"))
482 (sha256
483 (base32
484 "1dabhpn6r0hlln8vx9hxm34pfcm46qzgpb2apmziwg5z51fi4ksb"))))
485 (build-system gnu-build-system)
486 (arguments
487 `(#:modules ((guix build gnu-build-system)
488 (guix build utils)
489 (ice-9 string-fun))
490 #:make-flags
491 (let ((out (assoc-ref %outputs "out"))
492 (lua-api-version ,(version-major+minor (package-version lua))))
493 (list ,(string-append "CC=" (cc-for-target))
494 (string-append "LUA_APIS=" lua-api-version)))
495 #:phases
496 (modify-phases %standard-phases
497 (delete 'configure)
498 (delete 'check)
499 (replace 'install
500 (lambda* (#:key make-flags outputs #:allow-other-keys)
501 (let ((out (assoc-ref outputs "out")))
502 (apply invoke "make" "install"
503 (append make-flags
504 (list (string-append "DESTDIR=" out)
505 "prefix="))))))
506 (add-after 'install 'check
507 (lambda* (#:key inputs outputs make-flags #:allow-other-keys)
508 (let*
509 ((lua-version ,(version-major+minor (package-version lua)))
510 (env-suffix (if (equal? lua-version "5.1")
511 ""
512 (string-append
513 "_"
514 (string-replace-substring lua-version "." "_"))))
515
516 (lua-ossl (assoc-ref inputs "lua-ossl"))
517 (out (assoc-ref outputs "out"))
518
519 (lua-cpath (lambda (p)
520 (string-append p "/lib/lua/" lua-version "/?.so")))
521 (lua-path (lambda (p)
522 (string-append p "/share/lua/" lua-version "/?.lua"))))
523 ;; The test suite sets Lua-version-specific search-path variables
524 ;; when available so we must do the same, as these take
525 ;; precedence over the generic "LUA_CPATH" and "LUA_PATH"
526 (setenv (string-append "LUA_CPATH" env-suffix)
527 (string-append
528 (string-join (map lua-cpath (list out lua-ossl)) ";")
529 ";;"))
530 (setenv (string-append "LUA_PATH" env-suffix)
531 (string-append
532 (string-join (map lua-path (list out lua-ossl)) ";")
533 ";;"))
534
535 ;; Skip regression tests we expect to fail
536 (with-directory-excursion "regress"
537 (for-each (lambda (f)
538 (rename-file f (string-append f ".skip")))
539 (append
540 ;; Regression tests that require network
541 ;; connectivity
542 '("22-client-dtls.lua"
543 "30-starttls-completion.lua"
544 "62-noname.lua"
545 "153-dns-resolvers.lua")
546
547 ;; Regression tests that require LuaJIT
548 '("44-resolvers-gc.lua"
549 "51-join-defunct-thread.lua")
550
551 ;; Regression tests that require Lua 5.3
552 (if (not (equal? lua-version "5.3"))
553 '("152-thread-integer-passing.lua")
554 '()))))
555
556 (apply invoke "make" "check" make-flags)))))))
557 (native-inputs
558 (list m4))
559 (inputs
560 (list lua openssl))
561 (propagated-inputs
562 (list lua-ossl))
563 (home-page "https://25thandclement.com/~william/projects/cqueues.html")
564 (synopsis "Event loop for Lua using continuation queues")
565 (description "The cqueues extension module for Lua implements an event loop
566that operates through the yielding and resumption of coroutines. It is designed
567to be non-intrusive, composable, and embeddable within existing applications.")
568 (license license:expat)))
569
570(define-public lua-cqueues
571 (make-lua-cqueues "lua-cqueues" lua lua-ossl))
572
573(define-public lua5.1-cqueues
574 (make-lua-cqueues "lua5.1-cqueues" lua-5.1 lua5.1-ossl))
575
576(define-public lua5.2-cqueues
577 (make-lua-cqueues "lua5.2-cqueues" lua-5.2 lua5.2-ossl))
578
579(define-public lua-penlight
580 (package
581 (name "lua-penlight")
582 (version "1.7.0")
583 (source
584 (origin
585 (method git-fetch)
586 (uri (git-reference
587 (url "https://github.com/Tieske/Penlight")
588 (commit version)))
589 (file-name (git-file-name name version))
590 (sha256
591 (base32 "0qc2d1riyr4b5a0gnsmdw2lz5pw65s4ac60hc34w3mmk9l6yg6nl"))))
592 (build-system trivial-build-system)
593 (inputs
594 (list lua))
595 (propagated-inputs
596 (list lua-filesystem))
597 (arguments
598 `(#:modules ((guix build utils))
599 #:builder
600 (begin
601 (use-modules (guix build utils))
602 (let* ((source (assoc-ref %build-inputs "source"))
603 (lua-version ,(version-major+minor (package-version lua)))
604 (destination (string-append (assoc-ref %outputs "out")
605 "/share/lua/" lua-version)))
606 (mkdir-p destination)
607 (with-directory-excursion source
608 (copy-recursively "lua/" destination)))
609 #t)))
610 (home-page "http://tieske.github.io/Penlight/")
611 (synopsis "Collection of general purpose libraries for the Lua language")
612 (description "Penlight is a set of pure Lua libraries focusing on
613input data handling (such as reading configuration files), functional
614programming (such as map, reduce, placeholder expressions,etc), and OS
615path management. Much of the functionality is inspired by the Python
616standard libraries.")
617 (license license:expat)))
618
619(define-public lua-ldoc
620 (package
621 (name "lua-ldoc")
622 (version "1.4.6")
623 (source
624 (origin
625 (method git-fetch)
626 (uri (git-reference
627 (url "https://github.com/stevedonovan/LDoc")
628 (commit version)))
629 (file-name (git-file-name name version))
630 (sha256
631 (base32 "1h0cf7bp4am54r0j8lhjs2l1c7q5vz74ba0jvw9qdbaqimls46g8"))))
632 (build-system gnu-build-system)
633 (inputs
634 (list lua))
635 (propagated-inputs
636 (list lua-penlight))
637 (arguments
638 `(#:tests? #f ;tests must run after installation.
639 #:phases
640 (modify-phases %standard-phases
641 (add-after 'unpack 'fix-installation-directory
642 (lambda* (#:key outputs #:allow-other-keys)
643 (let ((out (assoc-ref outputs "out"))
644 (lua-version ,(version-major+minor (package-version lua))))
645 (substitute* "makefile"
646 (("LUA=.*") "#\n")
647 (("(LUA_PREFIX=).*" _ prefix)
648 (string-append prefix out "\n"))
649 (("(LUA_BINDIR=).*" _ prefix)
650 (string-append prefix out "/bin\n"))
651 (("(LUA_SHAREDIR=).*" _ prefix)
652 (string-append prefix out "/share/lua/" lua-version "\n"))))
653 #t))
654 (delete 'configure)
655 (add-before 'install 'create-bin-directory
656 (lambda* (#:key outputs #:allow-other-keys)
657 (mkdir-p (string-append (assoc-ref outputs "out") "/bin"))
658 #t)))))
659 (home-page "https://stevedonovan.github.io/ldoc/")
660 (synopsis "Lua documentation generator")
661 (description
662 "LDoc is a LuaDoc-compatible documentation generation system for
663Lua source code. It parses the declaration and documentation comments
664in a set of Lua source files and produces a set of XHTML pages
665describing the commented declarations and functions.")
666 (license license:expat)))
667
668(define (make-lua-lgi name lua)
669 (package
670 (name name)
671 (version "0.9.2")
672 (source
673 (origin
674 (method git-fetch)
675 (uri (git-reference
676 (url "https://github.com/pavouk/lgi")
677 (commit version)))
678 (file-name (git-file-name name version))
679 (sha256
680 (base32 "03rbydnj411xpjvwsyvhwy4plm96481d7jax544mvk7apd8sd5jj"))))
681 (build-system gnu-build-system)
682 (arguments
683 `(#:make-flags
684 (list ,(string-append "CC=" (cc-for-target))
685 (string-append "PREFIX=" (assoc-ref %outputs "out")))
686 #:phases
687 (modify-phases %standard-phases
688 (delete 'configure) ; no configure script
689 (add-before 'build 'set-env
690 (lambda* (#:key inputs #:allow-other-keys)
691 ;; We need to load cairo dynamically.
692 (let* ((cairo (string-append (assoc-ref inputs "cairo") "/lib")))
693 (setenv "LD_LIBRARY_PATH" cairo)
694 #t)))
695 (add-before 'build 'set-lua-version
696 (lambda _
697 ;; Lua version and therefore install directories are hardcoded.
698 (substitute* "./lgi/Makefile"
699 (("LUA_VERSION=5.1")
700 (format #f
701 "LUA_VERSION=~a"
702 ,(version-major+minor (package-version lua)))))
703 #t))
704 (add-before 'check 'skip-test-gtk
705 (lambda _
706 ;; FIXME: Skip GTK tests:
707 ;; gtk3 - can't get it to run with the xorg-server config below
708 ;; and some non-gtk tests will also fail
709 ;; gtk2 - lots of functions aren't implemented
710 ;; We choose gtk2 as the lesser evil and simply skip the test.
711 ;; Currently, awesome is the only package that uses lua-lgi but
712 ;; it doesn't need or interact with GTK using lua-lgi.
713 (substitute* "./tests/test.lua"
714 (("'gtk.lua',") "-- 'gtk.lua',"))
715 #t))
716 (add-before 'check 'start-xserver-instance
717 (lambda* (#:key inputs #:allow-other-keys)
718 ;; There must be a running X server during tests.
719 (system (format #f "~a/bin/Xvfb :1 &"
720 (assoc-ref inputs "xorg-server")))
721 (setenv "DISPLAY" ":1")
722 #t)))))
723 (native-inputs
724 (list dbus ;tests use 'dbus-run-session'
725 pkg-config))
726 (inputs
727 `(("cairo" ,cairo)
728 ("glib" ,glib)
729 ("gobject-introspection" ,gobject-introspection)
730 ("gtk" ,gtk+-2)
731 ("libffi" ,libffi)
732 ("lua" ,lua)
733 ("pango" ,pango)
734 ("xorg-server" ,xorg-server)))
735 (home-page "https://github.com/pavouk/lgi/")
736 (synopsis "Lua bridge to GObject based libraries")
737 (description
738 "LGI is gobject-introspection based dynamic Lua binding to GObject based
739libraries. It allows using GObject-based libraries directly from Lua.
740Notable examples are GTK+, GStreamer and Webkit.")
741 (license license:expat)))
742
743(define-public lua-lgi
744 (make-lua-lgi "lua-lgi" lua))
745
746(define-public lua5.1-lgi
747 (make-lua-lgi "lua5.1-lgi" lua-5.1))
748
749(define-public lua5.2-lgi
750 (make-lua-lgi "lua5.2-lgi" lua-5.2))
751
752(define (make-lua-lpeg name lua)
753 (package
754 (name name)
755 (version "1.0.2")
756 (source (origin
757 (method url-fetch)
758 (uri (string-append "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-"
759 version ".tar.gz"))
760 (sha256
761 (base32 "1zjzl7acvcdavmcg5l7wi12jd4rh95q9pl5aiww7hv0v0mv6bmj8"))))
762 (build-system gnu-build-system)
763 (arguments
764 `(#:phases
765 (modify-phases %standard-phases
766 (delete 'configure)
767 ;; `make install` isn't available, so we have to do it manually
768 (replace 'install
769 (lambda* (#:key outputs #:allow-other-keys)
770 (let ((out (assoc-ref outputs "out"))
771 (lua-version ,(version-major+minor (package-version lua))))
772 (install-file "lpeg.so"
773 (string-append out "/lib/lua/" lua-version))
774 (install-file "re.lua"
775 (string-append out "/share/lua/" lua-version))
776 #t))))
777 #:test-target "test"))
778 (inputs (list lua))
779 (synopsis "Pattern-matching library for Lua")
780 (description
781 "LPeg is a pattern-matching library for Lua, based on Parsing Expression
782Grammars (PEGs).")
783 (home-page "https://www.inf.puc-rio.br/~roberto/lpeg")
784 (license license:expat)))
785
786(define-public lua-lpeg
787 (make-lua-lpeg "lua-lpeg" lua))
788
789(define-public lua5.1-lpeg
790 (make-lua-lpeg "lua5.1-lpeg" lua-5.1))
791
792(define-public lua5.2-lpeg
793 (make-lua-lpeg "lua5.2-lpeg" lua-5.2))
794
795(define (make-lua-luv name lua)
796 (package
797 (name name)
798 (version "1.43.0-0")
799 (source (origin
800 ;; The release tarball includes the sources of libuv but does
801 ;; not include the pkg-config files.
802 (method git-fetch)
803 (uri (git-reference
804 (url "https://github.com/luvit/luv")
805 (commit version)))
806 (file-name (git-file-name name version))
807 (sha256
808 (base32
809 "1yzi4bm845vl84wyv2qw4z1n1v285lgwm681swmp84brfy2s7czp"))))
810 (build-system cmake-build-system)
811 (arguments
812 (list #:tests? #f ; there are none
813 #:configure-flags
814 #~'("-DWITH_LUA_ENGINE=Lua"
815 "-DWITH_SHARED_LIBUV=On"
816 "-DBUILD_MODULE=Off"
817 "-DBUILD_SHARED_LIBS=On"
818 "-DLUA_BUILD_TYPE=System")
819 #:phases
820 #~(modify-phases %standard-phases
821 (add-after 'unpack 'copy-lua-compat
822 (lambda* _
823 (copy-recursively #+(this-package-native-input "lua-compat")
824 "lua-compat")
825 (setenv "CPATH"
826 (string-append (getcwd) "/lua-compat/c-api:"
827 (or (getenv "CPATH") "")))
828 #t)))))
829 (inputs
830 (list lua libuv-for-luv))
831 (native-inputs
832 `(("lua-compat"
833 ,(origin
834 (method git-fetch)
835 (uri (git-reference
836 (url "https://github.com/keplerproject/lua-compat-5.3")
837 (commit "v0.10")))
838 (file-name "lua-compat-5.3-checkout")
839 (sha256
840 (base32
841 "1caxn228gx48g6kymp9w7kczgxcg0v0cd5ixsx8viybzkd60dcn4"))))))
842 (home-page "https://github.com/luvit/luv/")
843 (synopsis "Libuv bindings for Lua")
844 (description
845 "This library makes libuv available to Lua scripts.")
846 (license license:asl2.0)))
847
848(define-public lua-luv
849 (make-lua-luv "lua-luv" lua))
850
851(define-public lua5.1-luv
852 (make-lua-luv "lua5.1-luv" lua-5.1))
853
854(define-public lua5.2-luv
855 (make-lua-luv "lua5.2-luv" lua-5.2))
856
857;; Lua 5.3 is not supported.
858(define (make-lua-bitop name lua)
859 (package
860 (name name)
861 (version "1.0.2")
862 (source (origin
863 (method url-fetch)
864 (uri (string-append "http://bitop.luajit.org/download/"
865 "LuaBitOp-" version ".tar.gz"))
866 (sha256
867 (base32
868 "16fffbrgfcw40kskh2bn9q7m3gajffwd2f35rafynlnd7llwj1qj"))))
869 (build-system gnu-build-system)
870 (arguments
871 `(#:test-target "test"
872 #:make-flags
873 (list "INSTALL=install -pD"
874 (string-append "INSTALLPATH=printf "
875 (assoc-ref %outputs "out")
876 "/lib/lua/"
877 ,(version-major+minor (package-version lua))
878 "/bit/bit.so"))
879 #:phases
880 (modify-phases %standard-phases
881 (delete 'configure))))
882 (inputs (list lua))
883 (home-page "https://bitop.luajit.org/index.html")
884 (synopsis "Bitwise operations on numbers for Lua")
885 (description
886 "Lua BitOp is a C extension module for Lua which adds bitwise operations
887on numbers.")
888 (license license:expat)))
889
890(define-public lua5.2-bitop
891 (make-lua-bitop "lua5.2-bitop" lua-5.2))
892
893(define-public lua5.1-bitop
894 (make-lua-bitop "lua5.1-bitop" lua-5.1))
895
896(define-public selene
897 (package
898 (name "selene")
899 (version "2017.08.25")
900 (source (origin
901 (method git-fetch)
902 (uri (git-reference
903 (url "https://github.com/jeremyong/Selene")
904 ;; The release is quite old.
905 (commit "ffe1ade2568d4cff5894552be8f43e63e379a4c9")))
906 (file-name "Selene")
907 (sha256
908 (base32
909 "1axrgv3rxxdsaf807lwvklfzicn6x6gpf35narllrnz9lg6hn508"))))
910 (build-system cmake-build-system)
911 (arguments
912 `(#:configure-flags
913 ;; lua pc file in CMakeLists.txt is lua5.3.pc
914 '("-DLUA_PC_CFG=lua;lua-5.3;lua-5.1")
915 #:test-target "all"
916 #:phases
917 ;; This is a header only library
918 (modify-phases %standard-phases
919 (delete 'build)
920 (replace 'install
921 (lambda* (#:key inputs outputs #:allow-other-keys)
922 (let* ((output (assoc-ref outputs "out"))
923 (source (assoc-ref inputs "source"))
924 (includedir (string-append output "/include")))
925 (copy-recursively
926 (string-append source "/include")
927 includedir))
928 #t))
929 ;; The path of test files are hard coded.
930 (replace 'check
931 (lambda* (#:key inputs outputs #:allow-other-keys)
932 (let* ((output (assoc-ref outputs "out"))
933 (source (assoc-ref inputs "source"))
934 (builddir (getcwd))
935 (testdir (string-append builddir "/test")))
936 (copy-recursively (string-append source "/test") testdir)
937 (invoke "make")
938 (mkdir-p "runner")
939 (copy-file "./test_runner" "./runner/test_runner")
940 (chdir "./runner")
941 (invoke "./test_runner")))))))
942 (native-inputs
943 (list lua pkg-config))
944 (home-page "https://github.com/jeremyong/Selene")
945 (synopsis "Lua C++11 bindings")
946 (description
947 "Selene is a simple C++11 header-only library enabling seamless
948 interoperability between C++ and Lua programming language.")
949 (license license:zlib)))
950
951(define-public lua-resty-core
952 (package
953 (name "lua-resty-core")
954 (version "0.1.18")
955 (source (origin
956 (method git-fetch)
957 (uri (git-reference
958 (url "https://github.com/openresty/lua-resty-core")
959 (commit (string-append "v" version))))
960 (file-name (git-file-name name version))
961 (sha256
962 (base32
963 "1c58hykwpg5zqbyhrcb703pzwbkih409v3bh2gady6z2kj9q32dw"))))
964 (build-system trivial-build-system)
965 (arguments
966 `(#:modules ((guix build utils))
967 #:builder
968 (begin
969 (use-modules (guix build utils))
970 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
971 (package-lua-resty (lambda (input output)
972 (mkdir-p (string-append output "/lib/lua"))
973 (copy-recursively (string-append input "/lib/resty")
974 (string-append output "/lib/lua/resty"))
975 (copy-recursively (string-append input "/lib/ngx")
976 (string-append output "/lib/ngx"))
977 (symlink (string-append output "/lib/lua/resty")
978 (string-append output "/lib/resty")))))
979 (package-lua-resty (assoc-ref %build-inputs "source")
980 (assoc-ref %outputs "out")))
981 #t)))
982 (home-page "https://github.com/openresty/lua-resty-core")
983 (synopsis "Lua API for NGINX")
984 (description "This package provides a FFI-based Lua API for
985@code{ngx_http_lua_module} or @code{ngx_stream_lua_module}.")
986 (license license:bsd-2)))
987
988(define-public lua-resty-lrucache
989 (package
990 (name "lua-resty-lrucache")
991 (version "0.10")
992 (source (origin
993 (method git-fetch)
994 (uri (git-reference
995 (url "https://github.com/openresty/lua-resty-lrucache")
996 (commit (string-append "v" version))))
997 (file-name (git-file-name name version))
998 (sha256
999 (base32
1000 "1bsc54v1rvxmkwg7a2c01p192lvw5g576f589is8fy1m1c6v4ap8"))))
1001 (build-system trivial-build-system)
1002 (arguments
1003 `(#:modules ((guix build utils))
1004 #:builder
1005 (begin
1006 (use-modules (guix build utils))
1007 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1008 (package-lua-resty (lambda (input output)
1009 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1010 (copy-recursively (string-append input "/lib/resty")
1011 (string-append output "/lib/lua/" luajit-major+minor "/resty"))
1012 (symlink (string-append output "/lib/lua/" luajit-major+minor "/resty")
1013 (string-append output "/lib/resty")))))
1014 (package-lua-resty (assoc-ref %build-inputs "source")
1015 (assoc-ref %outputs "out")))
1016 #t)))
1017 (home-page "https://github.com/openresty/lua-resty-lrucache")
1018 (synopsis "Lua LRU cache based on the LuaJIT FFI")
1019 (description
1020 "This package provides Lua LRU cache based on the LuaJIT FFI.")
1021 (license license:bsd-2)))
1022
1023(define-public lua-resty-signal
1024 (package
1025 (name "lua-resty-signal")
1026 (version "0.02")
1027 (source (origin
1028 (method git-fetch)
1029 (uri (git-reference
1030 (url "https://github.com/openresty/lua-resty-signal")
1031 (commit (string-append "v" version))))
1032 (file-name (git-file-name name version))
1033 (sha256
1034 (base32
1035 "13y1pqn45y49mhqwywasfdsid46d0c33yi6mrnracbnmvyxz1cif"))))
1036 (build-system gnu-build-system)
1037 (arguments
1038 `(#:tests? #f ;TODO: Run the test suite.
1039 #:make-flags (list ,(string-append "CC=" (cc-for-target))
1040 (string-append "PREFIX=" %output))
1041 #:phases
1042 (modify-phases %standard-phases
1043 (delete 'configure)
1044 (add-after 'install 'install-lua
1045 (lambda* (#:key inputs outputs #:allow-other-keys)
1046 (use-modules (guix build utils))
1047 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1048 (package-lua-resty (lambda (input output)
1049 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1050 (copy-recursively (string-append input "/lib/resty")
1051 (string-append output "/lib/lua/" luajit-major+minor "/resty"))
1052 (symlink (string-append output "/lib/lua/" luajit-major+minor "/resty")
1053 (string-append output "/lib/resty")))))
1054 (package-lua-resty (assoc-ref inputs "source")
1055 (assoc-ref outputs "out")))
1056 #t)))))
1057 (home-page "https://github.com/openresty/lua-resty-signal")
1058 (synopsis "Lua library for killing or sending signals to Linux processes")
1059 (description "This package provides Lua library for killing or sending
1060signals to Linux processes.")
1061 (license license:bsd-3)))
1062
1063(define-public lua-tablepool
1064 (package
1065 (name "lua-tablepool")
1066 (version "0.01")
1067 (source (origin
1068 (method git-fetch)
1069 (uri (git-reference
1070 (url "https://github.com/openresty/lua-tablepool")
1071 (commit (string-append "v" version))))
1072 (file-name (git-file-name name version))
1073 (sha256
1074 (base32
1075 "03yjj3w6znvj6843prg84m0lkrn49l901f9hj9bgy3cj9s0awl6y"))))
1076 (build-system trivial-build-system)
1077 (arguments
1078 `(#:modules ((guix build utils))
1079 #:builder
1080 (begin
1081 (use-modules (guix build utils))
1082 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1083 (package-lua-resty (lambda (input output)
1084 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1085 (copy-recursively (string-append input "/lib")
1086 (string-append output "/lib")))))
1087 (package-lua-resty (assoc-ref %build-inputs "source")
1088 (assoc-ref %outputs "out")))
1089 #t)))
1090 (home-page "https://github.com/openresty/lua-tablepool")
1091 (synopsis "Lua table recycling pools for LuaJIT")
1092 (description "This package provides Lua table recycling pools for LuaJIT.")
1093 (license license:bsd-2)))
1094
1095(define-public lua-resty-shell
1096 (package
1097 (name "lua-resty-shell")
1098 (version "0.03")
1099 (source (origin
1100 (method git-fetch)
1101 (uri (git-reference
1102 (url "https://github.com/openresty/lua-resty-shell")
1103 (commit (string-append "v" version))))
1104 (file-name (git-file-name name version))
1105 (sha256
1106 (base32
1107 "1s6g04ip4hr97r2pd8ry3alq063604s9a3l0hn9nsidh81ps4dp7"))))
1108 (build-system trivial-build-system)
1109 (arguments
1110 `(#:modules ((guix build utils))
1111 #:builder
1112 (begin
1113 (use-modules (guix build utils))
1114 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1115 (package-lua-resty (lambda (input output)
1116 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1117 (copy-recursively (string-append input "/lib/resty")
1118 (string-append output "/lib/lua/" luajit-major+minor "/resty"))
1119 (symlink (string-append output "/lib/lua/" luajit-major+minor "/resty")
1120 (string-append output "/lib/resty")))))
1121 (package-lua-resty (assoc-ref %build-inputs "source")
1122 (assoc-ref %outputs "out")))
1123 #t)))
1124 (home-page "https://github.com/openresty/lua-resty-shell")
1125 (synopsis "Lua module for nonblocking system shell command executions")
1126 (description "This package provides Lua module for nonblocking system
1127shell command executions.")
1128 (license license:bsd-3)))
1129
1130(define-public emilua
1131 (package
1132 (name "emilua")
1133 (version "0.3.2")
1134 (source (origin
1135 (method git-fetch)
1136 (uri (git-reference
1137 (url "https://gitlab.com/emilua/emilua.git")
1138 (commit (string-append "v" version))
1139 ;; Current version requires Trial.Protocol and the HTTP lib
1140 ;; developed as part of GSoC 2014 for Boost, and these are
1141 ;; dependencies unlikely to be "unbundled" in future releases.
1142 (recursive? #t)))
1143 (file-name (git-file-name name version))
1144 (sha256
1145 (base32
1146 "1999bgrh52124a5g4qizav3x257ff2brjr855srpm1jv1nxzbygv"))))
1147 (build-system meson-build-system)
1148 (arguments
1149 `(;; Tests are disabled for now due to an issue that affecs guix:
1150 ;; <https://gitlab.com/emilua/emilua/-/issues/22>
1151 #:configure-flags
1152 (list "-Denable_http=true"
1153 "-Denable_tests=false"
1154 "-Denable_manpages=false"
1155 "-Dversion_suffix=-guix1")))
1156 (native-inputs
1157 (list luajit-lua52-openresty
1158 pkg-config
1159 re2c
1160 xxd))
1161 (inputs
1162 (list boost
1163 boost-static
1164 fmt-7
1165 ;; LuaJIT has a 2GiB addressing limit[1] that has been fixed on OpenResty
1166 ;; fork. Emilua is severely affected by this limit, so the upstream package
1167 ;; is avoided. Emilua also depends on the -DLUAJIT_ENABLE_LUA52COMPAT
1168 ;; configure flag[2] for some features to work (e.g. __pairs on HTTP
1169 ;; headers).
1170 ;;
1171 ;; [1] <http://hacksoflife.blogspot.com/2012/12/integrating-luajit-with-x-plane-64-bit.html>
1172 ;; [2] <http://luajit.org/extensions.html#lua52>
1173 luajit-lua52-openresty
1174 ncurses
1175 openssl))
1176 (native-search-paths
1177 (list
1178 (search-path-specification
1179 (variable "EMILUA_PATH")
1180 (files
1181 (list (string-append "lib/emilua-" (version-major+minor version)))))))
1182 (home-page "https://gitlab.com/emilua/emilua")
1183 (synopsis "Lua execution engine")
1184 (description
1185 "Emilua is a LuaJIT-based Lua execution engine that supports async IO,
1186fibers and actor-inspired threading. The experimental builtin HTTP module is
1187enabled.")
1188 (license license:boost1.0)))
1189
1190(define-public fennel
1191 (package
1192 (name "fennel")
1193 (version "1.3.1")
1194 (source (origin
1195 (method git-fetch)
1196 (uri (git-reference
1197 (url "https://git.sr.ht/~technomancy/fennel")
1198 (commit version)))
1199 (file-name (git-file-name name version))
1200 (sha256
1201 (base32
1202 "12zm3rd0vvkqazv1cv5bhwk6igsj18im2qakqw7cf4a20rc9wpmx"))))
1203 (build-system gnu-build-system)
1204 (arguments
1205 (list #:make-flags #~(list (string-append "PREFIX="
1206 (assoc-ref %outputs "out")))
1207 #:tests? #t ;even on cross-build
1208 #:test-target "test"
1209 #:phases #~(modify-phases %standard-phases
1210 (delete 'configure)
1211 (add-after 'build 'patch-fennel
1212 (lambda* (#:key inputs #:allow-other-keys)
1213 (substitute* "fennel"
1214 (("/usr/bin/env .*lua")
1215 (search-input-file inputs "/bin/lua")))))
1216 (delete 'check)
1217 (add-after 'install 'check
1218 (assoc-ref %standard-phases
1219 'check)))))
1220 (inputs (list lua))
1221 (home-page "https://fennel-lang.org/")
1222 (synopsis "Lisp that compiles to Lua")
1223 (description
1224 "Fennel is a programming language that brings together the speed,
1225simplicity, and reach of Lua with the flexibility of a Lisp syntax and macro
1226system.")
1227 (license license:expat)))
1228
1229(define-public fnlfmt
1230 (package
1231 (name "fnlfmt")
1232 (version "0.3.0")
1233 (source (origin
1234 (method git-fetch)
1235 (uri (git-reference
1236 (url "https://git.sr.ht/~technomancy/fnlfmt")
1237 (commit version)))
1238 (file-name (git-file-name name version))
1239 (sha256
1240 (base32
1241 "06gzw7f20yw4192kymr4karxw3ia3apjnjqpm6vxph87c67d1fa3"))
1242 (modules '((guix build utils)))
1243 (snippet
1244 #~(begin
1245 ;; Use input fennel instead of bundled fennel.
1246 (delete-file "fennel")
1247 (delete-file "fennel.lua")
1248 (substitute* "Makefile"
1249 (("./fennel") "fennel"))))))
1250 (build-system gnu-build-system)
1251 (arguments
1252 `(#:modules ((guix build gnu-build-system)
1253 (guix build utils)
1254 (ice-9 match))
1255 #:test-target "test"
1256 #:phases
1257 (modify-phases %standard-phases
1258 (delete 'configure)
1259 (add-before 'build 'patch-makefile
1260 (lambda* (#:key native-inputs inputs #:allow-other-keys)
1261 (substitute* "Makefile"
1262 ;; Patch lua shebang that gets inserted to fnlfmt.
1263 (("/usr/bin/env lua")
1264 (search-input-file (or native-inputs inputs) "/bin/lua")))))
1265 (replace 'install
1266 ;; There is no install target; manually install the output file.
1267 (lambda* (#:key outputs #:allow-other-keys)
1268 (let* ((out (assoc-ref outputs "out"))
1269 (bin (string-append out "/bin")))
1270 (for-each (lambda (file)
1271 (install-file file bin))
1272 (find-files "." "fnlfmt")))))
1273 (add-after 'install 'wrap
1274 (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
1275 (let* ((all-inputs (or native-inputs inputs))
1276 (fnlfmt (assoc-ref outputs "out"))
1277 (lua-version ,(version-major+minor (package-version lua)))
1278 (fennel (assoc-ref all-inputs "fennel")))
1279 (wrap-program (string-append fnlfmt "/bin/fnlfmt")
1280 `("LUA_PATH" ";" suffix
1281 (,(format #f "~a/share/lua/~a/?.lua" fennel lua-version))))
1282 #t))))))
1283 (inputs (list bash-minimal))
1284 (native-inputs (list lua fennel))
1285 (home-page "https://git.sr.ht/~technomancy/fnlfmt")
1286 (synopsis "Automatic formatting of Fennel code")
1287 (description
1288 "Fnlfmt is a tool for automatically formatting Fennel code in a consistent
1289way, following established lisp conventions.")
1290 (license license:lgpl3+)))