projects/guix·blob python-team · refs

1424 lines · 60.6 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016 Federico Beffa <[email protected]>
3;;; Copyright © 2016, 2024 Efraim Flashner <[email protected]>
4;;; Copyright © 2017, 2019 Tobias Geerinckx-Rice <[email protected]>
5;;; Copyright © 2019 Brett Gilio <[email protected]>
6;;; Copyright © 2020 Brendan Tildesley <[email protected]>
7;;; Copyright © 2021-2025 Philip McGrath <[email protected]>
8;;; Copyright © 2024, 2026 Ashish SHUKLA <[email protected]>
9;;; Copyright © 2025 Zhu Zihao <[email protected]>
10;;; Copyright © 2026 Anderson Torres <[email protected]>
11;;;
12;;; This file is part of GNU Guix.
13;;;
14;;; GNU Guix is free software; you can redistribute it and/or modify it
15;;; under the terms of the GNU General Public License as published by
16;;; the Free Software Foundation; either version 3 of the License, or (at
17;;; your option) any later version.
18;;;
19;;; GNU Guix is distributed in the hope that it will be useful, but
20;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22;;; GNU General Public License for more details.
23;;;
24;;; You should have received a copy of the GNU General Public License
25;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27(define-module (gnu packages chez)
28 #:use-module (gnu packages)
29 #:use-module ((guix licenses) #:prefix license:)
30 #:use-module (guix packages)
31 #:use-module (guix deprecation)
32 #:use-module (guix download)
33 #:use-module (guix diagnostics)
34 #:use-module (guix i18n)
35 #:use-module (guix git-download)
36 #:use-module (guix utils)
37 #:use-module (guix gexp)
38 #:use-module (guix build-system copy)
39 #:use-module (guix build-system gnu)
40 #:use-module (guix build-system copy)
41 #:use-module (gnu packages compression)
42 #:use-module (gnu packages ncurses)
43 #:use-module (gnu packages ghostscript)
44 #:use-module (gnu packages libffi)
45 #:use-module (gnu packages linux)
46 #:use-module (gnu packages netpbm)
47 #:use-module (gnu packages racket)
48 #:use-module (gnu packages tex)
49 #:use-module (gnu packages compression)
50 #:use-module (gnu packages image)
51 #:use-module (gnu packages xorg)
52 #:use-module (ice-9 match)
53 #:use-module (srfi srfi-1)
54 #:use-module (srfi srfi-26)
55 #:use-module (srfi srfi-34)
56 #:export (chez-scheme-for-system
57 nix-system->native-chez-machine-type
58 nix-system->pbarch-machine-type
59 unpack-nanopass))
60
61;; Commentary:
62;;
63;; The bootstrapping paths for Chez Scheme and Racket are closely
64;; entwined. See "Bootstrapping Racket" in the commentary on "racket.scm" for
65;; details on the Racket portion of Chez Scheme's bootstrapping path.
66;;
67;; Chez Scheme is a self-hosting compiler. A small kernel implemented in C
68;; loads "boot files" (in a custom object file format) compiled from the parts
69;; of the system implemented in Chez Scheme. (While Chez Scheme generates
70;; native machine code, it implements its own linker and loader.)
71;;
72;; As of Chez Scheme 10.0.0 (and the pre-release versions that preceded it on
73;; the Racket branch), there are several ways to obtain boot files:
74;;
75;; 1. The Racket package "cs-bootstrap" (in the "racket/src/rktboot/"
76;; directory of the main Racket Git repository) simulates enough of Chez
77;; Scheme to load the Chez Scheme compiler purely from source into Racket
78;; and apply the compiler to itself, producing the needed boot files
79;; (albeit very slowly).
80;; Any variant of Racket since version 7.1 can run the simulation. Using
81;; the older Racket BC implementation, which does not depend on Chez
82;; Scheme, breaks the dependency cycle.
83;; However, the simulation relies on implementation details of Chez
84;; Scheme, so a given version of Chez Scheme can only be bootstrapped by
85;; the corresponding version of the "cs-bootstrap" package.
86;;
87;; 2. The Chez Scheme makefile provides a "re.boot" target for bootstrapping
88;; via a different version of Chez Scheme (9.5.4 or later).
89;; This path manages potential differences in implementation details
90;; across Chez Scheme versions using a strategy similar to "cs-bootstrap",
91;; but the compatibility shim is maintained with the Chez Scheme source
92;; code (in "s/reboot.ss"). Also, it's faster, since less indirection is
93;; needed.
94;;
95;; 3. For cross-compilation, or with an extremely similar Chez Scheme, the
96;; makefile provides "cross.boot" and related targets.
97;;
98;; 4. The Chez Scheme Git repository includes pre-built "pb" (portable
99;; bytecode) boot files, which can be used for bootstrapping on any
100;; platform, but these binary files are removed from the source Guix uses.
101;;
102;; Concretely, we use racket-vm-bc to bootstrap chez-scheme-for-racket, which
103;; we then use to bootstrap both chez-scheme and racket-vm-cs.
104;;
105;; In principle, it would be possible instead to use chez-scheme to bootstrap
106;; chez-scheme-for-racket. However, since Racket is ultimately used for
107;; bootstrapping, chez-scheme would still need to be rebuilt when Racket
108;; changes, whereas treating chez-scheme as a leaf avoids having to rebuild
109;; Racket when upstream Chez Scheme changes. Furthermore, since "cs-bootstrap"
110;; is developed in the Racket source repository, we don't have to look for the
111;; version of "cs-bootstrap" compatible with the upstream Chez Scheme release.
112;;
113;; Code:
114
115(define-deprecated (chez-scheme-for-system #:optional system) chez-scheme
116 "Returns 'chez-scheme'."
117 chez-scheme)
118
119(define* (target-chez-arch #:optional (system
120 (or (%current-target-system)
121 (%current-system))))
122 "Return a string representing the architecture of SYSTEM as used in Chez
123Scheme machine types, or '#f' if none is defined."
124 (cond
125 ((target-x86-64? system)
126 "a6")
127 ((target-x86-32? system)
128 "i3")
129 ((target-aarch64? system)
130 "arm64")
131 ((target-arm32? system)
132 "arm32")
133 ((target-ppc64le? system)
134 #f)
135 ((target-ppc32? system)
136 "ppc32")
137 ((target-riscv64? system)
138 "rv64")
139 ((string-prefix? "loongarch64-" system)
140 "la64")
141 (else
142 #f)))
143
144(define* (target-chez-os #:optional (system (or (%current-target-system)
145 (%current-system))))
146 "Return a string representing the operating system kernel of SYSTEM as used
147in Chez Scheme machine types, or '#f' if none is defined."
148 ;; e.g. "le" includes both GNU/Linux and Android
149 (cond
150 ((target-linux? system)
151 "le")
152 ((target-hurd? system)
153 "gnu")
154 ((target-mingw? system)
155 "nt")
156 ;; missing (guix utils) predicates
157 ;; cf. https://github.com/NixOS/nixpkgs/blob/master/lib/systems/doubles.nix
158 ((string-suffix? "-darwin" system)
159 "osx")
160 ((string-suffix? "-freebsd" system)
161 "fb")
162 ((string-suffix? "-openbsd" system)
163 "ob")
164 ((string-suffix? "-netbsd" system)
165 "nb")
166 ;; Nix says "x86_64-solaris", but accommodate "-solaris2"
167 ((string-contains system "solaris")
168 "s2")
169 ((string-suffix? "-qnx" system)
170 "qnx")
171 ;; unknown
172 (else
173 #f)))
174
175(define-syntax define-machine-types
176 (lambda (stx)
177 (syntax-case stx (any)
178 ((_ any id0 id ...)
179 #`(define #,(datum->syntax #'id0 '%machine-types)
180 '(id0 id ...))))))
181;; The following is copied from s/cmacros.ss, line 376, in the Chez source
182(define-machine-types
183 any
184 pb tpb
185 pb32l tpb32l
186 pb32b tpb32b
187 pb64l tpb64l
188 pb64b tpb64b
189 i3nt ti3nt
190 i3osx ti3osx
191 i3le ti3le
192 i3fb ti3fb
193 i3ob ti3ob
194 i3nb ti3nb
195 i3s2 ti3s2
196 i3qnx ti3qnx
197 i3gnu ti3gnu
198 a6nt ta6nt
199 a6osx ta6osx
200 a6ios ta6ios
201 a6le ta6le
202 a6fb ta6fb
203 a6ob ta6ob
204 a6nb ta6nb
205 a6s2 ta6s2
206 ppc32osx tppc32osx
207 ppc32le tppc32le
208 ppc32fb tppc32fb
209 ppc32ob tppc32ob
210 ppc32nb tppc32nb
211 arm32le tarm32le
212 arm32fb tarm32fb
213 arm32ob tarm32ob
214 arm32nb tarm32nb
215 arm64nt tarm64nt
216 arm64osx tarm64osx
217 arm64ios tarm64ios
218 arm64le tarm64le
219 arm64fb tarm64fb
220 arm64ob tarm64ob
221 arm64nb tarm64nb
222 rv64le trv64le
223 rv64fb trv64fb
224 rv64ob trv64ob
225 rv64nb trv64nb
226 la64le tla64le
227)
228
229(define* (nix-system->pbarch-machine-type #:optional
230 (system
231 (or (%current-target-system)
232 (%current-system)))
233 #:key (threads? #t))
234 "Return a string naming the Chez Scheme machine type of the appropriate
235``pbarch'' backend for SYSTEM: that is, the ``portable bytecode'' backend
236specialized for SYSTEM's word size and endianness. The result will name the
237threaded machine type unless THREADS? is provided as #f."
238 (string-append (if threads?
239 "t"
240 "")
241 "pb"
242 (if (target-64bit? system)
243 "64"
244 "32")
245 (if (target-little-endian? system)
246 "l"
247 "b")))
248
249(define* (nix-system->native-chez-machine-type #:optional
250 (system
251 (or (%current-target-system)
252 (%current-system)))
253 #:key (threads? #t))
254 "Return a string naming the Chez Scheme machine type of the native-code
255backend for SYSTEM, if such a native-code backend exists. Otherwise, when
256SYSTEM can use only the ``portable bytecode'' backends, return #f. The result
257will name the threaded machine type unless THREADS? is provided as #f."
258 (let* ((chez-arch (target-chez-arch system))
259 (chez-os (target-chez-os system))
260 (machine
261 (and chez-arch chez-os
262 (string-append (if threads? "t" "") chez-arch chez-os))))
263 (and machine
264 (memq (string->symbol machine) %machine-types)
265 machine)))
266;;
267;; Chez Scheme:
268;;
269
270(define unpack-nanopass
271 #~(lambda* (#:key inputs native-inputs #:allow-other-keys)
272 (with-directory-excursion (if (directory-exists? "racket/src/ChezScheme")
273 "racket/src/ChezScheme"
274 ".")
275 (symlink (dirname (search-input-file (or native-inputs inputs)
276 "lib/chez-scheme/nanopass.ss"))
277 "nanopass"))))
278
279(define chez-configure
280 ;; The custom Chez 'configure' script doesn't allow unrecognized flags, such
281 ;; as those automatically added by `gnu-build-system`. This replacement
282 ;; phase uses only the explicitly provided `#:configure-flags`.
283 #~(lambda* (#:key inputs (configure-flags '()) out-of-source?
284 #:allow-other-keys)
285 (let* ((abs-srcdir (getcwd))
286 (srcdir (if out-of-source?
287 (string-append "../" (basename abs-srcdir))
288 ".")))
289 (format #t "source directory: ~s (relative from build: ~s)~%"
290 abs-srcdir srcdir)
291 (when out-of-source?
292 (begin
293 (mkdir "../build")
294 (chdir "../build")))
295 (format #t "build directory: ~s~%" (getcwd))
296 (format #t "configure flags: ~s~%" configure-flags)
297 (apply invoke
298 (string-append srcdir "/configure")
299 configure-flags))))
300
301(define-public chez-scheme-for-racket
302 (package
303 (name "chez-scheme-for-racket")
304 ;; The version should match `(scheme-version #t)`.
305 ;; See s/cmacros.ss c. line 360.
306 (version "10.5.0-pre-release.1") ; expect a chez-nanopass-bootstrap update
307 (source #f)
308 (build-system gnu-build-system)
309 (inputs `(,@(if (nix-system->native-chez-machine-type)
310 '()
311 (list libffi))
312 ,chez-scheme-for-racket-bootstrap-bootfiles
313 ,lz4
314 ,ncurses ;<-- for expeditor
315 ,zlib))
316 (native-inputs `(,@(if (%current-target-system)
317 (list this-package
318 `(,this-package "doc"))
319 (list stex-bootstrap
320 (texlive-local-tree
321 (list texlive-enumitem
322 texlive-etoolbox))))
323 ,chez-nanopass-bootstrap
324 ,zuo))
325 (native-search-paths
326 (list (search-path-specification
327 (variable "CHEZSCHEMELIBDIRS")
328 (files '("lib/chez-scheme")))))
329 (outputs '("out" "debug" "doc"))
330 (arguments
331 (list
332 #:modules
333 '((guix build gnu-build-system)
334 (guix build utils)
335 (ice-9 ftw)
336 (ice-9 match)
337 (srfi srfi-34))
338 #:out-of-source? #t
339 #:test-target "test" ; test-one test-some-fast test-some test test-more
340 ;; Tests take more than 30 hours on riscv64.
341 #:tests? (and (not (target-riscv64?))
342 (not (%current-target-system)))
343 #:configure-flags
344 #~`(,@(let* ((chez+version (strip-store-file-name #$output))
345 (doc-dir (string-append #$output:doc
346 "/share/doc/"
347 chez+version)))
348 (list (string-append "--installcsug="
349 doc-dir
350 "/csug")
351 (string-append "--installreleasenotes="
352 doc-dir
353 "/release_notes")))
354 ,(string-append "--installprefix=" #$output)
355 #$@(if (%current-target-system)
356 (list (string-append "--toolprefix="
357 (%current-target-system)
358 "-"))
359 '())
360 ,@(if (false-if-exception
361 (search-input-directory %build-inputs "/include/X11"))
362 '()
363 '("--disable-x11"))
364 #$(string-append "-m=" (or (nix-system->native-chez-machine-type)
365 (nix-system->pbarch-machine-type)))
366 ;; ^ could skip -m= for non-cross non-pbarch builds
367 #$@(if (nix-system->native-chez-machine-type)
368 #~()
369 ;; not inferred on non-native platforms: see
370 ;; https://racket.discourse.group/t/950/9
371 #~("--enable-libffi"
372 "CFLAGS+=-g -D_REENTRANT -pthread"
373 "LIBS+=-lm -ldl -lrt -lncurses"))
374 ,(string-append "STEXLIB="
375 (or (false-if-exception
376 (search-input-directory %build-inputs
377 "/lib/stex"))
378 "/GuixNotUsingStex"))
379 "ZUO=zuo"
380 "ZLIB=-lz"
381 "LZ4=-llz4"
382 ;; Guix will do 'compress-man-pages',
383 ;; and letting Chez try caused an error (at one point)
384 "--nogzip-man-pages")
385 #:phases
386 #~(modify-phases %standard-phases
387 (replace 'unpack
388 (let ((unpack (assoc-ref %standard-phases 'unpack)))
389 (lambda args
390 (unpack #:source #$(or (package-source this-package)
391 (package-source racket-vm-bc))))))
392 (add-after 'unpack 'unpack-nanopass
393 #$unpack-nanopass)
394 (add-after 'unpack-nanopass 'maybe-chdir
395 (lambda args
396 (when (directory-exists? "racket/src/ChezScheme")
397 (chdir "racket/src/ChezScheme"))))
398 (add-after 'maybe-chdir 'unpack-bootfiles
399 (lambda* (#:key native-inputs inputs #:allow-other-keys)
400 (when (directory-exists? "boot")
401 (delete-file-recursively "boot"))
402 (copy-recursively
403 (search-input-directory inputs "lib/chez-scheme-bootfiles")
404 "boot")))
405 (replace 'configure
406 #$chez-configure)
407 (add-after 'configure 'configure-environment-variables
408 (lambda args
409 ;; mats/6.ms needs HOME to be set:
410 (setenv "HOME" "/tmp")
411 ;; Writable TEXMFVAR is required to generate font shapes.
412 (setenv "TEXMFVAR" "/tmp")))
413 (replace 'build
414 ;; need to override target for cross-compilation
415 ;; https://racket.discourse.group/t/950/19
416 (let ((gnu:build (assoc-ref %standard-phases 'build)))
417 (lambda* (#:key target (make-flags '()) (parallel-build? #t)
418 #:allow-other-keys)
419 (gnu:build #:make-flags (if target
420 (cons "kernel" make-flags)
421 make-flags)
422 #:parallel-build? parallel-build?))))
423 (add-before 'check 'build-docs
424 ;; Building the documentation requires stex and a running scheme.
425 ;; This comes BEFORE 'check because the test suite may take on the
426 ;; order of an hour (without parallelism), so we want to get any
427 ;; other errors first.
428 ;; TODO: Improve cross support upstream: currently, it tries to
429 ;; run the cross-compiled scheme.
430 (lambda* (#:key native-inputs (make-flags '()) #:allow-other-keys)
431 #$(if (%current-target-system)
432 #~(format #t "not building docs for cross~%")
433 #~(apply invoke "make" "docs" make-flags))))
434 ;; The binary file name is called "scheme" as is the one from
435 ;; MIT/GNU Scheme. We add a symlink to use in case both are
436 ;; installed.
437 (add-after 'install 'install-symlink
438 (lambda* (#:key outputs #:allow-other-keys)
439 (let* ((bin-dir
440 (dirname (search-input-file outputs "/bin/scheme")))
441 (boot-dir
442 (match (find-files (string-append bin-dir "/../lib")
443 "scheme.boot")
444 ((scheme.boot)
445 (dirname scheme.boot)))))
446 (for-each (lambda (dir)
447 (with-directory-excursion dir
448 (symlink "./scheme" "chez-scheme")
449 (when (file-exists? "scheme.boot")
450 (symlink "./scheme.boot" "chez-scheme.boot"))))
451 (list bin-dir boot-dir)))))
452 (add-after 'install-symlink 'install-docs
453 ;; TODO: Improve cross support upstream.
454 ;; The `install-docs` target has a Zuo dependency on the `docs`
455 ;; target, so we have the same problem as the build-docs phase.
456 (lambda* (#:key native-inputs (make-flags '()) #:allow-other-keys)
457 #$(if (%current-target-system)
458 #~(let* ((rel
459 (string-append "share/doc/"
460 (strip-store-file-name #$output)))
461 (found/csug
462 (search-input-directory
463 native-inputs (string-append rel "/csug")))
464 (found (substring found/csug
465 0
466 (- (string-length found/csug)
467 (string-length "/csug"))))
468 (dest (string-append #$output:doc "/" rel)))
469 (mkdir-p dest)
470 (with-directory-excursion dest
471 (for-each (lambda (f)
472 (symlink (string-append found "/" f)
473 f))
474 '("csug" "csug.pdf"
475 "release_notes" "release_notes.pdf"))))
476 #~(apply invoke "make" "install-docs" make-flags))))
477 (add-after 'install-docs 'link-doc-pdfs
478 ;; otherwise, it's hard to notice them in a forest of HTML files
479 ;; TODO: improve cross support upstream.
480 (lambda* (#:key outputs #:allow-other-keys)
481 #$(if (%current-target-system)
482 #~(format #t "nothing to be done for cross~%")
483 #~(with-directory-excursion
484 (string-append (or (assoc-ref outputs "doc")
485 (assoc-ref outputs "out"))
486 "/share/doc/"
487 (strip-store-file-name #$output))
488 (symlink "release_notes/release_notes.pdf"
489 "release_notes.pdf")
490 (match (find-files
491 "csug"
492 "csug.*\\.pdf$" ;; embedded version number
493 #:fail-on-error? #t)
494 ((pth)
495 (symlink pth
496 "csug.pdf"))))))))))
497 (home-page "https://cisco.github.io/ChezScheme/")
498 (synopsis "Bootstrapping version of Chez Scheme")
499 (description
500 "This is the precise pre-release version of Chez Scheme from a specific
501Racket release. It is used to build Racket and to bootstrap the released
502version of Chez Scheme.")
503 (license license:asl2.0)))
504
505(define-public chez-scheme
506 (package
507 (inherit chez-scheme-for-racket)
508 (name "chez-scheme")
509 ;; The version should match `(scheme-version-number #t)`.
510 ;; See s/cmacros.ss c. line 360.
511 (version "10.4.0") ; expect a chez-nanopass-bootstrap update
512 (source (origin
513 (method git-fetch)
514 (uri (git-reference
515 (url "https://github.com/cisco/ChezScheme")
516 (commit (string-append "v" version))))
517 (sha256
518 (base32
519 "079vlkl27qdvsg1rsynmd828m42n98c2dnldkhsxf2slfsqd9kv5"))
520 (file-name (git-file-name name version))
521 (patches (search-patches "chez-scheme-bin-sh.patch"))
522 (snippet #~(begin
523 (use-modules (guix build utils))
524 ;; TODO: consider putting this in a (guix ...) or
525 ;; (guix build ...) module so it can be shared
526 ;; with the Racket origin without cyclic issues.
527 (for-each (lambda (dir)
528 (when (directory-exists? dir)
529 (delete-file-recursively dir)))
530 '("boot"
531 "lz4"
532 "nanopass"
533 "stex"
534 "zlib"
535 "zuo"))))))
536 (build-system gnu-build-system)
537 (inputs
538 (modify-inputs inputs
539 (replace "chez-scheme-for-racket-bootstrap-bootfiles"
540 chez-scheme-bootstrap-bootfiles)
541 ;; for X11 clipboard support in expeditor:
542 ;; https://github.com/cisco/ChezScheme/issues/9#issuecomment-222057232
543 (prepend libx11)))
544 ;; replace unpack phase?
545 (home-page "https://cisco.github.io/ChezScheme/")
546 (synopsis "R6RS Scheme compiler and run-time")
547 (description
548 "Chez Scheme is both a programming language and a high-performance
549implementation of that language. The language is a superset of R6RS Scheme
550with numerous extensions, including native threads, non-blocking I/O, local
551modules, and much more. Chez Scheme compiles source expressions incrementally
552to machine code, providing the speed of compiled code in an interactive
553system. The system is intended to be as reliable and efficient as possible,
554with reliability taking precedence over efficiency if necessary.")
555 (license license:asl2.0)))
556
557;;
558;; Bootfiles:
559;;
560
561(define-public chez-scheme-for-racket-bootstrap-bootfiles
562 (package
563 (name "chez-scheme-for-racket-bootstrap-bootfiles")
564 (version (package-version chez-scheme-for-racket))
565 (source #f) ; avoid problematic cycle with racket.scm
566 (native-inputs
567 (cons chez-nanopass-bootstrap
568 (if (%current-target-system)
569 (list zuo
570 chez-scheme-for-racket)
571 (list racket-vm-bc))))
572 (build-system copy-build-system)
573 (arguments
574 (list
575 #:install-plan
576 #~`(("boot/" "lib/chez-scheme-bootfiles"))
577 #:phases
578 #~(modify-phases %standard-phases
579 (replace 'unpack
580 (let ((unpack (assoc-ref %standard-phases 'unpack)))
581 (lambda args
582 (unpack #:source #$(or (package-source this-package)
583 (package-source racket-vm-bc))))))
584 (add-after 'unpack 'unpack-nanopass
585 #$unpack-nanopass)
586 (add-after 'unpack-nanopass 'chdir
587 (lambda args
588 (chdir "racket/src/ChezScheme")))
589 (add-before 'install 'build
590 #$(cond
591 ((%current-target-system)
592 ;; cross-compiling
593 ;; TODO: share more of this with upstream, once we figure out
594 ;; how best to manage running Chez as a cross-compiler and the
595 ;; unfortate cycle with %racket-origin.
596 #~(lambda* (#:key native-inputs inputs (parallel-build? #t)
597 #:allow-other-keys)
598 (invoke "./configure"
599 "--force" ; don't complain about missing bootfiles
600 #$(string-append
601 "-m=" (or (nix-system->native-chez-machine-type)
602 (nix-system->pbarch-machine-type)))
603 "ZUO=zuo"
604 ;; ignore submodules:
605 "ZLIB=-lz"
606 "LZ4=-llz4"
607 "STEXLIB=/GuixNotUsingStex")
608 (apply invoke
609 "make"
610 `(,@(if parallel-build?
611 `("-j" ,(number->string
612 (parallel-job-count)))
613 '())
614 ,(string-append "SCHEME="
615 (search-input-file
616 (or native-inputs inputs)
617 "/bin/scheme"))
618 "cross.boot"))))
619 (else
620 ;; bootstrapping
621 #~(lambda* (#:key native-inputs inputs #:allow-other-keys)
622 ;; Make sure we're building for the correct machine type.
623 (setenv "MACH"
624 #$@(if (nix-system->native-chez-machine-type)
625 #~(#$(nix-system->native-chez-machine-type))
626 #~(#$(nix-system->pbarch-machine-type))))
627 (invoke
628 (search-input-file (or native-inputs inputs)
629 "/opt/racket-vm/bin/racket")
630 "../rktboot/main.rkt"))))))))
631 (home-page "https://pkgs.racket-lang.org/package/cs-bootstrap")
632 (synopsis "Chez Scheme boot files bootstrapped by Racket")
633 (description "Chez Scheme is a self-hosting compiler: building it requires
634``boot files'' containing the Scheme-implemented portions compiled for the
635current platform. (Chez can then cross-compile boot files for all other
636supported platforms.)
637
638The Racket package @code{cs-bootstrap} (part of the main Racket Git
639repository) implements enough of a Chez Scheme simulation to load the Chez
640Scheme compiler purely from source into Racket and apply the compiler to
641itself, thus bootstrapping Chez Scheme. Bootstrapping takes about 10 times as
642long as using an existing Chez Scheme, but @code{cs-bootstrap} supports Racket
6437.1 and later, including the Racket BC variant.")
644 (license license:asl2.0)))
645
646(define-public chez-scheme-bootstrap-bootfiles
647 (package
648 (name "chez-scheme-bootstrap-bootfiles")
649 (version (package-version chez-scheme))
650 (source (package-source chez-scheme))
651 (native-inputs (list chez-nanopass-bootstrap
652 (if (%current-target-system)
653 chez-scheme
654 chez-scheme-for-racket)
655 zuo))
656 (outputs '("out"))
657 (build-system gnu-build-system)
658 (arguments
659 (list
660 #:configure-flags
661 #~`("--force" ; don't complain about missing bootfiles
662 "ZLIB=-lz" "LZ4=-llz4" "STEXLIB=/GuixNotUsingStex" ; ignore submods
663 "ZUO=zuo"
664 ;; could skip -m= for non-cross non-pbarch builds
665 #$(string-append "-m=" (or (nix-system->native-chez-machine-type)
666 (nix-system->pbarch-machine-type))))
667 #:make-flags
668 #~(list (string-append "SCHEME="
669 (search-input-file %build-inputs "/bin/scheme"))
670 #$(if (%current-target-system)
671 "cross.boot"
672 "re.boot"))
673 #:phases
674 #~(modify-phases %standard-phases
675 (add-after 'unpack 'unpack-nanopass
676 #$unpack-nanopass)
677 (replace 'configure
678 #$chez-configure)
679 (delete 'check)
680 (replace 'install
681 (lambda args
682 (mkdir-p (string-append #$output "/lib"))
683 (copy-recursively
684 "boot"
685 (string-append #$output "/lib/chez-scheme-bootfiles")))))))
686 (home-page "https://cisco.github.io/ChezScheme/")
687 (synopsis "Bootstrapped Chez Scheme boot files")
688 (description
689 "Chez Scheme is a self-hosting compiler: building it requires ``boot
690files'' containing the Scheme-implemented portions compiled for the current
691platform. (Chez can then cross-compile bootfiles for all other supported
692platforms.)
693
694This package provides boot files for the released version of Chez Scheme
695bootstrapped by @code{chez-scheme-for-racket}. Chez Scheme 9.5.4 or any later
696version can be used for bootstrapping. Guix ultimately uses the Racket
697package @code{cs-bootstrap} to bootstrap its initial version of Chez Scheme.")
698 (license license:asl2.0)))
699
700;;
701;; Chez's bootstrap dependencies:
702;;
703
704(define-public stex-bootstrap
705 ;; This commit includes a fix which we would otherwise want to use as
706 ;; patch. Let's revert to tagged releases as soon as one becomes available.
707 (let ((commit "afa607564a5662ffd748e824801277a6b5a3d11c")
708 (revision "2"))
709 (hidden-package
710 (package
711 (name "stex")
712 ;; ^ Debian calls this "stex", not "chez-stex". It is a set of
713 ;; command-line tools, and there isn't a Scheme API, let alone a
714 ;; Chez-specific one, except perhaps that the Scheme examples are
715 ;; assumed to be Chez-compatible.
716 (version (git-version "1.2.2" revision commit))
717 (source
718 (origin
719 (method git-fetch)
720 (uri (git-reference
721 (url "https://github.com/dybvig/stex")
722 (commit commit)))
723 (sha256
724 (base32 "0n6dryv5j7cw2qmsj55wqb0ph901h83a2hl4j891ppxp0xx18nkp"))
725 (file-name (git-file-name name version))
726 (patches
727 ;; submitted upstream in https://github.com/dybvig/stex/pull/6
728 (search-patches "stex-copy-from-immutable-store.patch"))
729 (snippet
730 #~(for-each delete-file
731 '("sbin/install" "doc/stex.pdf" "doc/stex.html")))))
732 (outputs '("out"))
733 (build-system copy-build-system)
734 ;; N.B. Upstream does not seem to support cross-compilation,
735 ;; though it would probably be easy to add.
736 (propagated-inputs
737 (list xorg-rgb
738 (texlive-local-tree (list texlive-epsf))
739 ghostscript
740 netpbm))
741 ;; Debian uses a versionless path for STEXLIB,
742 ;; which is much more convenient.
743 (arguments
744 (list
745 #:install-plan #~`(("inputs" "lib/stex/")
746 ("gifs" "lib/stex/")
747 ("math" "lib/stex/")
748 ("src" "lib/stex/")
749 ("Mf-stex" "lib/stex/")
750 ("Makefile.template" "lib/stex/"))
751 #:modules
752 '((guix build copy-build-system)
753 (guix build utils)
754 (ice-9 popen))
755 #:phases
756 #~(modify-phases %standard-phases
757 (add-before 'install 'patch-sources
758 (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
759 (define scheme
760 (false-if-exception
761 (search-input-file inputs "/bin/scheme")))
762 (when scheme
763 (setenv "Scheme" scheme))
764 (substitute* '("Makefile.template"
765 "doc/Makefile")
766 (("STEXLIB=[^\n]*")
767 (string-append "STEXLIB=" #$output "/lib/stex"))
768 (("Scheme=[^\n]*")
769 (string-append "Scheme=" (or scheme "scheme"))))
770 (substitute* '("Mf-stex"
771 "math/Makefile")
772 (("/bin/rm")
773 "rm"))
774 (substitute* "Mf-stex"
775 (("SHELL=bash")
776 ;; avoid Solaris workaround
777 "#SHELL=bash"))))
778 (add-after 'install 'maybe-compile
779 (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
780 (cond
781 ((getenv "Scheme")
782 => (lambda (scheme)
783 (define makefile
784 (string-append (getcwd) "/Makefile"))
785 (define machine
786 (let ((pipe (open-pipe* OPEN_BOTH scheme "-q")))
787 ;; try to not be wrong for cross-compilation
788 ;; (avoid #% reader abbreviation for Guile)
789 (write '(($primitive $target-machine)) pipe)
790 (force-output pipe)
791 (let ((sym (read pipe)))
792 (close-pipe pipe)
793 (symbol->string sym))))
794 (with-directory-excursion
795 (search-input-directory outputs "/lib/stex")
796 (invoke "make"
797 "-f" makefile
798 (string-append "Scheme=" scheme))
799 (for-each delete-file
800 (find-files machine "\\.")))))
801 (else
802 ;; for bootstrapping, can run without ahead-of-time
803 ;; compilation
804 (format #t "not compiling~%")))))
805 (add-after 'maybe-compile 'maybe-make-docs
806 (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
807 (cond
808 ((assoc-ref outputs "doc")
809 => (lambda (doc-prefix)
810 (define doc-dir
811 (string-append doc-prefix "/share/doc/stex"))
812 ;; the Makefile is referenced in the documentation
813 (copy-recursively "doc" doc-dir)
814 (install-file "ReadMe" doc-dir)
815 (setenv "TEXMFVAR" "/tmp") ;for generating font shapes
816 (with-directory-excursion "doc"
817 (invoke "make")
818 (install-file "stex.html" doc-dir)
819 (install-file "stex.pdf" doc-dir))))
820 (else
821 (format #t "not making docs~%"))))))))
822 (home-page "https://github.com/dybvig/stex")
823 (synopsis "LaTeX with embedded Scheme code and HTML generation")
824 (description "The @code{stex} package extends LaTeX with a handful of
825commands for including Scheme code (or pretty much any other kind of code, as
826long as you don't plan to use the Scheme-specific transcript support) in a
827document. It provides the programs @code{scheme-prep} and @code{html-prep} to
828convert @code{stex} documents to LaTeX and HTML, respectively, plus makefile
829templates, style files, and other resources. The @code{stex} system is used
830to typeset @cite{The Scheme Programming Language} and the @cite{Chez Scheme
831User's Guix}, among other documents.")
832 (license license:expat)))))
833
834(define-public stex
835 (package/inherit stex-bootstrap
836 (inputs (modify-inputs inputs
837 (prepend chez-scheme)))
838 (outputs '("out" "doc"))
839 (properties '())))
840
841(define-public chez-nanopass-bootstrap
842 (hidden-package
843 (package
844 (name "chez-nanopass-bootstrap")
845 (version "1.9.4")
846 (properties '((chez-nanopass-release-date . "December 29, 2025")))
847 (source
848 (origin
849 (method git-fetch)
850 (uri (git-reference
851 (url "https://github.com/nanopass/nanopass-framework-scheme")
852 (commit (string-append "v" version))))
853 (sha256
854 (base32 "1qq0vnbrvcialgjgnblfq3qp1ilqg94h0kg896ksd9v4g7ipj9v0"))
855 (file-name (git-file-name "nanopass-framework-scheme" version))
856 (snippet
857 #~(begin
858 (use-modules (guix build utils))
859 (when (file-exists? "doc/user-guide.pdf")
860 (delete-file "doc/user-guide.pdf"))
861 (substitute* "doc/Makefile"
862 (("include ~/stex/Mf-stex")
863 "include $(STEXLIB)/Mf-stex"))))))
864 (build-system copy-build-system)
865 ;; TODO: cross-compilation
866 (arguments
867 (let ((base-install-plan
868 #~`(("nanopass.ss" "lib/chez-scheme/")
869 ("nanopass" "lib/chez-scheme/"))))
870 (cond
871 ((this-package-native-input "chez-scheme")
872 (list #:install-plan
873 #~`(("nanopass.so" "lib/chez-scheme/")
874 ("doc/user-guide.pdf" #$(string-append
875 "share/doc/"
876 (package-name this-package)
877 "-"
878 (package-version this-package)
879 "/"))
880 ,@#$base-install-plan)
881 #:phases
882 #~(modify-phases %standard-phases
883 (add-after 'unpack 'fix-user-guide-date
884 (lambda args
885 (define release-date
886 #$(match (assq 'chez-nanopass-release-date (package-properties this-package))
887 ((_ . (? string? date))
888 date)
889 (bad
890 (raise (formatted-message
891 (G_ "missing or malformed '~a' property: ~a")
892 'chez-nanopass-release-date
893 bad)))))
894 (substitute* "doc/user-guide.stex"
895 (("^\\\\author.*$" all)
896 (string-append all "\n" "\\date{" release-date "}")))))
897 (add-before 'install 'compile-and-test
898 (lambda args
899 (invoke "scheme"
900 "--compile-imported-libraries"
901 "--program" "test-all.ss")))
902 (add-after 'compile-and-test 'build-doc
903 (lambda* (#:key native-inputs inputs #:allow-other-keys)
904 (with-directory-excursion "doc"
905 ;; Texlive-libkpathsea attempts to create directory at
906 ;; '$XDG_CACHE_HOME/.texliveYYYY'.
907 (setenv "XDG_CACHE_HOME" "/tmp")
908 (invoke "make"
909 (string-append "Scheme="
910 (search-input-file
911 (or native-inputs inputs)
912 "/bin/scheme"))
913 (string-append "STEXLIB="
914 (search-input-directory
915 (or native-inputs inputs)
916 "/lib/stex")))))))))
917 (else ; bootstrapping
918 (list #:install-plan base-install-plan)))))
919 (home-page "https://nanopass.org")
920 (synopsis "DSL for compiler development")
921 (description "The Nanopass framework is an embedded domain-specific
922language for writing compilers composed of several simple passes that
923operate over well-defined intermediate languages. The goal of this
924organization is both to simplify the understanding of each pass, because it
925is responsible for a single task, and to simplify the addition of new passes
926anywhere in the compiler. Nanopass reduces the boilerplate required to
927create compilers, making them easier to understand and maintain.")
928 (license license:expat))))
929
930(define-public chez-nanopass
931 (package
932 (inherit chez-nanopass-bootstrap)
933 (name "chez-nanopass")
934 (version "1.9.4")
935 (properties '((chez-nanopass-release-date . "December 29, 2025")))
936 (source
937 (let ((bootstrap-origin (package-source chez-nanopass-bootstrap)))
938 (origin
939 (inherit bootstrap-origin)
940 (uri (git-reference
941 (url (git-reference-url (origin-uri bootstrap-origin)))
942 (commit (string-append "v" version))))
943 (sha256
944 (base32 "1qq0vnbrvcialgjgnblfq3qp1ilqg94h0kg896ksd9v4g7ipj9v0"))
945 (file-name (git-file-name "nanopass-framework-scheme" version)))))
946 (native-inputs (list chez-scheme stex))))
947
948;;
949;; Other Chez packages:
950;;
951
952;; Help function for Chez Scheme to add the current path to
953;; CHEZSCHEMELIBDIRS.
954(define configure-chezschemelibdirs
955 #~(lambda _
956 (let ((chez-env (getenv "CHEZSCHEMELIBDIRS")))
957 (setenv "CHEZSCHEMELIBDIRS"
958 (if chez-env
959 (string-append ".:" chez-env)
960 ".")))))
961
962;; Help function to define make flags for some Chez Scheme custom make
963;; files.
964(define (chez-make-flags name version)
965 #~(let ((out #$output))
966 (list
967 ;; Set 'schemedir' so that libraries are installed in
968 ;; 'lib/chez-scheme' like Chez's 'native-search-paths' expects.
969 (string-append "schemedir=" out "/lib/chez-scheme")
970 (string-append "PREFIX=" out)
971 (string-append "DOCDIR=" out "/share/doc/" #$name "-" #$version))))
972
973(define-public chez-srfi
974 (package
975 (name "chez-srfi")
976 (version "1.0")
977 (source
978 (origin
979 (method git-fetch)
980 (uri (git-reference
981 (url "https://github.com/fedeinthemix/chez-srfi")
982 (commit (string-append "v" version))))
983 (sha256
984 (base32 "1vgn984mj2q4w6r2q66h7qklp2hrh85wwh4k9yisga5fi0ps7myf"))
985 (file-name (git-file-name name version))))
986 (build-system gnu-build-system)
987 (native-inputs
988 (list chez-scheme))
989 (arguments
990 (list #:make-flags (chez-make-flags name version)
991 #:test-target "test"
992 #:phases #~(modify-phases %standard-phases
993 (replace 'configure
994 #$configure-chezschemelibdirs))))
995 (home-page "https://github.com/fedeinthemix/chez-srfi")
996 (synopsis "SRFI libraries for Chez Scheme")
997 (description
998 "This package provides a collection of SRFI libraries for Chez Scheme.")
999 (license license:expat)))
1000
1001(define-public chez-web
1002 (let ((commit "5fd177fe53f31f466bf88720d03c95a3711a8bea")
1003 (revision "1"))
1004 (package
1005 (name "chez-web")
1006 ;; Release 2.0 is different and doesn't work.
1007 (version (git-version "2.0" revision commit))
1008 (source
1009 (origin
1010 (method git-fetch)
1011 (uri (git-reference
1012 (url "https://github.com/arcfide/ChezWEB")
1013 (commit commit)))
1014 (file-name (git-file-name name version))
1015 (sha256
1016 (base32 "1dq25qygyncbfq4kwwqqgyyakfqjwhp5q23vrf3bff1p66nyfl3b"))))
1017 (build-system gnu-build-system)
1018 (native-inputs
1019 (list chez-scheme
1020 ghostscript
1021 (texlive-local-tree
1022 (list texlive-charter
1023 texlive-context
1024 texlive-cweb
1025 texlive-metapost))))
1026 (arguments
1027 (list
1028 #:make-flags
1029 #~(list (string-append "PREFIX=" #$output)
1030 (string-append "DOCDIR=" #$output "/share/doc/"
1031 #$name "-" #$version)
1032 ;; lib/chez-scheme/chezweb ???
1033 (string-append "LIBDIR=" #$output "/lib/chezweb")
1034 (string-append "TEXDIR=" #$output "/share/texmf-local"))
1035 #:tests? #f ; no tests
1036 #:phases
1037 #~(modify-phases %standard-phases
1038 (add-after 'unpack 'fix-tex-input
1039 (lambda _
1040 ;; Fix "I can't find file `supp-pdf'." error.
1041 (substitute* "chezweb.w"
1042 (("supp-pdf") "supp-pdf.mkii"))
1043 ;; Recent cweb packages do not include "\acrofalse". Remove
1044 ;; it.
1045 (substitute* "doc/cwebman.tex"
1046 (("\\acrofalse.*") ""))))
1047 ;; This package has a custom "bootstrap" script that
1048 ;; is meant to be run from the Makefile.
1049 (delete 'bootstrap)
1050 (replace 'configure
1051 (lambda* _
1052 (copy-file "config.mk.template" "config.mk")
1053 (substitute* "tangleit"
1054 (("\\./cheztangle\\.ss" all)
1055 (string-append "scheme --program " all)))
1056 (substitute* "weaveit"
1057 (("mpost chezweb\\.mp")
1058 "mpost --tex=tex chezweb.mp")
1059 (("\\./chezweave" all)
1060 (string-append "scheme --program " all)))
1061 (substitute* "installit"
1062 (("-g \\$GROUP -o \\$OWNER") "")))))))
1063 (home-page "https://github.com/arcfide/ChezWEB")
1064 (synopsis "Hygienic Literate Programming for Chez Scheme")
1065 (description "ChezWEB is a system for doing Knuthian style WEB
1066programming in Scheme.")
1067 (license license:expat))))
1068
1069(define-public chez-sockets
1070 (let ((commit "bce96881c06bd69a6757a6bff139744153924140")
1071 (revision "1"))
1072 (package
1073 (name "chez-sockets")
1074 (version (git-version "0.0.0" revision commit))
1075 (source
1076 (origin
1077 (method git-fetch)
1078 (uri (git-reference
1079 (url "https://github.com/arcfide/chez-sockets")
1080 (commit commit)))
1081 (file-name (git-file-name name version))
1082 (sha256
1083 (base32 "1n5fbwwz51fdzvjackgmnsgh363g9inyxv7kmzi0469cwavwcx5m"))))
1084 (build-system gnu-build-system)
1085 (native-inputs
1086 (list chez-scheme
1087 chez-web
1088 (texlive-local-tree)))
1089 (arguments
1090 (list
1091 #:tests? #f ; no tests
1092 #:phases
1093 #~(modify-phases %standard-phases
1094 (replace 'configure
1095 (lambda* (#:key native-inputs inputs #:allow-other-keys)
1096 (let* ((scheme (search-input-file (or native-inputs inputs)
1097 "/bin/scheme"))
1098 (lib (string-append (dirname scheme) "/../lib"))
1099 (header-file (car (find-files lib "scheme\\.h")))
1100 (include-dir (dirname header-file)))
1101 (substitute* "Makefile"
1102 (("(SCHEMEH=).*$" _ var)
1103 (string-append var include-dir))))))
1104 (add-before 'build 'tangle
1105 (lambda* (#:key inputs #:allow-other-keys)
1106 (setenv "TEXINPUTS"
1107 (string-append
1108 (getcwd) ":"
1109 (assoc-ref inputs "chez-web")
1110 "/share/texmf-local/tex/generic:"
1111 ":"))
1112 ;; just using "make" tries to build the .c files before
1113 ;; they are created.
1114 (and (invoke "make" "sockets")
1115 (invoke "make"))))
1116 (replace 'build
1117 (lambda args
1118 (let ((chez-site (string-append #$output
1119 "/lib/chez-scheme/arcfide")))
1120 ;; make sure Chez Scheme can find the shared libraries.
1121 (substitute* "sockets.ss"
1122 (("(object \")(socket-ffi-values\\.[sd][oy][^\"]*)(\")"
1123 _ pre file post)
1124 (string-append pre chez-site "/" file post))
1125 (("(\")(sockets-stub\\.[sd][oy][^\"]*)(\")"
1126 _ pre file post)
1127 (string-append pre chez-site "/" file post)))
1128 ;; to compile chez-sockets, the .so files must be
1129 ;; installed (because of the absolute path we
1130 ;; inserted above).
1131 (for-each (lambda (f)
1132 (install-file f chez-site))
1133 '("socket-ffi-values.so"
1134 "sockets-stub.so"))
1135 (invoke "bash"
1136 "-c"
1137 (format #f "echo '~s' | scheme -q"
1138 '(compile-file "sockets.sls"))))))
1139 (replace 'install
1140 (lambda args
1141 (install-file "sockets.so"
1142 (string-append #$output
1143 "/lib/chez-scheme/arcfide"))
1144 (install-file "sockets.pdf"
1145 (string-append #$output
1146 "/share/doc/"
1147 #$name "-" #$version)))))))
1148 (home-page "https://github.com/arcfide/chez-sockets")
1149 (synopsis "Extensible sockets library for Chez Scheme")
1150 (description "Chez-sockets is an extensible sockets library for
1151Chez Scheme.")
1152 (license license:expat))))
1153
1154(define-public chez-matchable
1155 (package
1156 (name "chez-matchable")
1157 (version "20160306")
1158 (home-page "https://github.com/fedeinthemix/chez-matchable")
1159 (source
1160 (origin
1161 (method git-fetch)
1162 (uri (git-reference
1163 (url home-page)
1164 (commit (string-append "v" version))))
1165 (sha256
1166 (base32 "02qn7x348p23z1x5lwhkyj7i8z6mgwpzpnwr8dyina0yzsdkr71s"))
1167 (file-name (git-file-name name version))))
1168 (build-system gnu-build-system)
1169 (inputs
1170 (list chez-srfi)) ; for tests
1171 (native-inputs
1172 (list chez-scheme))
1173 (arguments
1174 (list #:make-flags (chez-make-flags name version)
1175 #:test-target "test"
1176 #:phases #~(modify-phases %standard-phases
1177 (replace 'configure
1178 #$configure-chezschemelibdirs))))
1179 (synopsis "Portable hygienic pattern matcher for Scheme")
1180 (description "This package provides a superset of the popular Scheme
1181@code{match} package by Andrew Wright, written in fully portable
1182@code{syntax-rules} and thus preserving hygiene.")
1183 (license license:public-domain)))
1184
1185(define-public chez-irregex
1186 (package
1187 (name "chez-irregex")
1188 (version "0.9.12")
1189 (source (origin
1190 (method url-fetch)
1191 (uri (string-append
1192 "http://synthcode.com/scheme/irregex/irregex-"
1193 version ".tar.gz"))
1194 (sha256
1195 (base32
1196 "1rmlmkf2pnly7mqi407vi2k6k19m2h44d4jvzfkrizk892qj61yc"))))
1197 (build-system gnu-build-system)
1198 (propagated-inputs
1199 (list chez-srfi)) ; for irregex-utils
1200 (native-inputs
1201 (list chez-scheme))
1202 (arguments
1203 (list #:make-flags (chez-make-flags name version)
1204 #:tests? #f ; no test available for Chez Scheme
1205 #:phases #~(modify-phases %standard-phases
1206 (replace 'configure
1207 #$configure-chezschemelibdirs)
1208 (replace 'build
1209 (lambda* (#:key make-flags #:allow-other-keys)
1210 (apply invoke `("make" "chez-build"
1211 ,@make-flags))))
1212 (replace 'install
1213 (lambda* (#:key make-flags #:allow-other-keys)
1214 (apply invoke `("make" "chez-install"
1215 ,@make-flags))
1216 (apply invoke `("make" "chez-install-src"
1217 ,@make-flags)))))))
1218 (home-page "https://synthcode.com/scheme/irregex")
1219 (synopsis "Portable regular expression library for Scheme")
1220 (description "This package provides a portable and efficient
1221R[4567]RS implementation of regular expressions, supporting both POSIX
1222syntax with various (irregular) PCRE extensions, as well as SCSH's SRE
1223syntax, with various aliases for commonly used patterns.")
1224 (license license:bsd-3)))
1225
1226(define-public chez-fmt
1227 (package
1228 (name "chez-fmt")
1229 (version "0.8.11")
1230 (source
1231 (origin
1232 (method url-fetch)
1233 (uri (string-append
1234 "http://synthcode.com/scheme/fmt/fmt-" version ".tar.gz"))
1235 (sha256
1236 (base32 "1zxqlw1jyg85yzclylh8bp2b3fwcy3l3xal68jw837n5illvsjcl"))
1237 (file-name (string-append name "-" version ".tar.gz"))))
1238 (build-system gnu-build-system)
1239 (propagated-inputs
1240 (list chez-srfi)) ; for irregex-utils
1241 (native-inputs
1242 (list chez-scheme))
1243 (arguments
1244 (list #:make-flags (chez-make-flags name version)
1245 #:test-target "chez-check"
1246 #:phases
1247 #~(modify-phases %standard-phases
1248 (replace 'configure
1249 #$configure-chezschemelibdirs)
1250 (replace 'build
1251 (lambda* (#:key (make-flags '()) #:allow-other-keys)
1252 (apply invoke "make" "chez-build" make-flags)))
1253 (replace 'install
1254 (lambda* (#:key (make-flags '()) #:allow-other-keys)
1255 (apply invoke "make" "chez-install" make-flags))))))
1256 (home-page "https://synthcode.com/scheme/fmt")
1257 (synopsis "Combinator formatting library for Chez Scheme")
1258 (description "This package provides a library of procedures for
1259formatting Scheme objects to text in various ways, and for easily
1260concatenating, composing and extending these formatters efficiently
1261without resorting to capturing and manipulating intermediate
1262strings.")
1263 (license license:bsd-3)))
1264
1265(define-public chez-mit
1266 (package
1267 (name "chez-mit")
1268 (version "0.1")
1269 (home-page "https://github.com/fedeinthemix/chez-mit")
1270 (source
1271 (origin
1272 (method git-fetch)
1273 (uri (git-reference
1274 (url home-page)
1275 (commit (string-append "v" version))))
1276 (sha256
1277 (base32 "0c7i3b6i90xk96nmxn1pc9272a4yal4v40dm1a4ybdi87x53zkk0"))
1278 (file-name (git-file-name name version))
1279 (snippet
1280 ;; Workaround for chez-scheme-for-racket.
1281 ;; See: https://github.com/racket/racket/issues/4151
1282 #~(begin
1283 (use-modules (guix build utils))
1284 (substitute* "mit/core.sls"
1285 (("[(]import ")
1286 "(import (only (chezscheme) import)\n")
1287 (("[(]define string->uninterned-symbol gensym[)]")
1288 (format #f "~s"
1289 '(begin
1290 (import (only (chezscheme)
1291 meta-cond
1292 library-exports))
1293 (meta-cond
1294 ((memq 'string->uninterned-symbol
1295 (library-exports '(chezscheme)))
1296 (import (only (chezscheme)
1297 string->uninterned-symbol)))
1298 (else
1299 (define string->uninterned-symbol
1300 gensym)))))))))))
1301 (build-system gnu-build-system)
1302 (inputs
1303 (list chez-srfi)) ; for tests
1304 (native-inputs
1305 (list chez-scheme))
1306 (arguments
1307 (list #:make-flags (chez-make-flags name version)
1308 #:test-target "test"
1309 #:phases #~(modify-phases %standard-phases
1310 (replace 'configure
1311 #$configure-chezschemelibdirs))))
1312 (synopsis "MIT/GNU Scheme compatibility library for Chez Scheme")
1313 (description "This package provides a set of MIT/GNU Scheme compatibility
1314libraries for Chez Scheme. The main goal was to provide the functionality
1315required to port the program @code{Scmutils} to Chez Scheme.")
1316 (license license:gpl3+)))
1317
1318(define-public chez-scmutils
1319 (package
1320 (name "chez-scmutils")
1321 (version "0.1")
1322 (home-page "https://github.com/fedeinthemix/chez-scmutils")
1323 (source
1324 (origin
1325 (method git-fetch)
1326 (uri (git-reference
1327 (url home-page)
1328 (commit (string-append "v" version))))
1329 (sha256
1330 (base32 "0lb05wlf8qpgg8y0gdsyaxg1nbfx1qbaqdjvygrp64ndn8fnhq7l"))
1331 (file-name (git-file-name name version))))
1332 (build-system gnu-build-system)
1333 (inputs
1334 (list chez-srfi)) ; for tests
1335 (native-inputs
1336 (list chez-scheme))
1337 (propagated-inputs
1338 (list chez-mit chez-srfi))
1339 (arguments
1340 (list
1341 #:make-flags (chez-make-flags name version)
1342 #:tests? #f ; no test suite
1343 #:phases
1344 #~(modify-phases %standard-phases
1345 (replace 'configure
1346 #$configure-chezschemelibdirs)
1347 ;; Since the documentation is lacking, we install the source
1348 ;; code. For things to work correctly we have to replace
1349 ;; relative paths by absolute ones in 'include' forms. This
1350 ;; in turn requires us to compile the files in the final
1351 ;; destination.
1352 (delete 'build)
1353 (add-after 'install 'install-src
1354 (lambda* (#:key (make-flags '()) #:allow-other-keys)
1355 (apply invoke "make" "install-src" make-flags)))
1356 (add-after 'install-src 'absolute-path-in-scm-files
1357 (lambda* (#:key #:allow-other-keys)
1358 (for-each (lambda (file)
1359 (substitute* file
1360 (("include +\"\\./scmutils")
1361 (string-append "include \"" (dirname file)))))
1362 (find-files #$output "\\.sls"))
1363 (for-each (lambda (file)
1364 (substitute* file
1365 (("include +\"\\./scmutils/simplify")
1366 (string-append "include \"" (dirname file)))))
1367 (find-files #$output "fbe-syntax\\.scm"))))
1368 (add-after 'absolute-path-in-scm-files 'build
1369 (lambda* (#:key (make-flags '()) #:allow-other-keys)
1370 (let ((mk-file (car (find-files #$output "Makefile"))))
1371 (with-directory-excursion (dirname mk-file)
1372 (apply invoke "make" "build" make-flags)))))
1373 (add-after 'build 'clean-up
1374 (lambda args
1375 (for-each delete-file
1376 (find-files #$output
1377 "Makefile|compile-all\\.ss")))))))
1378 (synopsis "Port of MIT/GNU Scheme Scmutils to Chez Scheme")
1379 (description "This package provides a port of the MIT/GNU Scheme
1380Scmutils program to Chez Scheme. The port consists of a set of
1381libraries providing most of the functionality of the original.")
1382 (license license:gpl3+)))
1383
1384(define-public schemesh
1385 (package
1386 (name "schemesh")
1387 (version "1.0.2")
1388 (source
1389 (origin
1390 (method git-fetch)
1391 (uri (git-reference
1392 (url "https://github.com/cosmos72/schemesh")
1393 (commit (string-append "v" version))))
1394 (file-name (git-file-name name version))
1395 (sha256
1396 (base32 "0ad174wxisv26766vv925pv7hnrbm3ad8jjwi1q83aggzzdn7q8i"))))
1397 (build-system gnu-build-system)
1398 (arguments
1399 (list
1400 ;; INFO: Tests are executed unconditionally, and are not fatal.
1401 ;; TODO: Report upstream.
1402 #:tests? #f
1403 #:make-flags
1404 #~(list
1405 (string-append "prefix=" #$output)
1406 (string-append "CC=" #$(cc-for-target)))
1407 #:phases
1408 #~(modify-phases %standard-phases
1409 (delete 'configure))))
1410 (inputs
1411 (list chez-scheme
1412 lz4
1413 ;; INFO: Makefile supposes terminfo is provided by libtinfo. Ours
1414 ;; is provided by ncurses/tinfo.
1415 ncurses/tinfo
1416 `(,util-linux "lib")
1417 zlib))
1418 (home-page "https://github.com/cosmos72/schemesh")
1419 (synopsis "Unix shell and Lisp REPL, fused together")
1420 (description
1421 "Schemesh is an interactive shell scriptable in Lisp. It supports
1422interactive line editing, autocompletion, history and the familiar Unix shell
1423syntax.")
1424 (license license:gpl2)))