projects/guix·blob version-1.4.0 · refs

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