projects/guix·blob bootstrap-team · refs

1686 lines · 69.9 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;;;
29;;; This file is part of GNU Guix.
30;;;
31;;; GNU Guix is free software; you can redistribute it and/or modify it
32;;; under the terms of the GNU General Public License as published by
33;;; the Free Software Foundation; either version 3 of the License, or (at
34;;; your option) any later version.
35;;;
36;;; GNU Guix is distributed in the hope that it will be useful, but
37;;; WITHOUT ANY WARRANTY; without even the implied warranty of
38;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39;;; GNU General Public License for more details.
40;;;
41;;; You should have received a copy of the GNU General Public License
42;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
43
44(define-module (gnu packages lua)
45 #:use-module ((guix licenses) #:prefix license:)
46 #:use-module (guix packages)
47 #:use-module (guix download)
48 #:use-module (guix git-download)
49 #:use-module (guix gexp)
50 #:use-module (guix utils)
51 #:use-module (guix build-system gnu)
52 #:use-module (guix build-system cmake)
53 #:use-module (guix build-system meson)
54 #:use-module (guix build-system trivial)
55 #:use-module (gnu packages)
56 #:use-module (gnu packages autotools)
57 #:use-module (gnu packages base)
58 #:use-module (gnu packages bash)
59 #:use-module (gnu packages boost)
60 #:use-module (gnu packages curl)
61 #:use-module (gnu packages build-tools)
62 #:use-module (gnu packages check)
63 #:use-module (gnu packages gcc)
64 #:use-module (gnu packages compression)
65 #:use-module (gnu packages gcc)
66 #:use-module (gnu packages glib)
67 #:use-module (gnu packages gperf)
68 #:use-module (gnu packages gnupg)
69 #:use-module (gnu packages gtk)
70 #:use-module (gnu packages libevent)
71 #:use-module (gnu packages libffi)
72 #:use-module (gnu packages linux)
73 #:use-module (gnu packages m4)
74 #:use-module (gnu packages ncurses)
75 #:use-module (gnu packages ninja)
76 #:use-module (gnu packages pkg-config)
77 #:use-module (gnu packages pretty-print)
78 #:use-module (gnu packages rdf)
79 #:use-module (gnu packages re2c)
80 #:use-module (gnu packages readline)
81 #:use-module (gnu packages rsync)
82 #:use-module (gnu packages ssh)
83 #:use-module (gnu packages tls)
84 #:use-module (gnu packages version-control)
85 #:use-module (gnu packages vim)
86 #:use-module (gnu packages wget)
87 #:use-module (gnu packages xml)
88 #:use-module (gnu packages xorg)
89 #:use-module ((srfi srfi-1) #:hide (zip)))
90
91(define-public lua
92 (package
93 (name "lua")
94 (version "5.3.5")
95 (source (origin
96 (method url-fetch)
97 (uri (string-append "https://www.lua.org/ftp/lua-"
98 version ".tar.gz"))
99 (sha256
100 (base32 "1b2qn2rv96nmbm6zab4l877bd4zq7wpwm8drwjiy2ih4jqzysbhc"))
101 (patches (search-patches "lua-pkgconfig.patch"
102 "lua-liblua-so.patch"))))
103 (build-system gnu-build-system)
104 (inputs (list readline))
105 (arguments
106 `(#:modules ((guix build gnu-build-system)
107 (guix build utils)
108 (srfi srfi-1))
109 #:test-target "test"
110 #:make-flags
111 (list "MYCFLAGS=-fPIC -DLUA_DL_DLOPEN"
112 (string-append "CC=" ,(cc-for-target))
113 (string-append "SYSLIBS=-L" (assoc-ref %build-inputs "readline")
114 "/lib")
115 "linux")
116 #:phases
117 (modify-phases %standard-phases
118 (delete 'configure)
119 (replace 'install
120 (lambda* (#:key outputs #:allow-other-keys)
121 (let ((out (assoc-ref outputs "out")))
122 (invoke "make" "install"
123 (string-append "INSTALL_TOP=" out)
124 (string-append "INSTALL_MAN=" out
125 "/share/man/man1"))))))))
126 (home-page "https://www.lua.org/")
127 (synopsis "Embeddable scripting language")
128 (description
129 "Lua is a powerful, fast, lightweight, embeddable scripting language. Lua
130combines simple procedural syntax with powerful data description constructs
131based on associative arrays and extensible semantics. Lua is dynamically typed,
132runs by interpreting bytecode for a register-based virtual machine, and has
133automatic memory management with incremental garbage collection, making it ideal
134for configuration, scripting, and rapid prototyping.")
135 (license license:x11)))
136
137(define-public lua-5.4
138 (package (inherit lua)
139 (version "5.4.8")
140 (arguments
141 (substitute-keyword-arguments (package-arguments lua)
142 ((#:make-flags flags)
143 (append (delete "linux" flags)
144 '("linux-readline")))))
145 (source (origin
146 (method url-fetch)
147 (uri (string-append "https://www.lua.org/ftp/lua-"
148 version ".tar.gz"))
149 (sha256
150 (base32 "1bi90r9nzmqhjwhr8ysffhmhq30wxxcpqwmbxr33wyaf2npds62g"))
151 (patches (search-patches "lua-5.4-pkgconfig.patch"
152 "lua-5.4-liblua-so.patch"))))))
153
154(define-public lua-5.2
155 (package (inherit lua)
156 (version "5.2.4")
157 (source
158 (origin
159 (method url-fetch)
160 (uri (string-append "https://www.lua.org/ftp/lua-"
161 version ".tar.gz"))
162 (sha256
163 (base32 "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr"))
164 (patches (search-patches "lua-pkgconfig.patch"
165 "lua-liblua-so.patch"))))))
166
167(define-public lua-5.1
168 (package (inherit lua)
169 (version "5.1.5")
170 (source (origin
171 (method url-fetch)
172 (uri (string-append "https://www.lua.org/ftp/lua-"
173 version ".tar.gz"))
174 (sha256
175 (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))
176 (patches (search-patches "lua51-liblua-so.patch"
177 "lua-CVE-2014-5461.patch"
178 "lua51-pkgconfig.patch"))))))
179
180(define-public luajit
181 (let ((branch "v2.1")
182 (commit "04dca7911ea255f37be799c18d74c305b921c1a6"))
183 (package
184 (name "luajit")
185 (version (git-version branch "0" commit))
186 (source (origin
187 (method git-fetch)
188 (uri (git-reference
189 (url "https://luajit.org/git/luajit.git")
190 (commit commit)))
191 (file-name (git-file-name name version))
192 (sha256
193 (base32
194 "0srwk9nmiz8a93f70inq2597ff6xy203ckr4c0k7jcksdixymi9v"))))
195 (build-system gnu-build-system)
196 (arguments
197 (list #:tests? #f ; luajit is distributed without tests
198 #:phases
199 #~(modify-phases %standard-phases
200 #$@(if (target-riscv64?)
201 #~((add-after 'unpack 'patch
202 (lambda _
203 (invoke
204 "patch" "--force" "-p1" "-i"
205 #$(local-file
206 (search-patch
207 "luajit-add-riscv64-support.patch"))))))
208 #~())
209 (delete 'configure)) ; no configure script
210 #:make-flags #~(list (string-append "PREFIX="
211 (assoc-ref %outputs "out")))))
212 (home-page "https://www.luajit.org/")
213 (synopsis
214 "Just in time compiler for Lua programming language version 5.1")
215 ;; On powerpc64le-linux, the build fails with an error: "No support for
216 ;; PowerPC 64 bit mode (yet)". See: https://issues.guix.gnu.org/49220
217 (supported-systems (fold delete %supported-systems
218 (list "powerpc64le-linux")))
219 (description
220 "LuaJIT is a Just-In-Time Compiler (JIT) for the Lua
221programming language. Lua is a powerful, dynamic and light-weight programming
222language. It may be embedded or used as a general-purpose, stand-alone
223language.")
224 (license license:x11))))
225
226(define-public luajit-lua52-openresty
227 (package
228 (inherit luajit)
229 (name "luajit-lua52-openresty")
230 (version "2.1-20201229")
231 (source
232 (origin
233 (method git-fetch)
234 (uri (git-reference
235 (url "https://github.com/openresty/luajit2.git")
236 (commit (string-append "v" version))))
237 (file-name (git-file-name name version))
238 (sha256
239 (base32 "07haj27kbpbnkv836c2nd36h2xislrmri52w0zbpxvl68xk6g96p"))))
240 (arguments
241 `(#:tests? #f ;no test
242 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
243 #:phases
244 (modify-phases %standard-phases
245 (delete 'configure) ;no configure script
246 (add-after 'unpack 'enable-lua52-compat
247 (lambda _
248 (substitute* "src/Makefile"
249 (("#(XCFLAGS\\+= -DLUAJIT_ENABLE_LUA52COMPAT)" _ flag) flag))
250 #t)))))
251 (home-page "https://github.com/openresty/luajit2")
252 (synopsis "OpenResty's Branch of LuaJIT 2")
253 (description
254 "This is the official OpenResty branch of LuaJIT. It is not to be
255considered a fork, since changes are regularly synchronized from the upstream
256LuaJIT project. This package also enables the Lua 5.2 compat mode needed by
257some projects.")))
258
259(define (make-lua-expat name lua)
260 (package
261 (name name)
262 (version "1.3.0")
263 (source (origin
264 (method url-fetch)
265 (uri (string-append "https://matthewwild.co.uk/projects/"
266 "luaexpat/luaexpat-" version ".tar.gz"))
267 (sha256
268 (base32
269 "1hvxqngn0wf5642i5p3vcyhg3pmp102k63s9ry4jqyyqc1wkjq6h"))))
270 (build-system gnu-build-system)
271 (arguments
272 `(#:make-flags
273 (let ((out (assoc-ref %outputs "out"))
274 (lua-version ,(version-major+minor (package-version lua))))
275 (list ,(string-append "CC=" (cc-for-target))
276 (string-append "LUA_LDIR=" out "/share/lua/" lua-version)
277 (string-append "LUA_CDIR=" out "/lib/lua/" lua-version)))
278 #:phases
279 (modify-phases %standard-phases
280 (delete 'configure)
281 (replace 'check
282 (lambda _
283 (setenv "LUA_CPATH" "src/?.so;;")
284 (setenv "LUA_PATH" "src/?.lua;;")
285 (invoke "lua" "tests/test.lua")
286 (invoke "lua" "tests/test-lom.lua"))))))
287 (inputs
288 (list lua expat))
289 (home-page "https://matthewwild.co.uk/projects/luaexpat/")
290 (synopsis "SAX XML parser based on the Expat library")
291 (description "LuaExpat is a SAX XML parser based on the Expat library.")
292 (license (package-license lua-5.1))))
293
294(define-public lua5.1-expat
295 (make-lua-expat "lua5.1-expat" lua-5.1))
296
297(define-public lua5.2-expat
298 (make-lua-expat "lua5.2-expat" lua-5.2))
299
300(define (make-lua-socket name lua)
301 (package
302 (name name)
303 (version "3.0-rc1")
304 (source (origin
305 (method git-fetch)
306 (uri (git-reference
307 (url "https://github.com/diegonehab/luasocket")
308 (commit (string-append "v" version))))
309 (file-name (git-file-name name version))
310 (sha256
311 (base32
312 "1chs7z7a3i3lck4x7rz60ziwbf793gw169hpjdfca8y4yf1hzsxk"))))
313 (build-system gnu-build-system)
314 (arguments
315 `(#:make-flags
316 (let ((out (assoc-ref %outputs "out"))
317 (lua-version ,(version-major+minor (package-version lua))))
318 (list (string-append "INSTALL_TOP=" out)
319 (string-append "LUAV?=" lua-version)))
320 #:phases
321 (modify-phases %standard-phases
322 (delete 'configure)
323 (replace 'check
324 (lambda _
325 (setenv "LUA_CPATH" (string-append "src/?.so." ,version ";;"))
326 (setenv "LUA_PATH" "src/?.lua;;")
327 (when (zero? (primitive-fork))
328 (invoke "lua" "test/testsrvr.lua"))
329 (invoke "lua" "test/testclnt.lua"))))))
330 (inputs
331 (list lua))
332 (home-page "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/")
333 (synopsis "Socket library for Lua")
334 (description "LuaSocket is a Lua extension library that is composed by two
335parts: a C core that provides support for the TCP and UDP transport layers,
336and a set of Lua modules that add support for functionality commonly needed by
337applications that deal with the Internet.
338
339Among the supported modules, the most commonly used implement the
340SMTP (sending e-mails), HTTP (WWW access) and FTP (uploading and downloading
341files) client protocols. These provide a very natural and generic interface
342to the functionality defined by each protocol. In addition, you will find
343that the MIME (common encodings), URL (anything you could possible want to do
344with one) and LTN12 (filters, sinks, sources and pumps) modules can be very
345handy.")
346 (license license:expat)))
347
348(define-public lua5.1-socket
349 (make-lua-socket "lua5.1-socket" lua-5.1))
350
351(define-public lua5.2-socket
352 (make-lua-socket "lua5.2-socket" lua-5.2))
353
354(define (make-lua-filesystem name lua)
355 (package
356 (name name)
357 (version "1.7.0.2")
358 (source (origin
359 (method git-fetch)
360 (uri (git-reference
361 (url "https://github.com/keplerproject/luafilesystem")
362 (commit (string-append "v"
363 (string-join
364 (string-split version #\.) "_")))))
365 (file-name (git-file-name name version))
366 (sha256
367 (base32
368 "0zmprgkm9zawdf9wnw0v3w6ibaj442wlc6alp39hmw610fl4vghi"))))
369 (build-system gnu-build-system)
370 (arguments
371 `(#:make-flags
372 (let ((out (assoc-ref %outputs "out"))
373 (lua-version ,(version-major+minor (package-version lua))))
374 (list (string-append "PREFIX=" out)
375 (string-append "LUA_LIBDIR=" out "/lib/lua/" lua-version)))
376 #:test-target "test"
377 #:phases
378 (modify-phases %standard-phases
379 (delete 'configure))))
380 (inputs
381 (list lua))
382 (home-page "https://keplerproject.github.io/luafilesystem/index.html")
383 (synopsis "File system library for Lua")
384 (description "LuaFileSystem is a Lua library developed to complement the
385set of functions related to file systems offered by the standard Lua
386distribution. LuaFileSystem offers a portable way to access the underlying
387directory structure and file attributes.")
388 (license (package-license lua-5.1))))
389
390(define-public lua-filesystem
391 (make-lua-filesystem "lua-filesystem" lua))
392
393(define-public lua5.1-filesystem
394 (make-lua-filesystem "lua5.1-filesystem" lua-5.1))
395
396(define-public lua5.2-filesystem
397 (make-lua-filesystem "lua5.2-filesystem" lua-5.2))
398
399(define-public lua-bee
400 ;; There are no releases; use the commit known to work with the packaged
401 ;; luamake.
402 (let ((commit "fe3feb2b62e8f0179dad5abb438ed4df39f675d4")
403 (revision "0"))
404 (package
405 (name "lua-bee")
406 (version (git-version "0.0.0" revision commit))
407 (source (origin
408 (method git-fetch)
409 (uri (git-reference
410 (url "https://github.com/actboy168/bee.lua/")
411 (commit commit)
412 ;; Requires a few git submodules such as the Lua
413 ;; sources to patch and a few source libraries.
414 (recursive? #t)))
415 (file-name (git-file-name name version))
416 (sha256
417 (base32
418 "1iv4cdkgcs123zw67ngq4jfbp7p7hkmj8zg2lbblipmm0hivhbd2"))))
419 (build-system gnu-build-system)
420 (arguments
421 (list
422 ;; TODO: Re-enable the tests after luamake can use a newer bee commit
423 ;; (see:
424 ;; <https://github.com/actboy168/bee.lua/commit/679c566f0f26bcf0c19e37066e678993122e1f34>).
425 #:tests? #f
426 #:phases
427 #~(modify-phases %standard-phases
428 (delete 'configure)
429 (replace 'build
430 (lambda* (#:key parallel-build? #:allow-other-keys)
431 (invoke "luamake"
432 "-EXE" "lua"
433 "-notest"
434 "-j" (if parallel-build?
435 (number->string (parallel-job-count))
436 "1")
437 "-v")))
438 (replace 'check
439 (lambda* (#:key parallel-tests? tests? #:allow-other-keys)
440 (when tests?
441 (invoke "luamake"
442 "-EXE" "lua"
443 "-j" (if parallel-tests?
444 (number->string (parallel-job-count))
445 "1")
446 "test" "-v"))))
447 (replace 'install
448 (lambda _
449 (install-file "build/bin/lua"
450 (string-append #$output "/bin"))
451 (install-file "build/bin/bee.so"
452 (string-append #$output "/lib/")))))))
453 (native-inputs (list luamake))
454 (home-page "https://github.com/actboy168/bee.lua/")
455 (synopsis "Lua runtime with a few extra features")
456 (description "The Bee Lua runtime implements a few extra features
457such as:
458@itemize
459@item Deterministic tables traversal
460@item Enable @code{lua_assert} in debug mode
461@item Add error hook (for debugger)
462@item Add resume/yield hook (for debugger)
463@item Disable tail calls in debug mode (for debugger)
464@end itemize")
465 (license license:expat))))
466
467(define-public luamake
468 (package
469 (name "luamake")
470 (version "1.7")
471 (source (origin
472 (method git-fetch)
473 (uri (git-reference
474 (url "https://github.com/actboy168/luamake")
475 (commit (string-append "v" version))))
476 (file-name (git-file-name name version))
477 (sha256
478 (base32
479 "075sp8dpcb81kwrpp843f1y00kvaqan09np6spf6b72z5dhf6aiw"))))
480 (build-system gnu-build-system)
481 (arguments
482 (list
483 #:phases
484 #~(modify-phases %standard-phases
485 (add-after 'unpack 'copy-lua-bee-sources
486 (lambda* (#:key native-inputs inputs #:allow-other-keys)
487 (copy-recursively (dirname
488 (search-input-directory
489 (or native-inputs inputs) "bee"))
490 "bee.lua")))
491 (add-after 'unpack 'patch-commands
492 (lambda* (#:key inputs #:allow-other-keys)
493 (substitute* "scripts/action.lua"
494 (("\"ninja\"")
495 (format #f "~s" (search-input-file inputs "bin/ninja"))))))
496 (delete 'configure)
497 (replace 'build
498 (lambda* (#:key parallel-build? #:allow-other-keys)
499 (invoke "compile/build.sh" "-j"
500 (if parallel-build?
501 (number->string (parallel-job-count))
502 "1")
503 "notest" "-v")))
504 (replace 'check
505 (lambda* (#:key parallel-tests? tests? #:allow-other-keys)
506 (when tests?
507 (invoke "compile/build.sh" "-j"
508 (if parallel-tests?
509 (number->string (parallel-job-count))
510 "1")
511 "test" "-v"))))
512 (replace 'install
513 (lambda _
514 (let ((bin (string-append #$output "/bin"))
515 (lib (string-append #$output "/lib/luamake")))
516 (install-file "luamake" lib)
517 (install-file "main.lua" lib)
518 (copy-recursively "scripts"
519 (string-append lib "/scripts"))
520 (copy-recursively "tools"
521 (string-append lib "/tools"))
522 (mkdir bin)
523 (symlink (string-append lib "/luamake")
524 (string-append bin "/luamake"))))))))
525 (native-inputs (list (package-source lua-bee)
526 ninja))
527 (inputs (list ninja))
528 (home-page "https://github.com/actboy168/luamake")
529 (synopsis "Make-inspired configuration and build system")
530 (description "Luamake is a platform independent configuration and
531build system that uses the standard Lua command-line interpreter.")
532 (license license:expat)))
533
534(define-public lua-language-server
535 (package
536 (name "lua-language-server")
537 (version "3.16.4")
538 (source (origin
539 (method git-fetch)
540 (uri (git-reference
541 (url "https://github.com/LuaLS/lua-language-server")
542 (commit version)
543 ;; There are quite a few bundled Lua libraries under the
544 ;; '3rd' and 'meta/3rd' directories; most are currently
545 ;; not packaged in Guix, and they all track exact
546 ;; commits, so it would be annoying to maintain them as
547 ;; separate origins (on top of having to patch the build
548 ;; system to unbundle them).
549 (recursive? #t)))
550 (file-name (git-file-name name version))
551 (sha256
552 (base32
553 "0kbbwz9cjw9b8sii2hki51s968n551r8z46h9gp9bd2m3g3l1l75"))))
554 (build-system gnu-build-system)
555 (arguments
556 (list
557 ;; The test suite currently fails with luamake apparently attempting to
558 ;; find the bee.so shared object (see:
559 ;; <https://github.com/LuaLS/lua-language-server/issues/3325>).
560 #:tests? #f
561 #:phases
562 #~(modify-phases %standard-phases
563 (delete 'configure)
564 (replace 'build
565 (lambda* (#:key parallel-build? #:allow-other-keys)
566 (invoke "luamake"
567 "-notest"
568 "-j" (if parallel-build?
569 (number->string (parallel-job-count))
570 "1")
571 "-v")))
572 (replace 'check
573 (lambda* (#:key parallel-tests? tests? #:allow-other-keys)
574 (when tests?
575 (invoke "luamake"
576 "-j" (if parallel-tests?
577 (number->string (parallel-job-count))
578 "1")
579 "test" "-v"))))
580 (replace 'install
581 ;; This is inspired by the package definition in Slackware.
582 (lambda* (#:key inputs #:allow-other-keys)
583 (let* ((bin (string-append #$output "/bin"))
584 (lib (string-append #$output
585 "/libexec/lua-language-server"))
586 (lib/bin (string-append lib "/bin")))
587 ;; XXX: The binary expects some odd layout to find its resources,
588 ;; hence the bin subdirectory under libexec.
589 (mkdir-p lib)
590 (for-each (lambda (x)
591 (copy-recursively x (string-append lib "/" x)))
592 (list "bin"
593 "debugger.lua"
594 "locale"
595 "main.lua"
596 "meta"
597 "script"))
598 ;; Create a custom wrapper, adjusted to log elsewhere than in
599 ;; its read-only location under the store.
600 (mkdir bin)
601 (call-with-output-file (string-append bin "/lua-language-server")
602 (lambda (p)
603 (format p "#!~a
604exec ~a --logpath=\"/tmp/runtime-$USER/lua-language-server/log\" \
605--metapath=\"/tmp/runtime-$USER/lua-language-server/meta\" \"$@\""
606 (search-input-file inputs "bin/sh")
607 (string-append lib/bin
608 "/lua-language-server"))))
609 (chmod (string-append bin "/lua-language-server") #o755)))))))
610 (native-inputs (list luamake))
611 (inputs (list bash-minimal)) ;for the wrapper
612 (home-page "https://github.com/LuaLS/lua-language-server")
613 (synopsis "Lua language server")
614 (description "The Lua language server provides various language
615 features for Lua to make development easier and faster, including:
616@itemize
617@item Support for all recent versions of Lua, including LuaJIT
618@item Jump to definition
619@item Dynamic type checking
620@item Find references
621@item Diagnostics/Warnings
622@item Syntax checking
623@item Element renaming
624@item Hover to view details on variables, functions, and more
625@item Auto-completion
626@item Support for libraries
627@item Code formatting
628@item Spell checking
629@item Custom plugins
630@item Documentation generation
631@end itemize")
632 (license license:expat)))
633
634(define (make-lua-ossl name lua)
635 (package
636 (name name)
637 (version "20220711")
638 (source (origin
639 (method git-fetch)
640 (uri (git-reference
641 (url "https://github.com/wahern/luaossl")
642 (commit (string-append "rel-" version))))
643 (file-name (git-file-name name version))
644 (sha256
645 (base32
646 "1a9pgmc6fbhgh1m9ksz9fq057yzz46npqgakcsy9vngg47xacfdb"))))
647 (build-system gnu-build-system)
648 (arguments
649 (list
650 #:make-flags
651 #~(let ((lua-api-version #$(version-major+minor (package-version lua))))
652 (list (string-append "CC=" #$(cc-for-target))
653 "CFLAGS='-D HAVE_SYS_SYSCTL_H=0'" ; sys/sysctl.h is deprecated
654 (string-append "prefix=" #$output)
655 (string-append "LUA_APIS=" lua-api-version)))
656 #:phases
657 #~(modify-phases %standard-phases
658 (delete 'configure)
659 (delete 'check)
660 (add-after 'install 'check
661 (lambda _
662 (let ((lua-version #$(version-major+minor (package-version lua))))
663 (setenv "LUA_CPATH"
664 (string-append #$output "/lib/lua/" lua-version "/?.so;;"))
665 (setenv "LUA_PATH"
666 (string-append #$output "/share/lua/" lua-version "/?.lua;;"))
667 (with-directory-excursion "regress"
668 (for-each (lambda (f)
669 (unless (member f (list
670 ;; This test is for luajit only
671 "./104-interposition-discarded.lua"
672 ;; needs cqueues, which needs ossl
673 "./148-custom-extensions.lua"))
674 (invoke "lua" f)))
675 (find-files "." "^[0-9].*\\.lua$")))))))))
676 (inputs
677 (list lua openssl))
678 (home-page "https://25thandclement.com/~william/projects/luaossl.html")
679 (synopsis "OpenSSL bindings for Lua")
680 (description "The luaossl extension module for Lua provides comprehensive,
681low-level bindings to the OpenSSL library, including support for certificate
682and key management, key generation, signature verification, and deep bindings
683to the distinguished name, alternative name, and X.509v3 extension interfaces.
684It also binds OpenSSL's bignum, message digest, HMAC, cipher, and CSPRNG
685interfaces.")
686 (license license:expat)))
687
688(define-public lua-ossl
689 (make-lua-ossl "lua-ossl" lua))
690
691(define-public lua5.1-ossl
692 (make-lua-ossl "lua5.1-ossl" lua-5.1))
693
694(define-public lua5.2-ossl
695 (make-lua-ossl "lua5.2-ossl" lua-5.2))
696
697(define (make-lua-sec name lua)
698 (package
699 (name name)
700 (version "0.9")
701 (source (origin
702 (method git-fetch)
703 (uri (git-reference
704 (url "https://github.com/brunoos/luasec")
705 (commit (string-append "v" version))))
706 (file-name (git-file-name name version))
707 (sha256
708 (base32
709 "0ssncgkggyr8i3z6zbvgrgsqj2q8676rnsikhpfwnk9n7sx4gwbl"))))
710 (build-system gnu-build-system)
711 (arguments
712 `(#:make-flags
713 (let ((out (assoc-ref %outputs "out"))
714 (lua-version ,(version-major+minor (package-version lua))))
715 (list "linux"
716 ,(string-append "CC=" (cc-for-target))
717 "LD=gcc"
718 (string-append "LUAPATH=" out "/share/lua/" lua-version)
719 (string-append "LUACPATH=" out "/lib/lua/" lua-version)))
720 #:tests? #f ; no tests included
721 #:phases
722 (modify-phases %standard-phases
723 (delete 'configure))))
724 (inputs
725 (list lua openssl))
726 (propagated-inputs
727 `(("lua-socket"
728 ,(make-lua-socket
729 (format #f "lua~a-socket"
730 (version-major+minor (package-version lua))) lua))))
731 (home-page "https://github.com/brunoos/luasec/wiki")
732 (synopsis "OpenSSL bindings for Lua")
733 (description "LuaSec is a binding for OpenSSL library to provide TLS/SSL
734communication. It takes an already established TCP connection and creates a
735secure session between the peers.")
736 (license license:expat)))
737
738(define-public lua5.1-sec
739 (make-lua-sec "lua5.1-sec" lua-5.1))
740
741(define-public lua5.2-sec
742 (make-lua-sec "lua5.2-sec" lua-5.2))
743
744(define (make-lua-cqueues name lua lua-ossl)
745 (package
746 (name name)
747 (version "20200726")
748 (source (origin
749 (method git-fetch)
750 (uri (git-reference
751 (url "https://github.com/wahern/cqueues")
752 (commit (string-append "rel-" version))))
753 (file-name (git-file-name name version))
754 (sha256
755 (base32
756 "17gwqndlga6gnishgs6wk8cvgwzanddr42yikkg2xd4nanhcg8z9"))))
757 (build-system gnu-build-system)
758 (arguments
759 (list
760 #:modules '((guix build gnu-build-system)
761 (guix build utils)
762 (ice-9 string-fun))
763 #:make-flags
764 #~(let ((lua-api-version #$(version-major+minor (package-version lua))))
765 (list (string-append "CC=" #$(cc-for-target))
766 (string-append "LUA_APIS=" lua-api-version)))
767 #:phases
768 #~(modify-phases %standard-phases
769 (delete 'configure)
770 (delete 'check)
771 (replace 'install
772 (lambda* (#:key make-flags #:allow-other-keys)
773 (apply invoke "make" "install"
774 (append make-flags
775 (list (string-append "DESTDIR=" #$output)
776 "prefix=")))))
777 (add-after 'install 'check
778 (lambda* (#:key make-flags #:allow-other-keys)
779 (let*
780 ((lua-version #$(version-major+minor (package-version lua)))
781 (env-suffix (if (equal? lua-version "5.1")
782 ""
783 (string-append
784 "_"
785 (string-replace-substring lua-version "." "_"))))
786
787 (lua-cpath (lambda (p)
788 (string-append p "/lib/lua/" lua-version "/?.so")))
789 (lua-path (lambda (p)
790 (string-append p "/share/lua/" lua-version "/?.lua"))))
791 ;; The test suite sets Lua-version-specific search-path variables
792 ;; when available so we must do the same, as these take
793 ;; precedence over the generic "LUA_CPATH" and "LUA_PATH"
794 (setenv (string-append "LUA_CPATH" env-suffix)
795 (string-append
796 (string-join (map lua-cpath (list #$output #$lua-ossl)) ";")
797 ";;"))
798 (setenv (string-append "LUA_PATH" env-suffix)
799 (string-append
800 (string-join (map lua-path (list #$output #$lua-ossl)) ";")
801 ";;"))
802
803 ;; Skip regression tests we expect to fail
804 (with-directory-excursion "regress"
805 (for-each (lambda (f)
806 (rename-file f (string-append f ".skip")))
807 (append
808 ;; Regression tests that require network
809 ;; connectivity
810 '("22-client-dtls.lua"
811 "30-starttls-completion.lua"
812 "62-noname.lua"
813 "153-dns-resolvers.lua")
814
815 ;; Regression tests that require LuaJIT
816 '("44-resolvers-gc.lua"
817 "51-join-defunct-thread.lua"
818 ;; These both need the ffi module.
819 "73-starttls-buffering.lua"
820 "87-alpn-disappears.lua")
821
822 ;; Regression tests that require Lua 5.3
823 (if (not (equal? lua-version "5.3"))
824 '("152-thread-integer-passing.lua")
825 '()))))
826
827 (apply invoke "make" "check" make-flags)))))))
828 (native-inputs
829 (list m4))
830 (inputs
831 (list lua openssl))
832 (propagated-inputs
833 (list lua-ossl))
834 (home-page "https://25thandclement.com/~william/projects/cqueues.html")
835 (synopsis "Event loop for Lua using continuation queues")
836 (description "The cqueues extension module for Lua implements an event loop
837that operates through the yielding and resumption of coroutines. It is designed
838to be non-intrusive, composable, and embeddable within existing applications.")
839 (license license:expat)))
840
841(define-public lua-cqueues
842 (make-lua-cqueues "lua-cqueues" lua lua-ossl))
843
844(define-public lua5.1-cqueues
845 (make-lua-cqueues "lua5.1-cqueues" lua-5.1 lua5.1-ossl))
846
847(define-public lua5.2-cqueues
848 (make-lua-cqueues "lua5.2-cqueues" lua-5.2 lua5.2-ossl))
849
850(define-public lua-penlight
851 (package
852 (name "lua-penlight")
853 (version "1.7.0")
854 (source
855 (origin
856 (method git-fetch)
857 (uri (git-reference
858 (url "https://github.com/Tieske/Penlight")
859 (commit version)))
860 (file-name (git-file-name name version))
861 (sha256
862 (base32 "0qc2d1riyr4b5a0gnsmdw2lz5pw65s4ac60hc34w3mmk9l6yg6nl"))))
863 (build-system trivial-build-system)
864 (inputs
865 (list lua))
866 (propagated-inputs
867 (list lua-filesystem))
868 (arguments
869 `(#:modules ((guix build utils))
870 #:builder
871 (begin
872 (use-modules (guix build utils))
873 (let* ((source (assoc-ref %build-inputs "source"))
874 (lua-version ,(version-major+minor (package-version lua)))
875 (destination (string-append (assoc-ref %outputs "out")
876 "/share/lua/" lua-version)))
877 (mkdir-p destination)
878 (with-directory-excursion source
879 (copy-recursively "lua/" destination)))
880 #t)))
881 (home-page "http://tieske.github.io/Penlight/")
882 (synopsis "Collection of general purpose libraries for the Lua language")
883 (description "Penlight is a set of pure Lua libraries focusing on
884input data handling (such as reading configuration files), functional
885programming (such as map, reduce, placeholder expressions,etc), and OS
886path management. Much of the functionality is inspired by the Python
887standard libraries.")
888 (license license:expat)))
889
890(define-public lua-ldoc
891 (package
892 (name "lua-ldoc")
893 (version "1.4.6")
894 (source
895 (origin
896 (method git-fetch)
897 (uri (git-reference
898 (url "https://github.com/stevedonovan/LDoc")
899 (commit version)))
900 (file-name (git-file-name name version))
901 (sha256
902 (base32 "1h0cf7bp4am54r0j8lhjs2l1c7q5vz74ba0jvw9qdbaqimls46g8"))))
903 (build-system gnu-build-system)
904 (inputs
905 (list lua))
906 (propagated-inputs
907 (list lua-penlight))
908 (arguments
909 `(#:tests? #f ;tests must run after installation.
910 #:phases
911 (modify-phases %standard-phases
912 (add-after 'unpack 'fix-installation-directory
913 (lambda* (#:key outputs #:allow-other-keys)
914 (let ((out (assoc-ref outputs "out"))
915 (lua-version ,(version-major+minor (package-version lua))))
916 (substitute* "makefile"
917 (("LUA=.*") "#\n")
918 (("(LUA_PREFIX=).*" _ prefix)
919 (string-append prefix out "\n"))
920 (("(LUA_BINDIR=).*" _ prefix)
921 (string-append prefix out "/bin\n"))
922 (("(LUA_SHAREDIR=).*" _ prefix)
923 (string-append prefix out "/share/lua/" lua-version "\n"))))
924 #t))
925 (delete 'configure)
926 (add-before 'install 'create-bin-directory
927 (lambda* (#:key outputs #:allow-other-keys)
928 (mkdir-p (string-append (assoc-ref outputs "out") "/bin"))
929 #t)))))
930 (home-page "https://stevedonovan.github.io/ldoc/")
931 (synopsis "Lua documentation generator")
932 (description
933 "LDoc is a LuaDoc-compatible documentation generation system for
934Lua source code. It parses the declaration and documentation comments
935in a set of Lua source files and produces a set of XHTML pages
936describing the commented declarations and functions.")
937 (license license:expat)))
938
939(define (make-lua-lgi name lua)
940 (package
941 (name name)
942 (version "0.9.2")
943 (source
944 (origin
945 (method git-fetch)
946 (uri (git-reference
947 (url "https://github.com/pavouk/lgi")
948 (commit version)))
949 (file-name (git-file-name name version))
950 (sha256
951 (base32 "03rbydnj411xpjvwsyvhwy4plm96481d7jax544mvk7apd8sd5jj"))))
952 (build-system gnu-build-system)
953 (arguments
954 `(#:make-flags
955 (list ,(string-append "CC=" (cc-for-target))
956 (string-append "PREFIX=" (assoc-ref %outputs "out")))
957 #:phases
958 (modify-phases %standard-phases
959 (delete 'configure) ; no configure script
960 (add-before 'build 'set-env
961 (lambda* (#:key inputs #:allow-other-keys)
962 ;; We need to load cairo dynamically.
963 (let* ((cairo (string-append (assoc-ref inputs "cairo") "/lib")))
964 (setenv "LD_LIBRARY_PATH" cairo)
965 #t)))
966 (add-before 'build 'set-lua-version
967 (lambda _
968 ;; Lua version and therefore install directories are hardcoded.
969 (substitute* "./lgi/Makefile"
970 (("LUA_VERSION=5.1")
971 (format #f
972 "LUA_VERSION=~a"
973 ,(version-major+minor (package-version lua)))))
974 #t))
975 (add-before 'check 'skip-test-gtk
976 (lambda _
977 ;; FIXME: Skip GTK tests:
978 ;; gtk3 - can't get it to run with the xorg-server config below
979 ;; and some non-gtk tests will also fail
980 ;; gtk2 - lots of functions aren't implemented
981 ;; We choose gtk2 as the lesser evil and simply skip the test.
982 ;; Currently, awesome is the only package that uses lua-lgi but
983 ;; it doesn't need or interact with GTK using lua-lgi.
984 (substitute* "./tests/test.lua"
985 (("'gtk.lua',") "-- 'gtk.lua',"))
986 #t))
987 (add-before 'check 'start-xserver-instance
988 (lambda* (#:key inputs #:allow-other-keys)
989 ;; There must be a running X server during tests.
990 (system (format #f "~a/bin/Xvfb :1 &"
991 (assoc-ref inputs "xorg-server")))
992 (setenv "DISPLAY" ":1")
993 #t)))))
994 (native-inputs
995 (list dbus ;tests use 'dbus-run-session'
996 pkg-config))
997 (inputs
998 `(("cairo" ,cairo)
999 ("glib" ,glib)
1000 ("gobject-introspection" ,gobject-introspection)
1001 ("gtk" ,gtk+-2)
1002 ("libffi" ,libffi)
1003 ("lua" ,lua)
1004 ("pango" ,pango)
1005 ("xorg-server" ,xorg-server)))
1006 (home-page "https://github.com/pavouk/lgi/")
1007 (synopsis "Lua bridge to GObject based libraries")
1008 (description
1009 "LGI is gobject-introspection based dynamic Lua binding to GObject based
1010libraries. It allows using GObject-based libraries directly from Lua.
1011Notable examples are GTK+, GStreamer and Webkit.")
1012 (license license:expat)))
1013
1014(define-public lua-lgi
1015 (make-lua-lgi "lua-lgi" lua))
1016
1017(define-public lua5.1-lgi
1018 (make-lua-lgi "lua5.1-lgi" lua-5.1))
1019
1020(define-public lua5.2-lgi
1021 (make-lua-lgi "lua5.2-lgi" lua-5.2))
1022
1023(define (make-lua-lpeg name lua)
1024 (package
1025 (name name)
1026 (version "1.0.2")
1027 (source (origin
1028 (method url-fetch)
1029 (uri (string-append "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-"
1030 version ".tar.gz"))
1031 (sha256
1032 (base32 "1zjzl7acvcdavmcg5l7wi12jd4rh95q9pl5aiww7hv0v0mv6bmj8"))))
1033 (build-system gnu-build-system)
1034 (arguments
1035 `(#:phases
1036 (modify-phases %standard-phases
1037 (delete 'configure)
1038 ;; `make install` isn't available, so we have to do it manually
1039 (replace 'install
1040 (lambda* (#:key outputs #:allow-other-keys)
1041 (let ((out (assoc-ref outputs "out"))
1042 (lua-version ,(version-major+minor (package-version lua))))
1043 (install-file "lpeg.so"
1044 (string-append out "/lib/lua/" lua-version))
1045 (install-file "re.lua"
1046 (string-append out "/share/lua/" lua-version))
1047 #t))))
1048 #:test-target "test"))
1049 (inputs (list lua))
1050 (synopsis "Pattern-matching library for Lua")
1051 (description
1052 "LPeg is a pattern-matching library for Lua, based on Parsing Expression
1053Grammars (PEGs).")
1054 (home-page "https://www.inf.puc-rio.br/~roberto/lpeg")
1055 (license license:expat)))
1056
1057(define-public lua-lpeg
1058 (make-lua-lpeg "lua-lpeg" lua))
1059
1060(define-public lua5.1-lpeg
1061 (make-lua-lpeg "lua5.1-lpeg" lua-5.1))
1062
1063(define-public lua5.2-lpeg
1064 (make-lua-lpeg "lua5.2-lpeg" lua-5.2))
1065
1066(define (make-lua-luv name lua)
1067 (package
1068 (name name)
1069 (version "1.43.0-0")
1070 (source (origin
1071 ;; The release tarball includes the sources of libuv but does
1072 ;; not include the pkg-config files.
1073 (method git-fetch)
1074 (uri (git-reference
1075 (url "https://github.com/luvit/luv")
1076 (commit version)))
1077 (file-name (git-file-name name version))
1078 (sha256
1079 (base32
1080 "1yzi4bm845vl84wyv2qw4z1n1v285lgwm681swmp84brfy2s7czp"))))
1081 (build-system cmake-build-system)
1082 (arguments
1083 (list #:tests? #f ; there are none
1084 #:configure-flags
1085 #~'("-DWITH_LUA_ENGINE=Lua"
1086 "-DWITH_SHARED_LIBUV=On"
1087 "-DBUILD_MODULE=Off"
1088 "-DBUILD_SHARED_LIBS=On"
1089 "-DLUA_BUILD_TYPE=System")
1090 #:phases
1091 #~(modify-phases %standard-phases
1092 (add-after 'unpack 'copy-lua-compat
1093 (lambda* _
1094 (copy-recursively #+(this-package-native-input "lua-compat")
1095 "lua-compat")
1096 (setenv "CPATH"
1097 (string-append (getcwd) "/lua-compat/c-api:"
1098 (or (getenv "CPATH") "")))
1099 #t)))))
1100 (inputs
1101 (list lua libuv-for-luv))
1102 (native-inputs
1103 `(("lua-compat"
1104 ,(origin
1105 (method git-fetch)
1106 (uri (git-reference
1107 (url "https://github.com/keplerproject/lua-compat-5.3")
1108 (commit "v0.10")))
1109 (file-name "lua-compat-5.3-checkout")
1110 (sha256
1111 (base32
1112 "1caxn228gx48g6kymp9w7kczgxcg0v0cd5ixsx8viybzkd60dcn4"))))))
1113 (home-page "https://github.com/luvit/luv/")
1114 (synopsis "Libuv bindings for Lua")
1115 (description
1116 "This library makes libuv available to Lua scripts.")
1117 (license license:asl2.0)))
1118
1119(define-public lua-luv
1120 (make-lua-luv "lua-luv" lua))
1121
1122(define-public lua5.1-luv
1123 (make-lua-luv "lua5.1-luv" lua-5.1))
1124
1125(define-public lua5.2-luv
1126 (make-lua-luv "lua5.2-luv" lua-5.2))
1127
1128;; Lua 5.3 is not supported.
1129(define (make-lua-bitop name lua)
1130 (package
1131 (name name)
1132 (version "1.0.2")
1133 (source (origin
1134 (method url-fetch)
1135 (uri (string-append "http://bitop.luajit.org/download/"
1136 "LuaBitOp-" version ".tar.gz"))
1137 (sha256
1138 (base32
1139 "16fffbrgfcw40kskh2bn9q7m3gajffwd2f35rafynlnd7llwj1qj"))))
1140 (build-system gnu-build-system)
1141 (arguments
1142 `(#:test-target "test"
1143 #:make-flags
1144 (list "INSTALL=install -pD"
1145 (string-append "INSTALLPATH=printf "
1146 (assoc-ref %outputs "out")
1147 "/lib/lua/"
1148 ,(version-major+minor (package-version lua))
1149 "/bit/bit.so"))
1150 #:phases
1151 (modify-phases %standard-phases
1152 (delete 'configure))))
1153 (inputs (list lua))
1154 (home-page "https://bitop.luajit.org/index.html")
1155 (synopsis "Bitwise operations on numbers for Lua")
1156 (description
1157 "Lua BitOp is a C extension module for Lua which adds bitwise operations
1158on numbers.")
1159 (license license:expat)))
1160
1161(define-public lua5.2-bitop
1162 (make-lua-bitop "lua5.2-bitop" lua-5.2))
1163
1164(define-public lua5.1-bitop
1165 (make-lua-bitop "lua5.1-bitop" lua-5.1))
1166
1167(define-public lutok
1168 (package
1169 (name "lutok")
1170 (version "0.6.2")
1171 (source (origin
1172 (method git-fetch)
1173 (uri (git-reference
1174 (url "https://github.com/freebsd/lutok")
1175 (commit (string-append name "-" version))))
1176 (file-name (git-file-name name version))
1177 (sha256
1178 (base32
1179 "1hk8shp1vkxa09qxaafcfrgc9098cr75n5zc192bv8yjyvz0hvc3"))))
1180 (build-system gnu-build-system)
1181 ;; Disable the test suite to avoid a circular dependency on kyua.
1182 (arguments (list #:tests? #f))
1183 (native-inputs (list autoconf automake libtool pkg-config))
1184 (inputs (list atf))
1185 (propagated-inputs (list lua-5.4)) ;included in c_gate.hpp
1186 (home-page "https://github.com/freebsd/lutok")
1187 (synopsis "Lightweight C++ API for Lua")
1188 (description "Lutok is a lightweight C++ API library for Lua.
1189
1190Lutok provides thin C++ wrappers around the Lua C API to ease the interaction
1191between C++ and Lua. These wrappers make intensive use of @acronym{RAII,
1192Resource Acquisition is Initialization} to prevent resource leakage, expose
1193C++-friendly data types, report errors by means of exceptions and ensure that
1194the Lua stack is always left untouched in the face of errors. The library
1195also provides a small subset of miscellaneous utility functions built on top
1196of the wrappers.
1197
1198Lutok focuses on providing a clean and safe C++ interface; the drawback is
1199that it is not suitable for performance-critical environments. In order to
1200implement error-safe C++ wrappers on top of a Lua C binary library, Lutok adds
1201several layers or abstraction and error checking that go against the original
1202spirit of the Lua C API and thus degrade performance.")
1203 (license license:bsd-3)))
1204
1205(define-public selene
1206 (package
1207 (name "selene")
1208 (version "2017.08.25")
1209 (source (origin
1210 (method git-fetch)
1211 (uri (git-reference
1212 (url "https://github.com/jeremyong/Selene")
1213 ;; The release is quite old.
1214 (commit "ffe1ade2568d4cff5894552be8f43e63e379a4c9")))
1215 (file-name "Selene")
1216 (sha256
1217 (base32
1218 "1axrgv3rxxdsaf807lwvklfzicn6x6gpf35narllrnz9lg6hn508"))))
1219 (build-system cmake-build-system)
1220 (arguments
1221 `(#:configure-flags
1222 ;; lua pc file in CMakeLists.txt is lua5.3.pc
1223 '("-DLUA_PC_CFG=lua;lua-5.3;lua-5.1")
1224 #:phases
1225 ;; This is a header only library
1226 (modify-phases %standard-phases
1227 (delete 'build)
1228 (replace 'install
1229 (lambda* (#:key inputs outputs #:allow-other-keys)
1230 (let* ((output (assoc-ref outputs "out"))
1231 (source (assoc-ref inputs "source"))
1232 (includedir (string-append output "/include")))
1233 (copy-recursively
1234 (string-append source "/include")
1235 includedir))
1236 #t))
1237 ;; The path of test files are hard coded.
1238 (replace 'check
1239 (lambda* (#:key inputs outputs #:allow-other-keys)
1240 (let* ((output (assoc-ref outputs "out"))
1241 (source (assoc-ref inputs "source"))
1242 (builddir (getcwd))
1243 (testdir (string-append builddir "/test")))
1244 (copy-recursively (string-append source "/test") testdir)
1245 (invoke "make")
1246 (mkdir-p "runner")
1247 (copy-file "./test_runner" "./runner/test_runner")
1248 (chdir "./runner")
1249 (invoke "./test_runner")))))))
1250 (native-inputs
1251 (list lua pkg-config))
1252 (home-page "https://github.com/jeremyong/Selene")
1253 (synopsis "Lua C++11 bindings")
1254 (description
1255 "Selene is a simple C++11 header-only library enabling seamless
1256 interoperability between C++ and Lua programming language.")
1257 (license license:zlib)))
1258
1259(define-public lua-resty-core
1260 (package
1261 (name "lua-resty-core")
1262 (version "0.1.18")
1263 (source (origin
1264 (method git-fetch)
1265 (uri (git-reference
1266 (url "https://github.com/openresty/lua-resty-core")
1267 (commit (string-append "v" version))))
1268 (file-name (git-file-name name version))
1269 (sha256
1270 (base32
1271 "1c58hykwpg5zqbyhrcb703pzwbkih409v3bh2gady6z2kj9q32dw"))))
1272 (build-system trivial-build-system)
1273 (arguments
1274 `(#:modules ((guix build utils))
1275 #:builder
1276 (begin
1277 (use-modules (guix build utils))
1278 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1279 (package-lua-resty (lambda (input output)
1280 (mkdir-p (string-append output "/lib/lua"))
1281 (copy-recursively (string-append input "/lib/resty")
1282 (string-append output "/lib/lua/resty"))
1283 (copy-recursively (string-append input "/lib/ngx")
1284 (string-append output "/lib/ngx"))
1285 (symlink (string-append output "/lib/lua/resty")
1286 (string-append output "/lib/resty")))))
1287 (package-lua-resty (assoc-ref %build-inputs "source")
1288 (assoc-ref %outputs "out")))
1289 #t)))
1290 (home-page "https://github.com/openresty/lua-resty-core")
1291 (synopsis "Lua API for NGINX")
1292 (description "This package provides a FFI-based Lua API for
1293@code{ngx_http_lua_module} or @code{ngx_stream_lua_module}.")
1294 (license license:bsd-2)))
1295
1296(define-public lua-resty-lrucache
1297 (package
1298 (name "lua-resty-lrucache")
1299 (version "0.10")
1300 (source (origin
1301 (method git-fetch)
1302 (uri (git-reference
1303 (url "https://github.com/openresty/lua-resty-lrucache")
1304 (commit (string-append "v" version))))
1305 (file-name (git-file-name name version))
1306 (sha256
1307 (base32
1308 "1bsc54v1rvxmkwg7a2c01p192lvw5g576f589is8fy1m1c6v4ap8"))))
1309 (build-system trivial-build-system)
1310 (arguments
1311 `(#:modules ((guix build utils))
1312 #:builder
1313 (begin
1314 (use-modules (guix build utils))
1315 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1316 (package-lua-resty (lambda (input output)
1317 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1318 (copy-recursively (string-append input "/lib/resty")
1319 (string-append output "/lib/lua/" luajit-major+minor "/resty"))
1320 (symlink (string-append output "/lib/lua/" luajit-major+minor "/resty")
1321 (string-append output "/lib/resty")))))
1322 (package-lua-resty (assoc-ref %build-inputs "source")
1323 (assoc-ref %outputs "out")))
1324 #t)))
1325 (home-page "https://github.com/openresty/lua-resty-lrucache")
1326 (synopsis "Lua LRU cache based on the LuaJIT FFI")
1327 (description
1328 "This package provides Lua LRU cache based on the LuaJIT FFI.")
1329 (license license:bsd-2)))
1330
1331(define-public lua-resty-signal
1332 (package
1333 (name "lua-resty-signal")
1334 (version "0.02")
1335 (source (origin
1336 (method git-fetch)
1337 (uri (git-reference
1338 (url "https://github.com/openresty/lua-resty-signal")
1339 (commit (string-append "v" version))))
1340 (file-name (git-file-name name version))
1341 (sha256
1342 (base32
1343 "13y1pqn45y49mhqwywasfdsid46d0c33yi6mrnracbnmvyxz1cif"))))
1344 (build-system gnu-build-system)
1345 (arguments
1346 `(#:tests? #f ;TODO: Run the test suite.
1347 #:make-flags (list ,(string-append "CC=" (cc-for-target))
1348 (string-append "PREFIX=" %output))
1349 #:phases
1350 (modify-phases %standard-phases
1351 (delete 'configure)
1352 (add-after 'install 'install-lua
1353 (lambda* (#:key inputs outputs #:allow-other-keys)
1354 (use-modules (guix build utils))
1355 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1356 (package-lua-resty (lambda (input output)
1357 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1358 (copy-recursively (string-append input "/lib/resty")
1359 (string-append output "/lib/lua/" luajit-major+minor "/resty"))
1360 (symlink (string-append output "/lib/lua/" luajit-major+minor "/resty")
1361 (string-append output "/lib/resty")))))
1362 (package-lua-resty (assoc-ref inputs "source")
1363 (assoc-ref outputs "out")))
1364 #t)))))
1365 (home-page "https://github.com/openresty/lua-resty-signal")
1366 (synopsis "Lua library for killing or sending signals to Linux processes")
1367 (description "This package provides Lua library for killing or sending
1368signals to Linux processes.")
1369 (license license:bsd-3)))
1370
1371(define-public lua-tablepool
1372 (package
1373 (name "lua-tablepool")
1374 (version "0.01")
1375 (source (origin
1376 (method git-fetch)
1377 (uri (git-reference
1378 (url "https://github.com/openresty/lua-tablepool")
1379 (commit (string-append "v" version))))
1380 (file-name (git-file-name name version))
1381 (sha256
1382 (base32
1383 "03yjj3w6znvj6843prg84m0lkrn49l901f9hj9bgy3cj9s0awl6y"))))
1384 (build-system trivial-build-system)
1385 (arguments
1386 `(#:modules ((guix build utils))
1387 #:builder
1388 (begin
1389 (use-modules (guix build utils))
1390 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1391 (package-lua-resty (lambda (input output)
1392 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1393 (copy-recursively (string-append input "/lib")
1394 (string-append output "/lib")))))
1395 (package-lua-resty (assoc-ref %build-inputs "source")
1396 (assoc-ref %outputs "out")))
1397 #t)))
1398 (home-page "https://github.com/openresty/lua-tablepool")
1399 (synopsis "Lua table recycling pools for LuaJIT")
1400 (description "This package provides Lua table recycling pools for LuaJIT.")
1401 (license license:bsd-2)))
1402
1403(define-public lua-resty-shell
1404 (package
1405 (name "lua-resty-shell")
1406 (version "0.03")
1407 (source (origin
1408 (method git-fetch)
1409 (uri (git-reference
1410 (url "https://github.com/openresty/lua-resty-shell")
1411 (commit (string-append "v" version))))
1412 (file-name (git-file-name name version))
1413 (sha256
1414 (base32
1415 "1s6g04ip4hr97r2pd8ry3alq063604s9a3l0hn9nsidh81ps4dp7"))))
1416 (build-system trivial-build-system)
1417 (arguments
1418 `(#:modules ((guix build utils))
1419 #:builder
1420 (begin
1421 (use-modules (guix build utils))
1422 (let* ((luajit-major+minor ,(version-major+minor (package-version lua)))
1423 (package-lua-resty (lambda (input output)
1424 (mkdir-p (string-append output "/lib/lua/" luajit-major+minor))
1425 (copy-recursively (string-append input "/lib/resty")
1426 (string-append output "/lib/lua/" luajit-major+minor "/resty"))
1427 (symlink (string-append output "/lib/lua/" luajit-major+minor "/resty")
1428 (string-append output "/lib/resty")))))
1429 (package-lua-resty (assoc-ref %build-inputs "source")
1430 (assoc-ref %outputs "out")))
1431 #t)))
1432 (home-page "https://github.com/openresty/lua-resty-shell")
1433 (synopsis "Lua module for nonblocking system shell command executions")
1434 (description "This package provides Lua module for nonblocking system
1435shell command executions.")
1436 (license license:bsd-3)))
1437
1438(define-public (make-luarocks name lua)
1439 (package
1440 (name name)
1441 (version "3.9.2")
1442 (home-page "https://luarocks.org/")
1443 (source (origin
1444 (method url-fetch)
1445 (uri (string-append "https://luarocks.org/releases/luarocks-"
1446 version ".tar.gz"))
1447 (sha256
1448 (base32
1449 "1nsfp7cwqcxa8vmkcqkgi5wc0iax0j3gbdfd183kw81cq3nf99mw"))))
1450 (build-system gnu-build-system)
1451 (arguments
1452 `(#:tests? #f ;upstream has no tests
1453 #:phases
1454 (modify-phases %standard-phases
1455 (add-before 'build 'patch-bin-sh
1456 (lambda* (#:key inputs #:allow-other-keys)
1457 (substitute* '("GNUmakefile" "src/luarocks/fs/unix.lua"
1458 "src/luarocks/core/sysdetect.lua")
1459 (("/bin/sh")
1460 (search-input-file inputs "/bin/sh")))))
1461 (replace 'configure
1462 (lambda* (#:key outputs #:allow-other-keys)
1463 (let ((out (assoc-ref outputs "out")))
1464 (invoke "./configure"
1465 (string-append "--prefix=" out)))))
1466 (add-after 'install 'patch-unzip
1467 (lambda* (#:key inputs outputs #:allow-other-keys)
1468 (substitute*
1469 (string-append
1470 (assoc-ref outputs "out") "/etc/luarocks/config-"
1471 ,(substring (package-version lua) 0 3) ".lua") ;e.g. "5.2"
1472 (("variables = \\{")
1473 (string-append
1474 "variables = {\n"
1475 " AR = \"" (search-input-file inputs "/bin/ar") "\";\n"
1476 " BUNZIP2 = \"" (search-input-file inputs "/bin/bunzip2") "\";\n"
1477 " CC = \"" (search-input-file inputs "/bin/gcc") "\";\n"
1478 " CHMOD = \"" (search-input-file inputs "/bin/chmod") "\";\n"
1479 " CP = \"" (search-input-file inputs "/bin/cp") "\";\n"
1480 " CURL = \"" (search-input-file inputs "/bin/curl") "\";\n"
1481 " FIND = \"" (search-input-file inputs "/bin/find") "\";\n"
1482 " GIT = \"" (search-input-file inputs "/bin/git") "\";\n"
1483 " GPG = \"" (search-input-file inputs "/bin/gpg") "\";\n"
1484 " GUNZIP = \"" (search-input-file inputs "/bin/gunzip") "\";\n"
1485 " HG = \"" (search-input-file inputs "/bin/hg") "\";\n"
1486 " LD = \"" (search-input-file inputs "/bin/ld") "\";\n"
1487 " LS = \"" (search-input-file inputs "/bin/ls") "\";\n"
1488 " MAKE = \"" (search-input-file inputs "/bin/make") "\";\n"
1489 " MD5SUM = \"" (search-input-file inputs "/bin/md5sum") "\";\n"
1490 " MKDIR = \"" (search-input-file inputs "/bin/mkdir") "\";\n"
1491 " MKTEMP = \"" (search-input-file inputs "/bin/mktemp") "\";\n"
1492 " OPENSSL = \"" (search-input-file inputs "/bin/openssl") "\";\n"
1493 " PWD = \"" (search-input-file inputs "/bin/pwd") "\";\n"
1494 " RANLIB = \"" (search-input-file inputs "/bin/ranlib") "\";\n"
1495 " RM = \"" (search-input-file inputs "/bin/rm") "\";\n"
1496 " RMDIR = \"" (search-input-file inputs "/bin/rmdir") "\";\n"
1497 " RSYNC = \"" (search-input-file inputs "/bin/rsync") "\";\n"
1498 " SCP = \"" (search-input-file inputs "/bin/scp") "\";\n"
1499 " TAR = \"" (search-input-file inputs "/bin/tar") "\";\n"
1500 " TEST = \"" (search-input-file inputs "/bin/test") "\";\n"
1501 " TOUCH = \"" (search-input-file inputs "/bin/touch") "\";\n"
1502 " UNZIP = \"" (search-input-file inputs "/bin/unzip") " -n\";\n"
1503 " WGET = \"" (search-input-file inputs "/bin/wget") "\";\n"
1504 " ZIP = \"" (search-input-file inputs "/bin/zip") "\";"))))))))
1505 (inputs (list lua
1506 bash-minimal
1507 ;; Executables required by luarocks.
1508 binutils
1509 bzip2
1510 coreutils
1511 curl
1512 findutils
1513 gcc
1514 git
1515 gnupg
1516 gzip
1517 gnu-make
1518 mercurial
1519 openssh
1520 openssl
1521 rsync
1522 tar
1523 unzip
1524 wget
1525 zip))
1526 (native-inputs (list unzip))
1527 (synopsis "Package manager for Lua modules")
1528 (description
1529 "LuaRocks is the package manager for the Lua programming
1530language.
1531
1532It allows you to install Lua modules as self-contained packages called
1533@url{https://luarocks.org/en/Types_of_rocks, @emph{rocks}}, which also contain
1534version @url{https://luarocks.org/en/Dependencies, dependency} information.
1535This information can be used both during installation, so that when one rock
1536is requested all rocks it depends on are installed as well, and also
1537optionally at run time, so that when a module is required, the correct version
1538is loaded. LuaRocks supports both local and
1539@url{http://luarocks.org/en/Rocks_repositories, remote} repositories, and
1540multiple local rocks trees.")
1541 (license license:expat)))
1542
1543(define-public lua5.2-luarocks
1544 (make-luarocks "lua5.2-luarocks" lua-5.2))
1545
1546(define-public luarocks
1547 (make-luarocks "luarocks" lua))
1548
1549(define-public fennel
1550 (package
1551 (name "fennel")
1552 (version "1.6.0")
1553 (source (origin
1554 (method git-fetch)
1555 (uri (git-reference
1556 (url "https://git.sr.ht/~technomancy/fennel")
1557 (commit version)))
1558 (file-name (git-file-name name version))
1559 (sha256
1560 (base32
1561 "09gky2w8z83qqv0n9vx8jqsfldni14kjr6l7y5k44lq5i30i0fsv"))))
1562 (build-system gnu-build-system)
1563 (arguments
1564 (list #:make-flags #~(list (string-append "PREFIX="
1565 (assoc-ref %outputs "out")))
1566 #:test-target "test"
1567 #:phases #~(modify-phases %standard-phases
1568 (delete 'configure)
1569 (add-after 'build 'patch-fennel
1570 (lambda* (#:key inputs #:allow-other-keys)
1571 ;; Remove IRC CI build status reporting
1572 (delete-file "test/irc.lua")
1573 (substitute* "test/init.lua"
1574 ((",\\{hooks=\\{exit=dofile\\(\"test/irc.lua\"\\)\\}\\}")
1575 ""))
1576 (substitute* "fennel"
1577 (("/usr/bin/env .*lua")
1578 (search-input-file inputs "/bin/lua")))))
1579 (delete 'check)
1580 (add-after 'install 'check
1581 (assoc-ref %standard-phases
1582 'check)))))
1583 (inputs (list lua))
1584 (home-page "https://fennel-lang.org/")
1585 (synopsis "Lisp that compiles to Lua")
1586 (description
1587 "Fennel is a programming language that brings together the speed,
1588simplicity, and reach of Lua with the flexibility of a Lisp syntax and macro
1589system.")
1590 (license license:expat)))
1591
1592(define-public antifennel
1593 (package
1594 (version "0.2.0")
1595 (name "antifennel")
1596 (source
1597 (origin
1598 (method git-fetch)
1599 (uri (git-reference
1600 (url "https://git.sr.ht/~technomancy/antifennel")
1601 (commit version)))
1602 (sha256
1603 (base32 "1hd9h17q31b3gg88c657zq4han4air2ag55rrakbmcpy6n8acsqc"))
1604 (file-name (git-file-name name version))))
1605 (build-system gnu-build-system)
1606 (inputs (list luajit))
1607 (arguments
1608 (list
1609 #:phases #~(modify-phases %standard-phases
1610 (delete 'configure)
1611 ;; Tests pass after the fix introduced by the commit
1612 ;; ecd2169fcad1fa6616fdf6e6a8569f5b866601e5
1613 (delete 'check)
1614 (replace 'install
1615 (lambda _
1616 (install-file "antifennel"
1617 (string-append #$output "/bin")))))))
1618 (home-page "https://git.sr.ht/~technomancy/antifennel")
1619 (synopsis "Turn Lua code into Fennel code")
1620 (description
1621 "This package provides a way to turn Lua code into Fennel code.
1622This compiler does the opposite of what the Fennel compiler does.")
1623 (license license:expat)))
1624
1625(define-public fnlfmt
1626 (package
1627 (name "fnlfmt")
1628 (version "0.3.0")
1629 (source (origin
1630 (method git-fetch)
1631 (uri (git-reference
1632 (url "https://git.sr.ht/~technomancy/fnlfmt")
1633 (commit version)))
1634 (file-name (git-file-name name version))
1635 (sha256
1636 (base32
1637 "06gzw7f20yw4192kymr4karxw3ia3apjnjqpm6vxph87c67d1fa3"))
1638 (modules '((guix build utils)))
1639 (snippet
1640 #~(begin
1641 ;; Use input fennel instead of bundled fennel.
1642 (delete-file "fennel")
1643 (delete-file "fennel.lua")
1644 (substitute* "Makefile"
1645 (("./fennel") "fennel"))))))
1646 (build-system gnu-build-system)
1647 (arguments
1648 `(#:modules ((guix build gnu-build-system)
1649 (guix build utils)
1650 (ice-9 match))
1651 #:test-target "test"
1652 #:phases
1653 (modify-phases %standard-phases
1654 (delete 'configure)
1655 (add-before 'build 'patch-makefile
1656 (lambda* (#:key native-inputs inputs #:allow-other-keys)
1657 (substitute* "Makefile"
1658 ;; Patch lua shebang that gets inserted to fnlfmt.
1659 (("/usr/bin/env lua")
1660 (search-input-file (or native-inputs inputs) "/bin/lua")))))
1661 (replace 'install
1662 ;; There is no install target; manually install the output file.
1663 (lambda* (#:key outputs #:allow-other-keys)
1664 (let* ((out (assoc-ref outputs "out"))
1665 (bin (string-append out "/bin")))
1666 (for-each (lambda (file)
1667 (install-file file bin))
1668 (find-files "." "fnlfmt")))))
1669 (add-after 'install 'wrap
1670 (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
1671 (let* ((all-inputs (or native-inputs inputs))
1672 (fnlfmt (assoc-ref outputs "out"))
1673 (lua-version ,(version-major+minor (package-version lua)))
1674 (fennel (assoc-ref all-inputs "fennel")))
1675 (wrap-program (string-append fnlfmt "/bin/fnlfmt")
1676 `("LUA_PATH" ";" suffix
1677 (,(format #f "~a/share/lua/~a/?.lua" fennel lua-version))))
1678 #t))))))
1679 (inputs (list bash-minimal))
1680 (native-inputs (list lua fennel))
1681 (home-page "https://git.sr.ht/~technomancy/fnlfmt")
1682 (synopsis "Automatic formatting of Fennel code")
1683 (description
1684 "Fnlfmt is a tool for automatically formatting Fennel code in a consistent
1685way, following established lisp conventions.")
1686 (license license:lgpl3+)))