1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 Federico Beffa <beffa@fbengineering.ch>
3 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2017, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2019 Brett Gilio <brettg@gnu.org>
6 ;;; Copyright © 2020 Brendan Tildesley <mail@brendan.scot>
7 ;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
9 ;;; This file is part of GNU Guix.
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24 (define-module (gnu packages chez)
25 #:use-module (gnu packages)
26 #:use-module ((guix licenses)
27 #:select (gpl2+ gpl3+ lgpl2.0+ lgpl2.1+ asl2.0 bsd-3 expat
29 #:use-module (guix packages)
30 #:use-module (guix download)
31 #:use-module (guix git-download)
32 #:use-module (guix utils)
33 #:use-module (guix gexp)
34 #:use-module (guix build-system gnu)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages ncurses)
37 #:use-module (gnu packages ghostscript)
38 #:use-module (gnu packages linux)
39 #:use-module (gnu packages netpbm)
40 #:use-module (gnu packages tex)
41 #:use-module (gnu packages compression)
42 #:use-module (gnu packages image)
43 #:use-module (gnu packages xorg)
44 #:use-module (ice-9 match)
45 #:use-module (srfi srfi-1))
48 (let ((version "1.9.2"))
52 (url "https://github.com/nanopass/nanopass-framework-scheme")
53 (commit (string-append "v" version))))
54 (sha256 (base32 "16vjsik9rrzbabbhbxbaha51ppi3f9n8rk59pc6zdyffs0vziy4i"))
55 (file-name (git-file-name "nanopass" version)))))
58 ;; This commit includes a fix, which we would otherwise want to use as
59 ;; patch. Let's revert to tagged releases as soon as one becomes available.
60 (let* ((commit "54051494434a197772bf6ca5b4e6cf6be55f39a5")
62 (version (git-version version "1" commit)))
66 (url "https://github.com/dybvig/stex")
68 (sha256 (base32 "01jnvw8qw33gnpzwrakwhsr05h6b609lm180jnspcrb7lds2p23d"))
69 (file-name (git-file-name "stex" version)))))
71 (define-public chez-scheme
79 (url "https://github.com/cisco/ChezScheme")
80 (commit (string-append "v" version))))
82 (base32 "0prgn2z9l888j93ydxaf04ph424g0fi3a8w7f8m0b2r7fr1v7388"))
83 (file-name (git-file-name name version))
86 ;; backported from upstream: remove on next release
87 "chez-scheme-build-util-paths-backport.patch"))
89 ;; remove bundled libraries
90 (with-imported-modules '((guix build utils))
92 (use-modules (guix build utils))
93 (for-each (lambda (dir)
94 (when (directory-exists? dir)
95 (delete-file-recursively dir)))
100 (build-system gnu-build-system)
102 `(("libuuid" ,util-linux "lib")
104 ("zlib:static" ,zlib "static")
106 ("lz4:static" ,lz4 "static")
109 ;; for X11 clipboard support in expeditor:
110 ;; https://github.com/cisco/ChezScheme/issues/9#issuecomment-222057232
113 `(("nanopass" ,nanopass) ; source only
116 ("xorg-rgb" ,xorg-rgb)
117 ("texlive" ,(texlive-union (list texlive-latex-oberdiek
118 texlive-generic-epsf)))
119 ("ghostscript" ,ghostscript)
122 (list (search-path-specification
123 (variable "CHEZSCHEMELIBDIRS")
124 (files (list (string-append "lib/csv" version "-site"))))))
125 (outputs '("out" "doc"))
128 ((guix build gnu-build-system)
134 '("--threads") ;; TODO when we fix armhf, it doesn't support --threads
136 (modify-phases %standard-phases
137 ;; put these where configure expects them to be
138 (add-after 'unpack 'unpack-nanopass+stex
139 (lambda* (#:key native-inputs inputs #:allow-other-keys)
140 (for-each (lambda (dep)
142 (assoc-ref (or native-inputs inputs) dep))
143 (copy-recursively src dep
145 '("nanopass" "stex"))
147 ;; NOTE: the custom Chez 'configure' script doesn't allow
148 ;; unrecognized flags, such as those automatically added
149 ;; by `gnu-build-system`.
151 (lambda* (#:key inputs outputs
152 (configure-flags '())
154 (let* ((zlib-static (assoc-ref inputs "zlib:static"))
155 (lz4-static (assoc-ref inputs "lz4:static"))
156 (out (assoc-ref outputs "out"))
157 ;; add flags which are always required:
159 (string-append "--installprefix=" out)
160 (string-append "ZLIB=" zlib-static "/lib/libz.a")
161 (string-append "LZ4=" lz4-static "/lib/liblz4.a")
162 ;; Guix will do compress man pages,
163 ;; and letting Chez try causes an error
166 (format #t "configure flags: ~s~%" flags)
167 ;; Some makefiles (for tests) don't seem to propagate CC
168 ;; properly, so we take it out of their hands:
169 (setenv "CC" ,(cc-for-target))
174 ;; The binary file name is called "scheme" as is the one from MIT/GNU
175 ;; Scheme. We add a symlink to use in case both are installed.
176 (add-after 'install 'install-symlink
177 (lambda* (#:key outputs #:allow-other-keys)
178 (let* ((out (assoc-ref outputs "out"))
179 (bin (string-append out "/bin"))
180 (lib (string-append out "/lib"))
181 (name "chez-scheme"))
182 (symlink (string-append bin "/scheme")
183 (string-append bin "/" name))
185 (symlink file (string-append (dirname file)
187 (find-files lib "scheme.boot"))
189 ;; Building explicitly lets us avoid using substitute*
190 ;; to re-write makefiles.
191 (add-after 'install-symlink 'prepare-stex
192 (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
194 (strip-store-file-name
195 (assoc-ref (or native-inputs inputs) "stex")))
196 ;; Eventually we want to install stex as a real
197 ;; package so it's reusable. For now:
199 (doc-dir (string-append stex-output
202 (with-directory-excursion "stex"
205 (string-append "LIB="
209 (string-append "Scheme="
210 (assoc-ref outputs "out")
212 (for-each (lambda (pth)
213 (install-file pth doc-dir))
214 '("ReadMe" ; includes the license
219 ;; Building the documentation requires stex and a running scheme.
220 ;; FIXME: this is probably wrong for cross-compilation
221 (add-after 'prepare-stex 'install-doc
222 (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
223 (let* ((chez+version (strip-store-file-name
224 (assoc-ref outputs "out")))
226 (strip-store-file-name
227 (assoc-ref (or native-inputs inputs) "stex")))
228 (scheme (string-append (assoc-ref outputs "out")
230 ;; see note on stex-output in phase build-stex, above:
231 (stexlib (string-append "/tmp"
234 (doc-dir (string-append (assoc-ref outputs "doc")
237 (define* (stex-make #:optional (suffix ""))
240 (string-append "Scheme=" scheme)
241 (string-append "STEXLIB=" stexlib)
242 (string-append "installdir=" doc-dir suffix)))
243 (with-directory-excursion "csug"
245 (with-directory-excursion "release_notes"
246 (stex-make "/release_notes"))
247 (with-directory-excursion doc-dir
248 (symlink "release_notes/release_notes.pdf"
250 (symlink "csug/csug9_5.pdf"
253 ;; Chez Scheme does not have a MIPS backend.
254 ;; FIXME: Debian backports patches to get armhf working.
255 ;; We should too. It is the Chez machine type arm32le
256 ;; (no threaded version upstream yet, though there is in
257 ;; Racket's fork), more specifically (per the release notes) ARMv6.
258 (supported-systems (fold delete %supported-systems
259 '("mips64el-linux" "armhf-linux")))
260 (home-page "https://cisco.github.io/ChezScheme/")
261 (synopsis "R6RS Scheme compiler and run-time")
263 "Chez Scheme is a compiler and run-time system for the language of the
264 Revised^6 Report on Scheme (R6RS), with numerous extensions. The compiler
265 generates native code for each target processor, with support for x86, x86_64,
266 and 32-bit PowerPC architectures.")
269 (define-public chez-srfi
277 (url "https://github.com/fedeinthemix/chez-srfi")
278 (commit (string-append "v" version))))
280 (base32 "1vgn984mj2q4w6r2q66h7qklp2hrh85wwh4k9yisga5fi0ps7myf"))
281 (file-name (git-file-name name version))))
282 (build-system gnu-build-system)
284 `(("chez-scheme" ,chez-scheme)))
286 `(#:make-flags (let ((out (assoc-ref %outputs "out")))
287 (list (string-append "PREFIX=" out)
288 "CHEZ=chez-scheme --libdirs ./"
289 (string-append "chezversion=" ,(package-version chez-scheme))))
291 #:phases (modify-phases %standard-phases
292 (delete 'configure))))
293 (home-page "https://github.com/fedeinthemix/chez-srfi")
294 (synopsis "SRFI libraries for Chez Scheme")
296 "This package provides a collection of SRFI libraries for Chez Scheme.")
299 (define-public chez-web
300 (let ((commit "5fd177fe53f31f466bf88720d03c95a3711a8bea")
304 ;; Release 2.0 is different and doesn't work.
305 (version (git-version "2.0" revision commit))
310 (url "https://github.com/arcfide/ChezWEB")
312 (file-name (git-file-name name version))
314 (base32 "1dq25qygyncbfq4kwwqqgyyakfqjwhp5q23vrf3bff1p66nyfl3b"))))
315 (build-system gnu-build-system)
317 `(("chez-scheme" ,chez-scheme)
318 ("ghostscript" ,ghostscript)
319 ("texlive" ,(texlive-union (list texlive-latex-oberdiek
322 texlive-fonts-charter
323 texlive-generic-pdftex
326 texlive-tex-plain)))))
328 `(#:make-flags (list (string-append "PREFIX=" %output)
329 (string-append "DOCDIR=" %output "/share/doc/"
331 (string-append "LIBDIR=" %output "/lib/chezweb")
332 (string-append "TEXDIR=" %output "/share/texmf-local"))
333 #:tests? #f ; no tests
335 (modify-phases %standard-phases
336 (add-before 'build 'set-HOME
338 ;; FIXME: texlive-union does not find the built
339 ;; metafonts, so it tries to generate them in HOME.
340 (setenv "HOME" "/tmp")
342 ;; This package has a custom "bootstrap" script that
343 ;; is meant to be run from the Makefile.
347 (copy-file "config.mk.template" "config.mk")
348 (substitute* "tangleit"
349 (("\\./cheztangle\\.ss" all)
350 (string-append "chez-scheme --program " all)))
351 (substitute* "weaveit"
352 (("mpost chezweb\\.mp")
353 "mpost --tex=tex chezweb.mp")
354 (("\\./chezweave" all)
355 (string-append "chez-scheme --program " all)))
356 (substitute* "installit"
357 (("-g \\$GROUP -o \\$OWNER") ""))
359 (home-page "https://github.com/arcfide/ChezWEB")
360 (synopsis "Hygienic Literate Programming for Chez Scheme")
361 (description "ChezWEB is a system for doing Knuthian style WEB
362 programming in Scheme.")
365 (define-public chez-sockets
366 (let ((commit "bce96881c06bd69a6757a6bff139744153924140")
369 (name "chez-sockets")
370 (version (git-version "0.0.0" revision commit))
375 (url "https://github.com/arcfide/chez-sockets")
377 (file-name (git-file-name name version))
379 (base32 "1n5fbwwz51fdzvjackgmnsgh363g9inyxv7kmzi0469cwavwcx5m"))))
380 (build-system gnu-build-system)
382 `(("chez-scheme" ,chez-scheme)
383 ("chez-web" ,chez-web)
384 ("texlive" ,(texlive-union (list texlive-generic-pdftex)))))
386 `(#:tests? #f ; no tests
388 (modify-phases %standard-phases
390 (lambda* (#:key outputs inputs #:allow-other-keys)
391 (let* ((out (assoc-ref outputs "out"))
392 (chez-web (assoc-ref inputs "chez-web"))
393 (chez (assoc-ref inputs "chez-scheme"))
394 (chez-h (dirname (car (find-files chez "scheme\\.h")))))
395 (substitute* "Makefile"
396 (("(SCHEMEH=).*$" all var)
397 (string-append var chez-h)))
399 (add-before 'build 'tangle
400 (lambda* (#:key inputs #:allow-other-keys)
404 (assoc-ref inputs "chez-web") "/share/texmf-local/tex/generic:"
406 ;; just using "make" tries to build the .c files before
408 (and (invoke "make" "sockets")
411 (lambda* (#:key outputs inputs #:allow-other-keys)
412 (let* ((out (assoc-ref outputs "out"))
413 (chez-site (string-append out "/lib/csv"
414 ,(package-version chez-scheme)
416 ;; make sure Chez Scheme can find the shared libraries.
417 (substitute* "sockets.ss"
418 (("(load-shared-object) \"(socket-ffi-values\\.[sd][oy].*)\""
420 (string-append cmd " \"" chez-site "/" so "\""))
421 (("sockets-stub\\.[sd][oy].*" all)
422 (string-append chez-site "/" all)))
423 ;; to compile chez-sockets, the .so files must be
424 ;; installed (because of the absolute path we
426 (for-each (lambda (f d) (install-file f d))
427 '("socket-ffi-values.so" "sockets-stub.so")
428 (list chez-site chez-site))
429 (zero? (system "echo '(compile-file \"sockets.sls\")' | scheme -q")))))
431 (lambda* (#:key outputs inputs #:allow-other-keys)
432 (let* ((out (assoc-ref outputs "out"))
433 (lib (string-append out "/lib/chez-sockets"))
434 (doc (string-append out "/share/doc/" ,name "-" ,version))
435 (chez-site (string-append out "/lib/csv"
436 ,(package-version chez-scheme)
438 (for-each (lambda (f d) (install-file f d))
439 '("sockets.pdf" "sockets.so")
440 (list doc chez-site))
442 (home-page "https://github.com/arcfide/chez-sockets")
443 (synopsis "Extensible sockets library for Chez Scheme")
444 (description "Chez-sockets is an extensible sockets library for
448 ;; Help function for Chez Scheme to add the current path to
449 ;; CHEZSCHEMELIBDIRS.
450 (define chez-configure
452 (let ((chez-env (getenv "CHEZSCHEMELIBDIRS")))
453 (setenv "CHEZSCHEMELIBDIRS"
455 (string-append ".:" chez-env)
459 ;; Help function to define make flags for some Chez Scheme custom make
461 (define (chez-make-flags name version)
462 `(let ((out (assoc-ref %outputs "out")))
464 ;; Set 'chezversion' so that libraries are installed in
465 ;; 'lib/csvX.Y.Z-site' like Chez's 'native-search-paths' expects.
466 (string-append "chezversion=" ,(package-version chez-scheme))
467 (string-append "PREFIX=" out)
468 (string-append "DOCDIR=" out "/share/doc/"
469 ,name "-" ,version))))
471 (define-public chez-matchable
473 (name "chez-matchable")
475 (home-page "https://github.com/fedeinthemix/chez-matchable")
481 (commit (string-append "v" version))))
483 (base32 "02qn7x348p23z1x5lwhkyj7i8z6mgwpzpnwr8dyina0yzsdkr71s"))
484 (file-name (git-file-name name version))))
485 (build-system gnu-build-system)
487 `(("chez-srfi" ,chez-srfi))) ; for tests
489 `(("chez-scheme" ,chez-scheme)))
491 `(#:make-flags ,(chez-make-flags name version)
493 #:phases (modify-phases %standard-phases
494 (replace 'configure ,chez-configure))))
495 (synopsis "Portable hygienic pattern matcher for Scheme")
496 (description "This package provides a superset of the popular Scheme
497 @code{match} package by Andrew Wright, written in fully portable
498 @code{syntax-rules} and thus preserving hygiene.")
499 (license public-domain)))
501 (define-public chez-irregex
503 (name "chez-irregex")
509 (url "https://github.com/fedeinthemix/chez-irregex")
510 (commit (string-append "v" version))))
512 (base32 "0jh6piylw545j81llay9wfivgpv6lcnwd81gm4w17lkasslir50q"))
513 (file-name (git-file-name name version))))
514 (build-system gnu-build-system)
516 `(("chez-matchable" ,chez-matchable))) ; for tests
518 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
520 `(("chez-scheme" ,chez-scheme)))
522 `(#:make-flags ,(chez-make-flags name version)
524 #:phases (modify-phases %standard-phases
525 (replace 'configure ,chez-configure))))
526 (home-page "https://github.com/fedeinthemix/chez-irregex")
527 (synopsis "Portable regular expression library for Scheme")
528 (description "This package provides a portable and efficient
529 R[4567]RS implementation of regular expressions, supporting both POSIX
530 syntax with various (irregular) PCRE extensions, as well as SCSH's SRE
531 syntax, with various aliases for commonly used patterns.")
534 (define-public chez-fmt
542 "http://synthcode.com/scheme/fmt/fmt-" version ".tar.gz"))
544 (base32 "1zxqlw1jyg85yzclylh8bp2b3fwcy3l3xal68jw837n5illvsjcl"))
545 (file-name (string-append name "-" version ".tar.gz"))))
546 (build-system gnu-build-system)
548 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
550 `(("chez-scheme" ,chez-scheme)))
552 `(#:make-flags ,(chez-make-flags name version)
553 #:test-target "chez-check"
555 (modify-phases %standard-phases
556 (replace 'configure ,chez-configure)
558 (lambda* (#:key (make-flags '()) #:allow-other-keys)
559 (apply invoke "make" "chez-build" make-flags)))
561 (lambda* (#:key (make-flags '()) #:allow-other-keys)
562 (apply invoke "make" "chez-install" make-flags))))))
563 (home-page "http://synthcode.com/scheme/fmt")
564 (synopsis "Combinator formatting library for Chez Scheme")
565 (description "This package provides a library of procedures for
566 formatting Scheme objects to text in various ways, and for easily
567 concatenating, composing and extending these formatters efficiently
568 without resorting to capturing and manipulating intermediate
572 (define-public chez-mit
576 (home-page "https://github.com/fedeinthemix/chez-mit")
582 (commit (string-append "v" version))))
584 (base32 "0c7i3b6i90xk96nmxn1pc9272a4yal4v40dm1a4ybdi87x53zkk0"))
585 (file-name (git-file-name name version))))
586 (build-system gnu-build-system)
588 `(("chez-srfi" ,chez-srfi))) ; for tests
590 `(("chez-scheme" ,chez-scheme)))
592 `(#:make-flags ,(chez-make-flags name version)
594 #:phases (modify-phases %standard-phases
595 (replace 'configure ,chez-configure))))
596 (synopsis "MIT/GNU Scheme compatibility library for Chez Scheme")
597 (description "This package provides a set of MIT/GNU Scheme compatibility
598 libraries for Chez Scheme. The main goal was to provide the functionality
599 required to port the program @code{Scmutils} to Chez Scheme.")
602 (define-public chez-scmutils
604 (name "chez-scmutils")
606 (home-page "https://github.com/fedeinthemix/chez-scmutils")
612 (commit (string-append "v" version))))
614 (base32 "0lb05wlf8qpgg8y0gdsyaxg1nbfx1qbaqdjvygrp64ndn8fnhq7l"))
615 (file-name (git-file-name name version))))
616 (build-system gnu-build-system)
618 `(("chez-srfi" ,chez-srfi))) ; for tests
620 `(("chez-scheme" ,chez-scheme)))
622 `(("chez-mit" ,chez-mit)
623 ("chez-srfi" ,chez-srfi)))
625 `(#:make-flags ,(chez-make-flags name version)
626 #:tests? #f ; no test suite
628 (modify-phases %standard-phases
629 (replace 'configure ,chez-configure)
630 ;; Since the documentation is lacking, we install the source
631 ;; code. For things to work correctly we have to replace
632 ;; relative paths by absolute ones in 'include' forms. This
633 ;; in turn requires us to compile the files in the final
636 (add-after 'install 'install-src
637 (lambda* (#:key (make-flags '()) #:allow-other-keys)
638 (apply invoke "make" "install-src" make-flags)))
639 (add-after 'install-src 'absolute-path-in-scm-files
640 (lambda* (#:key outputs #:allow-other-keys)
641 (let ((out (assoc-ref outputs "out")))
642 (for-each (lambda (file)
644 (("include +\"\\./scmutils")
645 (string-append "include \"" (dirname file)))))
646 (find-files out "\\.sls"))
647 (for-each (lambda (file)
649 (("include +\"\\./scmutils/simplify")
650 (string-append "include \"" (dirname file)))))
651 (find-files out "fbe-syntax\\.scm"))
653 (add-after 'absolute-path-in-scm-files 'build
654 (lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
655 (let* ((out (assoc-ref outputs "out"))
656 (mk-file (car (find-files out "Makefile"))))
657 (with-directory-excursion (dirname mk-file)
658 (apply invoke "make" "build" make-flags)))))
659 (add-after 'build 'clean-up
660 (lambda* (#:key outputs #:allow-other-keys)
661 (let* ((out (assoc-ref outputs "out")))
662 (for-each delete-file
663 (find-files out "Makefile|compile-all\\.ss"))
665 (synopsis "Port of MIT/GNU Scheme Scmutils to Chez Scheme")
666 (description "This package provides a port of the MIT/GNU Scheme
667 Scmutils program to Chez Scheme. The port consists of a set of
668 libraries providing most of the functionality of the original.")