projects/guix·blob python-team · refs

1164 lines · 51.1 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013-2016, 2018, 2020-2022 Ludovic Courtès <[email protected]>
3;;; Copyright © 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice <[email protected]>
4;;; Copyright © 2020 Pierre Neidhardt <[email protected]>
5;;; Copyright © 2021-2025 Philip McGrath <[email protected]>
6;;; Copyright © 2021 jgart <[email protected]>
7;;; Copyright © 2025 Janneke Nieuwenhuizen <[email protected]>
8;;;
9;;; This file is part of GNU Guix.
10;;;
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.
15;;;
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.
20;;;
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/>.
23
24(define-module (gnu packages racket)
25 #:use-module (guix packages)
26 #:use-module (guix download)
27 #:use-module (guix git-download)
28 #:use-module (guix utils)
29 #:use-module (guix gexp)
30 #:use-module (guix build-system gnu)
31 #:use-module (guix diagnostics)
32 #:use-module (guix i18n)
33 #:use-module ((guix search-paths) #:select ($SSL_CERT_DIR $SSL_CERT_FILE))
34 #:use-module (srfi srfi-1)
35 #:use-module (srfi srfi-26)
36 #:use-module (srfi srfi-34)
37 #:use-module (ice-9 match)
38 #:use-module (gnu packages)
39 #:use-module (gnu packages autotools)
40 #:use-module (gnu packages chez)
41 #:use-module (gnu packages compression)
42 #:use-module (gnu packages databases)
43 #:use-module (gnu packages fontutils)
44 #:use-module (gnu packages gl)
45 #:use-module (gnu packages glib)
46 #:use-module (gnu packages gtk)
47 #:use-module (gnu packages image)
48 #:use-module (gnu packages libedit)
49 #:use-module (gnu packages libffi)
50 #:use-module (gnu packages multiprecision)
51 #:use-module (gnu packages ncurses)
52 #:use-module (gnu packages sqlite)
53 #:use-module (gnu packages tls)
54 #:use-module (gnu packages xorg)
55 #:use-module ((guix licenses) #:prefix license:))
56
57;; COMMENTARY:
58;;
59;; Anatomy of Racket:
60;; ------------------
61;;
62;; The main Racket Git repository (<https://github.com/racket/racket>) is
63;; organized broadly like this:
64;;
65;; .
66;; ├── Makefile
67;; ├── pkgs/
68;; └── racket/
69;; ├── collects/
70;; └── src/
71;; ├── configure
72;; ├── Makefile.in
73;; ├── bc/
74;; ├── cs/
75;; ├── ChezScheme/
76;; ├── rktboot/
77;; ├── zuo/
78;; └── ...
79;;
80;; The 'racket/src/' directory contains the source of the runtime system, core
81;; compiler, and primitives for the major Racket implementations: this layer
82;; is called the ``Racket VM''. It is basically a normal Autoconf project,
83;; except that the makefiles just run Zuo to do the real work. (Even when
84;; Racket VM implementations use components implemented in Racket, they are
85;; compiled in special modes to produce VM primitives.) (There are or have
86;; been experimental Racket VM implementations elsewhere,
87;; e.g. <https://github.com/pycket/pycket>.)
88;;
89;; The 'racket/collects/' directory contains ``built in'' Racket libraries
90;; that are not part of any package, including the implementation of
91;; 'racket/base': in particular, it must contain enough to implement `raco pkg
92;; install'. It is theoretically possible to use the Racket VM layer without
93;; the main collections, but it is not stable or useful.
94;;
95;; The 'pkgs/' directory contains Racket packages that are especially closely
96;; tied to the implementation of the Racket VM, including 'compiler-lib',
97;; 'racket-doc', and 'racket-test'. Some of these packages depend on Racket
98;; packages that are developed in other Git repositories, predominantly but
99;; not exclusively under the 'racket' GitHub organization. Conversely, not all
100;; of the packages developed in the main Git repository are part of the main
101;; Racket distribution. (Additionally, components of the Racket VM that are
102;; implemented in Racket can be installed as packages, mostly for ease of
103;; development.)
104;;
105;; The top-level 'Makefile' is more like a directory of scripts: it has
106;; convenience targets for developing Racket, and it cooperates with the
107;; 'distro-build' package to assemble custom Racket distributions. (Again,
108;; the makefile just delegates to Zuo.) It is not part of Racket source
109;; distributions: the root of a source distribution is basically 'racket/src'
110;; with some extra package sources and configuration added. In fact, the
111;; top-level 'Makefile' and the 'distro-build' package are what create Racket
112;; source distributions.
113;;
114;; A ''minimal Racket'' installation includes two packages: 'base', which is a
115;; sort of bridge between the current ``built-in'' collections and the package
116;; system's model of dependencies, and 'racket-lib', which, for installations
117;; that can not rely on a system package manager, pulls in the SQLite and
118;; OpenSSL shared libraries as platform-specific dependencies for use by the
119;; ``built-in'' collections.
120;;
121;; The main Racket distribution consists of installing the 'main-distribution'
122;; package and all of its dependencies.
123;;
124;; The default mode when building Racket (or installing it with the released
125;; installers) is an ``in-place build'', which produces a self-contained,
126;; relocatable, roughly FHS-like directory. (Racket also supports
127;; ``Unix-style'' installations, which rearrange the parts of an in-place
128;; build into Racket-specific subdirectories and generally tries to work for
129;; installation into an FHS-based system.) Certain tools, e.g. 'distro-build'
130;; and 'raco cross', are able to work with an in-place Racket build.
131;;
132;; This file defines the packages 'racket-vm-cgc', 'racket-vm-bc', and
133;; 'racket-vm-cs'. All three are in-place builds of 'racket/src/' and
134;; 'racket/collects/' and are installed to 'opt/racket-vm/' in the store
135;; output.
136;;
137;; Using 'racket-vm-cs', we then define the packages 'racket-minimal' and
138;; 'racket'. These use Racket's support for ``layered installations'', which
139;; allow an immutable base layer to be extended with additional packages.
140;; They use the layer configuration directly provide ready-to-install FHS-like
141;; trees, rather than relying on the built in ``Unix-style install''
142;; mechanism.
143;;
144;; Bootstrapping Racket:
145;; ---------------------
146;;
147;; Here's how bootstrapping Racket works:
148;;
149;; - Racket BC [CGC] can be built with only a C compiler (except for
150;; one caveat discussed below).
151;; - Racket BC [3M] needs an existing Racket to run "xform",
152;; which transforms its own C source code to add additional annotations
153;; for the precise garbage collector.
154;; - Racket CS needs (boot files for) the corresponding version of Chez
155;; Scheme. It also needs an existing Racket to compile Racket-implemented
156;; parts of the runtime system to R6RS libraries.
157;; - Chez Scheme also needs boot files for itself, but Racket BC can
158;; bootstrap these using the code in "racket/src/rktboot/".
159;; See the commentary in "chez.scm" for further details
160;;
161;; So, we build CGC to build 3M to build bootfiles and CS.
162;;
163;; (Note: since the CGC variant is basically only for bootstrapping, we
164;; often use "BC" to mean "3M", consistent with `(banner)` and the
165;; suffixes used on executables when more than one variant co-exists.)
166;;
167;; Since the pre-releases for Chez Scheme 10.0.0, all of Racket's changes have
168;; been merged upstream, and development will be kept in sync going
169;; forward. However, there is no plan to align the Chez Scheme and Racket
170;; release cycles. For the near fulture, a given released version of Racket
171;; will continue to depend on a specific pre-release version of Chez Scheme as
172;; part of Racket CS's "ABI". See upstream discussion at
173;; <https://racket.discourse.group/t/2739/3>.
174;;
175;; One remaining bootstrapping limitation is that Racket's reader, module
176;; system, and macro expander are implemented in Racket. For Racket CS,
177;; they are compiled to R6RS libraries as discussed above. This note from the
178;; README file applies to all such subsystems:
179;;
180;; The Racket version must be practically the same as the current Racket
181;; version, although it can be the Racket BC implementation (instead of
182;; the Racket CS implementation).
183;;
184;; Unlike Chez Scheme boot files, the files generated in "schemified"
185;; are human-readable and -editable Scheme code. That provides a way
186;; out of bootstrapping black holes, even without BC.
187;;
188;; However, other Racket subsystems implemented in Racket for Racket CS
189;; use older C implementations for Racket BC, whereas the reader, expander,
190;; and module system were completely replaced with the Racket implementation
191;; as of Racket 7.0. See also <https://racket.discourse.group/t/951/4>.
192;;
193;; For Racket BC, the compiled "linklet" s-expressions (primitive modules)
194;; are embedded in C as a static string constant. Eventually, they are further
195;; compiled by the C-implemented Racket BC bytecode and JIT compilers.
196;;
197;; Zuo is notably *not* a problem for bootstrapping. The implementation is a
198;; single hand-written C file designed to build with just `cc -o zuo zuo.c`,
199;; even with very old or limited compilers. (We use the Autoconf support for
200;; convenience.) As of Zuo 1.8, Zuo has tagged releases in its own repository
201;; independent of the Racket release cycle.
202;;
203;; CODE:
204
205(define %racket-version "9.3") ; Remember to update chez-scheme-for-racket!
206(define %racket-commit
207 (string-append "v" %racket-version))
208(define %racket-origin
209 (origin
210 (method git-fetch)
211 (uri (git-reference
212 (url "https://github.com/racket/racket")
213 (commit %racket-commit)))
214 (sha256
215 (base32 "1q2pj20rsd739acb02dc825dw35wlrfn722c1nc5lyp91fmjcnrk"))
216 (file-name (git-file-name "racket" %racket-version))
217 (patches (search-patches "racket-chez-scheme-bin-sh.patch"
218 "racket-launcher-config-dir.patch"
219 "racket-rktio-bin-sh.patch"))
220 (modules '((guix build utils)))
221 (snippet
222 #~(begin
223 (use-modules (guix build utils))
224 ;; Unbundle Chez submodules and boot files.
225 (with-directory-excursion "racket/src/ChezScheme"
226 ;; TODO: consider putting this in a (guix ...) or (guix build ...)
227 ;; module so it can be shared with the upstream Chez Scheme origin
228 ;; without cyclic issues.
229 (for-each (lambda (dir)
230 (when (directory-exists? dir)
231 (delete-file-recursively dir)))
232 '("boot"
233 "lz4"
234 "nanopass"
235 "stex"
236 "zlib"
237 "zuo")))
238 ;; Unbundle Zuo.
239 (delete-file-recursively "racket/src/zuo")
240 ;; Unbundle libffi.
241 (delete-file-recursively "racket/src/bc/foreign/libffi")))))
242
243
244(define-public zuo
245 (package
246 (name "zuo")
247 (version "1.12") ; defined in racket/src/zuo/zuo.c or the following
248 #;(displayln (~a (hash-ref (runtime-env) 'version) "."
249 (hash-ref (runtime-env) 'minor-version)))
250 (source (origin
251 (method git-fetch)
252 (uri (git-reference
253 (url "https://github.com/racket/zuo")
254 (commit (string-append "v" version))))
255 (sha256
256 (base32 "053zn230v4bgfrf7clrqcp5d614fh4sv00hr5qw3vdvnl006shh5"))
257 (file-name (git-file-name name version))
258 (patches (search-patches "zuo-bin-sh.patch"))))
259 (outputs '("out" "debug"))
260 (build-system gnu-build-system)
261 (arguments
262 (list
263 #:out-of-source? #t))
264 (home-page "https://github.com/racket/zuo")
265 (synopsis "Tiny Racket for build scripts")
266 (description "Zuo is a tiny Racket with primitives for dealing
267with files and running processes. It comes with a @command{make}-like
268embedded DSL, which is used to build Racket itself.
269
270Zuo is a Racket variant in the sense that program files start with
271@code{#lang}, and the module path after @code{#lang} determines the parsing
272and expansion of the file content. That's how the @command{make}-like DSL is
273defined, and even the base Zuo language is defined by layers of @code{#lang}s.
274One of the early layers implements macros.")
275 (license (list license:asl2.0 license:expat))))
276
277
278(define racket-vm-common-configure-flags
279 #~`(,@(cond
280 ((false-if-exception
281 (search-input-file %build-inputs "/bin/libtool"))
282 => (lambda (libtool)
283 (list (string-append "--enable-lt=" libtool))))
284 (else
285 '()))
286 ,@(cond
287 ((false-if-exception
288 (search-input-file %build-inputs "/opt/racket-vm/bin/racket"))
289 => (lambda (racket)
290 (list (string-append "--enable-racket=" racket))))
291 (else
292 '()))
293 "CFLAGS=-g -O2 -Wno-error=implicit-function-declaration"
294 "--disable-strip"
295 ;; Using --enable-origtree lets us distinguish the VM from subsequent
296 ;; layers and produces a build with the shape expected by tools such as
297 ;; "distro-build" and "raco-cross". Removing these flags would require
298 ;; changes, especially to 'configure-layer.rkt' (defined below).
299 "--enable-origtree"
300 ,(string-append "--prefix=" #$output "/opt/racket-vm")))
301
302(define-public racket-vm-cgc
303 ;; Eventually, it may make sense for some vm packages to not be hidden,
304 ;; but this one is especially likely to remain hidden.
305 (hidden-package
306 (package
307 (name "racket-vm-cgc")
308 (version %racket-version)
309 (source %racket-origin)
310 (inputs (list ncurses ;; <- common to all variants (for #%terminal)
311 libffi)) ;; <- for BC and non-native CS variants
312 (native-inputs (cons* zuo ;; <- for all variants
313 libtool ;; <- only for BC variants
314 (if (%current-target-system)
315 (list this-package)
316 '())))
317 (outputs '("out" "debug"))
318 (build-system gnu-build-system)
319 (arguments
320 (list
321 #:configure-flags
322 #~(cons "--enable-cgcdefault"
323 #$racket-vm-common-configure-flags)
324 #:make-flags
325 #~(list (string-append "ZUO="
326 #+(this-package-native-input "zuo")
327 "/bin/zuo"))
328 ;; Tests are in packages like racket-test-core and
329 ;; main-distribution-test that aren't part of the main
330 ;; distribution.
331 #:tests? #f
332 ;; Upstream recommends #:out-of-source?, and it
333 ;; helps a lot with debugging.
334 #:out-of-source? #t
335 #:modules '((ice-9 match)
336 (ice-9 regex)
337 (guix build gnu-build-system)
338 (guix build utils))
339 #:strip-directories #~'("opt/racket-vm/bin"
340 "opt/racket-vm/lib")
341 #:phases
342 #~(modify-phases %standard-phases
343 (add-before 'configure 'initialize-config.rktd
344 (lambda* (#:key inputs #:allow-other-keys)
345 (define (write-racket-hash alist)
346 ;; inside must use dotted pair notation
347 (display "#hash(")
348 (for-each (match-lambda
349 ((k . v)
350 (format #t "(~s . ~s)" k v)))
351 alist)
352 (display ")\n"))
353 (define maybe-release-catalog
354 (let ((v #$(package-version this-package)))
355 (if (string-match "^[0-9]+\\.[0-9]+($|\\.[0-8][0-9]*$)"
356 v)
357 `(,(string-append
358 "https://download.racket-lang.org/releases/"
359 v
360 "/catalog/"))
361 '())))
362 (mkdir-p "racket/etc")
363 (with-output-to-file "racket/etc/config.rktd"
364 (lambda ()
365 (write-racket-hash
366 `((build-stamp . "")
367 (catalogs ,@maybe-release-catalog
368 #f)))))))
369 (add-before 'configure 'chdir
370 (lambda _
371 (chdir "racket/src")))
372 (replace 'install-license-files
373 ;; The #:out-of-source? mode for install-license-files fails
374 ;; to find the srcdir: as a workaround, navigate there ourselves.
375 (let ((install-license-files
376 (assoc-ref %standard-phases 'install-license-files)))
377 (lambda args
378 (with-directory-excursion "../src"
379 (apply install-license-files
380 `(,@args
381 ;; if there are duplicate keywords, last is used
382 #:out-of-source? #f)))))))))
383 (home-page "https://racket-lang.org")
384 (synopsis "Old Racket implementation used for bootstrapping")
385 (description "This variant of the Racket BC (``before Chez'' or
386``bytecode'') implementation is not recommended for general use. It uses
387CGC (a ``Conservative Garbage Collector''), which was succeeded as default in
388PLT Scheme version 370 (which translates to 3.7 in the current versioning
389scheme) by the 3M variant, which in turn was succeeded in version 8.0 by the
390Racket CS implementation.
391
392Racket CGC is primarily used for bootstrapping Racket BC [3M]. It may
393also be used for embedding applications without the annotations needed in C
394code to use the 3M garbage collector.")
395 ;; https://download.racket-lang.org/license.html
396 ;; The LGPL components are only used by Racket BC.
397 (license (list license:lgpl3+ license:asl2.0 license:expat)))))
398
399(define-public racket-vm-bc
400 (package
401 (inherit racket-vm-cgc)
402 (name "racket-vm-bc")
403 (native-inputs
404 (if (%current-target-system)
405 (package-native-inputs racket-vm-cgc)
406 (modify-inputs native-inputs
407 (prepend racket-vm-cgc))))
408 (arguments
409 (substitute-keyword-arguments arguments
410 ((#:configure-flags _ '())
411 #~(cons "--enable-bconly"
412 #$(cond
413 ((target-ppc64le?)
414 ;; Attempt to avoid a problem bootstrapping Chez Scheme:
415 ;; see <https://issues.guix.gnu.org/57050#19>
416 ;; and <https://racket.discourse.group/t/950/30>.
417 #~(map
418 (lambda (flag)
419 (if (string-prefix? "CPPFLAGS=" flag)
420 (string-append flag
421 " -DSTACK_SAFETY_MARGIN=2000000")
422 flag))
423 #$racket-vm-common-configure-flags))
424 (else
425 racket-vm-common-configure-flags))))))
426 (synopsis "Racket BC [3M] implementation")
427 (description "The Racket BC (``before Chez'' or ``bytecode'')
428implementation was the default before Racket 8.0. It uses a compiler written
429in C targeting architecture-independent bytecode, plus a JIT compiler on most
430platforms. Racket BC has a different C API than the current default runtime
431system, Racket CS (based on ``Chez Scheme'').
432
433This package is the normal implementation of Racket BC with a precise garbage
434collector, 3M (``Moving Memory Manager'').")
435 ;; https://download.racket-lang.org/license.html
436 ;; The LGPL components are only used by Racket BC.
437 (license (list license:lgpl3+ license:asl2.0 license:expat))))
438
439(define-public racket-vm-cs
440 (package
441 (inherit racket-vm-bc)
442 (name "racket-vm-cs")
443 (inputs
444 (let ((inputs (modify-inputs inputs
445 (prepend zlib lz4))))
446 (if (nix-system->native-chez-machine-type)
447 (modify-inputs inputs
448 (delete "libffi"))
449 inputs)))
450 (native-inputs
451 (let ((native-inputs (package-native-inputs racket-vm-cgc)))
452 (modify-inputs (if (%current-target-system)
453 (modify-inputs native-inputs
454 (prepend this-package)
455 (delete "racket-vm-cgc"))
456 native-inputs)
457 (delete "libtool")
458 (prepend chez-scheme-for-racket
459 chez-nanopass-bootstrap))))
460 (arguments
461 (substitute-keyword-arguments arguments
462 ((#:phases those-phases #~%standard-phases)
463 #~(modify-phases #$those-phases
464 (add-after 'unpack 'unpack-nanopass
465 #$unpack-nanopass)))
466 ((#:configure-flags _ '())
467 #~(cons* "--enable-csonly"
468 "--enable-libz"
469 "--enable-lz4"
470 (string-append "--enable-scheme="
471 #+(this-package-native-input
472 "chez-scheme-for-racket")
473 "/bin/scheme")
474 #$@(if (nix-system->native-chez-machine-type)
475 #~()
476 #~(#$(string-append "--enable-mach="
477 (nix-system->pbarch-machine-type))
478 "--enable-pb"))
479 #$racket-vm-common-configure-flags))))
480 (synopsis "Racket CS implementation")
481 (description "The Racket CS implementation, which uses ``Chez Scheme'' as
482its core compiler and runtime system, has been the default Racket VM
483implementation since Racket 8.0. It performs better than the Racket BC
484implementation for most programs. On systems for which Racket CS cannot
485generate machine code, this package uses a variant of its ``portable
486bytecode'' backend specialized for word size and endianness.
487
488Using the Racket VM packages directly is not recommended: instead, install the
489@code{racket-minimal} or @code{racket} packages.")
490 ;; https://download.racket-lang.org/license.html
491 ;; The LGPL components are only used by Racket BC.
492 (license (list license:asl2.0 license:expat))))
493
494(define (racket-packages-origin name origin specs)
495 "Extract from ORIGIN the sources for the Racket packages specified by SPECS,
496a non-empty list of package specifications. In the resulting file-like
497object, each package's source will be in the directory
498\"/share/racket/pkgs/PKG/\", where PKG is the Racket name for the package.
499The NAME will be used in the store file name for the resulting file-like
500object.
501
502A package specification is a list of the form:
503
504 (PKG PATH)
505
506where PATH is the path to the package source relative to ORIGIN---possibly
507\".\". As a special case, a package specification may also be a string, which
508is equivalent to:
509
510 (PKG PKG)
511
512Examples:
513
514- \"expeditor\"
515- (\"main-distribution\" \".\")
516- (\"racket-lib\" \"pkgs/racket-lib\")"
517 (computed-file
518 (string-append "racket-pkg-" name "-sources")
519 (with-imported-modules `((guix build utils))
520 #~(begin
521 (use-modules (guix build utils))
522 (mkdir-p (string-append #$output "/share/racket/pkgs"))
523 (chdir (string-append #$output "/share/racket/pkgs"))
524 #$@(map (match-lambda
525 ((? string? name)
526 #~(copy-recursively #$(file-append origin (string-append "/" name))
527 #$name))
528 ((name ".")
529 #~(copy-recursively #$origin #$name))
530 ((name path)
531 #~(copy-recursively #$(file-append origin (string-append "/" path))
532 #$name)))
533 specs)))))
534
535(define (simple-racket-origin repo hash specs)
536 "Like 'racket-packages-origin', but specialized for packages hosted at
537\"https://github.com/racket/REPO\" with sha256 checksum HASH. REPO is also
538used to build the name of the resulting store item."
539 (racket-packages-origin
540 repo
541 (origin
542 (method git-fetch)
543 (uri (git-reference
544 (url (format #f "https://github.com/racket/~a" repo))
545 (commit %racket-commit)))
546 (sha256 hash)
547 (file-name (git-file-name (string-append "racket-" repo)
548 %racket-version)))
549 specs))
550
551(define-public racket-minimal
552 (package
553 (name "racket-minimal")
554 (version %racket-version)
555 (source #f)
556 ;; For cross-compilation, Matthew Flatt recommends reusing
557 ;; as much of `raco cross` as possible. So, put that off until
558 ;; we have a build system for Racket packages.
559 (inputs
560 (list openssl
561 sqlite
562 racket-vm-cs
563 (racket-packages-origin
564 "base" %racket-origin
565 '(("base" "pkgs/base")
566 ("racket-lib" "pkgs/racket-lib")))))
567 (native-search-paths (list $SSL_CERT_DIR $SSL_CERT_FILE))
568 (build-system gnu-build-system)
569 (arguments
570 ;; Here and for the `racket` package, we're using #:configure-flags
571 ;; to pass flags for `configure-layer.rkt` and #:make-flags
572 ;; to pass arguments for `raco pkg install`.
573 (list
574 #:configure-flags
575 #~`("--tethered"
576 "--extra-foreign-lib-search-dirs"
577 ,(format
578 #f "~s"
579 (list #$(file-append (this-package-input "openssl") "/lib")
580 #$(file-append (this-package-input "sqlite") "/lib"))))
581 #:make-flags #~`("racket-lib")
582 #:tests? #f ;; packaged separately
583 #:modules '((guix build gnu-build-system)
584 (guix build utils)
585 (guix build union)
586 (ice-9 match))
587 #:imported-modules `((guix build union)
588 ,@%default-gnu-imported-modules)
589 #:phases
590 #~(modify-phases %standard-phases
591 (delete 'unpack)
592 (replace 'configure
593 (lambda* (#:key inputs configure-flags #:allow-other-keys)
594 (let* ((vm-dir (search-input-directory inputs "opt/racket-vm"))
595 (racket (string-append vm-dir "/bin/racket")))
596 (apply invoke
597 racket
598 #$configure-layer.rkt
599 `(,@(cond
600 ((false-if-exception
601 (search-input-file
602 inputs "etc/racket/config.rktd"))
603 => (lambda (file)
604 `("--parent"
605 ,(dirname (dirname (dirname file))))))
606 (else
607 '()))
608 ,@configure-flags
609 ,vm-dir
610 ,#$output))
611 (invoke racket
612 "--config" (string-append #$output "/etc/racket")
613 "-l" "raco" "setup"
614 "--no-user"))))
615 (replace 'build
616 (lambda* (#:key inputs #:allow-other-keys)
617 ;; We use "share/racket/pkgs" for sources to distinguish them
618 ;; from the "lib/racket/pkgs" of a potential parent layer.
619 (union-build (string-append #$output "/lib/racket/pkgs")
620 (search-path-as-list '("share/racket/pkgs")
621 (map cdr inputs))
622 #:create-all-directories? #t)))
623 (replace 'install
624 (lambda* (#:key inputs make-flags #:allow-other-keys)
625 (let ((racket
626 (search-input-file inputs "/opt/racket-vm/bin/racket")))
627 (unless (null? make-flags)
628 (invoke racket
629 "-l-"
630 "pkg/dirs-catalog"
631 "--link"
632 "local-catalog"
633 (string-append #$output "/lib/racket/pkgs"))
634 (apply invoke
635 racket
636 "--config" (string-append #$output "/etc/racket")
637 "-l" "raco"
638 "pkg" "install"
639 "--installation"
640 "--auto"
641 "--catalog" "local-catalog"
642 make-flags))))))))
643 (home-page "https://racket-lang.org")
644 (synopsis "Racket without bundled packages such as DrRacket")
645 (description
646 "Racket is a general-purpose programming language in the Scheme family,
647with a large set of libraries and a compiler based on Chez Scheme. Racket is
648also a platform for language-oriented programming, from small domain-specific
649languages to complete language implementations.
650
651The ``minimal Racket'' distribution includes just enough of Racket for you to
652use @command{raco pkg} to install more. Bundled packages, such as the
653DrRacket IDE, are not included.")
654 ;; https://download.racket-lang.org/license.html
655 ;; The LGPL components are only used by Racket BC.
656 (license (list license:asl2.0 license:expat))))
657
658(define-public racket
659 (package
660 (inherit racket-minimal)
661 (name "racket")
662 (source #f)
663 (native-inputs (list racket-minimal)) ; XXX: conservative estimate, untested
664 (inputs
665 (list
666 cairo
667 fontconfig
668 glib
669 glu
670 gmp
671 gtk+ ;; propagates gdk-pixbuf+svg
672 libjpeg-turbo
673 libpng
674 libx11 ;; ?? wayland ??
675 mesa
676 mpfr
677 pango
678 unixodbc
679 libedit ;; TODO reconsider in light of expeditor and readline-gpl
680 racket-minimal ;; <-- TODO non-tethered layer
681 racket-vm-cs
682 (simple-racket-origin
683 "2d" (base32 "0fb5v6058ls08xw3zbmqyr2ym0psm119gl9ffgmhm9w8rs9i4dq7")
684 '("2d" "2d-doc" "2d-lib"))
685 (simple-racket-origin
686 "algol60" (base32 "03akd7xhn4l7y66qgaimvdbn6gq7ay6j03dc11mz80n06z21dfb6")
687 '(("algol60" ".")))
688 (racket-packages-origin
689 "racket" %racket-origin
690 '(("at-exp-lib" "pkgs/at-exp-lib")
691 ("compiler" "pkgs/compiler")
692 ("compiler-lib" "pkgs/compiler-lib")
693 ("net" "pkgs/net")
694 ("net-doc" "pkgs/net-doc")
695 ("net-lib" "pkgs/net-lib")
696 ("racket-doc" "pkgs/racket-doc")
697 ("racket-index" "pkgs/racket-index")
698 ("racket-index-exe" "pkgs/racket-index-exe")
699 ("scheme-doc" "pkgs/scheme-doc")
700 ("sandbox-lib" "pkgs/sandbox-lib")
701 ("sequence-tools-lib" "pkgs/sequence-tools-lib")
702 ("zo-lib" "pkgs/zo-lib")))
703 (simple-racket-origin
704 "cext-lib" (base32 "0xhl7k2xns08lwfs7241g8994py3rh9p6ks2q1jbhrmbfq8j9v2v")
705 '("cext-lib" "dynext-lib"))
706 (simple-racket-origin
707 "class-iop" (base32 "08z57q83cr7wnh6g8ah3hdhmsmf9zp1jfs7yvxv188l3hzvygy5l")
708 '("class-iop-lib"))
709 (simple-racket-origin
710 "compatibility" (base32 "14jvklchabd2hfp1ffmwghl4va1xill86s7qixqnzxqqhpi895n2")
711 '("compatibility" "compatibility-doc" "compatibility-lib"))
712 (simple-racket-origin
713 "contract-profile" (base32 "068z8flwcznqg0bjk227i2qapqbciyrckgqf8mvk57gxmr6zh3d3")
714 '(("contract-profile" ".")))
715 (simple-racket-origin
716 "data" (base32 "1lx9lq1wrfcdws60q88gkkx8bxy7igla9p4fjhyij75mk80qm6wh")
717 '("data" "data-doc" "data-enumerate-lib" "data-lib"))
718 (simple-racket-origin
719 "datalog" (base32 "0nf6cy4djpyhfvgpa6yn72apbz9s83gp0qg95pzjd0az4v6qwq1s")
720 '(("datalog" ".")))
721 (simple-racket-origin
722 "db" (base32 "09f2wysqmgs46nbzmwrhbn6jqnkpj6bsabm6s6kw8qmp6azca9q2")
723 '("db" "db-doc" "db-lib"))
724 (simple-racket-origin
725 "deinprogramm" (base32 "0j7867c8nshgz0mcl9l7w5adwi51lxf6s2x4cv24674xgbh71xkn")
726 '("deinprogramm"
727 "deinprogramm-doc"
728 "deinprogramm-lib"
729 "deinprogramm-signature"
730 "deinprogramm-tool"))
731 (simple-racket-origin
732 "distributed-places" (base32 "1dajpkj9balqcpv6cdk9hwjz592h1vq8rrx5vncariiac4vbdpa0")
733 '("distributed-places" "distributed-places-doc" "distributed-places-lib"))
734 (simple-racket-origin
735 "draw" (base32 "0j2xzirchwjrynqf10w69ji3qrmqh3p4zrfqsxalvf6h0cqpfrf8")
736 '("draw" "draw-doc" "draw-lib"))
737 (simple-racket-origin
738 "drracket" (base32 "1hrz4brh4zfzr7mnkdxyalgnziyzvk2ggr03hnamkfir1cy1szbq")
739 '("drracket"
740 "drracket-core"
741 "drracket-core-lib"
742 "drracket-plugin-lib"
743 "drracket-tool"
744 "drracket-tool-doc"
745 "drracket-tool-lib"
746 "drracket-tool-text-lib"))
747 (simple-racket-origin
748 "ds-store" (base32 "0lv8dy891k8gllhiqpag6x34jwgs57ihvqwp72plcgyi51qfpz5x")
749 '("ds-store" "ds-store-doc" "ds-store-lib"))
750 (simple-racket-origin
751 "eli-tester" (base32 "0icx6wn14gjm8kdmq1jppqgq87sxkras4qb5xmdr6wigxafhjqyk")
752 '(("eli-tester" ".")))
753 (simple-racket-origin
754 "eopl" (base32 "0qihajdpwf2q7hbs6fsw6mmmzy57kgzgry3vyp9z8w7ay8df3w15")
755 '(("eopl" ".")))
756 (simple-racket-origin
757 "errortrace" (base32 "1xlyfjls2nwajr178sz6liqp9hql6yj519jcqbhyp31yzv7d781l")
758 '("errortrace" "errortrace-doc" "errortrace-lib"))
759 (simple-racket-origin
760 "expeditor" (base32 "1nk88jq0blzcw45fr8nwp024cysplayi3paaay4z824lkn1smzaa")
761 '("expeditor" "expeditor-doc" "expeditor-lib"))
762 (simple-racket-origin
763 "frtime" (base32 "0ydz2yn8vvv6z7brwlswcyx0f31a6y6d443i89rysfvd2xkhpfd5")
764 '(("frtime" ".")))
765 (simple-racket-origin
766 "future-visualizer" (base32 "0yzfs4ls5h9224wnssm21mm6dig40r9k6zh66sbi1vrlwyswpym0")
767 '("future-visualizer"
768 "future-visualizer-pict"
769 "future-visualizer-typed"))
770 (simple-racket-origin
771 "games" (base32 "13z7fnbr48s98lmfxc0nbfhbqkd4hphymy2r63hqm783xzn6ylzi")
772 '(("games" ".")))
773 (simple-racket-origin
774 "gui" (base32 "199k6ii97f1ys6m65xb7q1f5g6cx8f3ipxkxsp98mjyxy44gg3ip")
775 '("gui" "gui-doc" "gui-lib" "tex-table"))
776 (simple-racket-origin
777 "gui-pkg-manager" (base32 "1f0ssg37kdk3xn9js616ns345565q39j9h51wzd99753iqd45m92")
778 '("gui-pkg-manager-lib"))
779 (simple-racket-origin
780 "htdp" (base32 "0brylvba54bm4d5g1z5zz07yl0qazvj3pqvrrliy5h8r0c3qi8fq")
781 '("htdp" "htdp-doc" "htdp-lib"))
782 (simple-racket-origin
783 "html" (base32 "18n1jnjgzfknc8nv8dppi85nb8q08gqdwkg6hfjk08x0p00anx2x")
784 '("html" "html-doc" "html-lib"))
785 (simple-racket-origin
786 "icons" (base32 "1s5a6j11fg3fdr6b7vm2q7q178d7q8b8igy73bs211r27qrd1gg7")
787 '(("icons" ".")))
788 (simple-racket-origin
789 "images" (base32 "0ckg53nzq4zdv8qc4f5nim9wsgsnif56w1wmji5w2czfm0j7frln")
790 '("images" "images-doc" "images-gui-lib" "images-lib"))
791 (simple-racket-origin
792 "lazy" (base32 "0rn8kd0ih7aw6fj1g7jdvi5978a6q4hyd6gbh89nb6j5ijvlgn43")
793 '(("lazy" ".")))
794 (simple-racket-origin
795 "macro-debugger" (base32 "0x3dy0dksz95pqgllwkv6i2jxvkbcnv9h9zpkjfq8dl304z1bkhp")
796 '("macro-debugger" "macro-debugger-text-lib"))
797 (simple-racket-origin
798 "main-distribution" (base32 "0gk7wrwy0r1yllk827h8awfswngl1lhlq765d6s42y841v33jn0i")
799 '(("main-distribution" ".")))
800 (simple-racket-origin
801 "make" (base32 "10852fj30bz5r46c3d99s37fkgy5yh44gb01j29sf3kxnhi0g2sa")
802 '(("make" ".")))
803 (simple-racket-origin
804 "math" (base32 "0rspnhdlgsnmr8i5nvp4lfqd9dvsvkj90f7xsic4imd23ja2zxkw")
805 '("math" "math-doc" "math-lib"))
806 (simple-racket-origin
807 "mysterx" (base32 "11p9jzrafw0hizhl0cs4sxx7rv281185q8hryic2rpk0kzjdyr48")
808 '(("mysterx" ".")))
809 (simple-racket-origin
810 "mzcom" (base32 "0rc9pfj7gwm5azghqvcibz6si1x5s2v8mr2yngk7ssq9gzfbi6a4")
811 '(("mzcom" ".")))
812 (simple-racket-origin
813 "mzscheme" (base32 "0p7bp8rmzw7k12sjxdqlxf31d8ama4wv9qz6ryvnmjn2qyhrr3d1")
814 '("mzscheme" "mzscheme-doc" "mzscheme-lib"))
815 (racket-packages-origin
816 "net-cookies" (origin
817 (method git-fetch)
818 (uri (git-reference
819 (url "https://github.com/RenaissanceBug/racket-cookies")
820 (commit %racket-commit)))
821 (sha256 (base32
822 "1220vskrvaqibazxzkzg0icg211ddlb7y20rb7v6d2zqfm16jin8"))
823 (file-name
824 (git-file-name "RenaissanceBug-racket-cookies" %racket-version)))
825 '("net-cookies" "net-cookies-doc" "net-cookies-lib"))
826 (racket-packages-origin
827 "optimization-coach"
828 (origin
829 (method git-fetch)
830 (uri (git-reference
831 (url "https://github.com/stamourv/optimization-coach")
832 (commit %racket-commit)))
833 (sha256 (base32
834 "0b27sw48d7rhz0hin88c7rbr9vpg1c23sn82nd4jkmq54h6gasr1"))
835 (file-name
836 (git-file-name "stamourv-optimization-coach" %racket-version)))
837 '(("optimization-coach" ".")))
838 (simple-racket-origin
839 "option-contract" (base32 "1914dcxy6qzpg3cpnzdm9lj0kwyw8xdb85mwiamqfkbg0xlyyhpa")
840 '("option-contract" "option-contract-doc" "option-contract-lib"))
841 (simple-racket-origin
842 "parser-tools" (base32 "0dp99d1a47kqyg2iqdijm5781qnd571iwvg85dvrjc76ab4pccgd")
843 '("parser-tools" "parser-tools-doc" "parser-tools-lib"))
844 (simple-racket-origin
845 "pconvert" (base32 "0xw9f9692v2qp16fwmwmwmrb118kpz259vmx8cq6s9vsw0112zpq")
846 '("pconvert-lib" "pconvert-doc"))
847 (simple-racket-origin
848 "pict" (base32 "1xs1k98nr052p5v30abn7kl8pm1rdwj8xqvrghw8b62bvhhb072a")
849 '("pict" "pict-doc" "pict-lib"))
850 (simple-racket-origin
851 "pict-snip" (base32 "1qrqbigw6arhccqgqzblfqqcpsdy15dwb0y22axwxgpw1ax0ki6f")
852 '("pict-snip" "pict-snip-doc" "pict-snip-lib"))
853 (simple-racket-origin
854 "picturing-programs" (base32 "1a3d6nw9n827b4711nvgrnw7w47k4fxvk8c2a8br6a1l748kxkwy")
855 '(("picturing-programs" ".")))
856 (simple-racket-origin
857 "plai" (base32 "1vcplmrzk2wr0n0m4fa0nq9ir986d5nk3dvcd7h1rv2jvhkcqdaq")
858 '("plai" "plai-doc" "plai-lib"))
859 (simple-racket-origin
860 "planet" (base32 "0r2yqrzrmdjjyr14k6hhlzc5kzrcx3583m1s02mhrcmpfw0s85w9")
861 '("planet" "planet-doc" "planet-lib"))
862 (simple-racket-origin
863 "plot" (base32 "0skmir4njxmh3yx3ng23dvwkal79dd3fd23ijk6lyk8b013w1kj2")
864 '("plot" "plot-compat" "plot-doc" "plot-gui-lib" "plot-lib"))
865 (simple-racket-origin
866 "preprocessor" (base32 "1p5aid58ifnjy4xl0ysh85cq39k25661v975jrpk182z3k5621mg")
867 '(("preprocessor" ".")))
868 (simple-racket-origin
869 "profile" (base32 "1n6jlhkq0zs2sd132k92nvw08qscadjz3d6p2r5pjlcdawkmkik0")
870 '("profile" "profile-doc" "profile-lib"))
871 (racket-packages-origin
872 "quickscript" (origin
873 (method git-fetch)
874 (uri (git-reference
875 (url "https://github.com/Metaxal/quickscript")
876 (commit %racket-commit)))
877 (sha256 (base32
878 "1r7i4g39hfkn0wb34dylzcp43ys1zl7ra9wmbzly07an7891xmns"))
879 (file-name (git-file-name "Metaxal-quickscript" %racket-version)))
880 '(("quickscript" ".")))
881 (simple-racket-origin
882 "r5rs" (base32 "06rw7aihq4wdr27nan42mfg13fs9lh8d0hf7m9g8m5vmnkd3h2pn")
883 '("r5rs" "r5rs-doc" "r5rs-lib"))
884 (simple-racket-origin
885 "r6rs" (base32 "19pfv07lgkhjqxvy6k5s7wn26rkibrr0lnnfg9b0qybhxscbgjny")
886 '("r6rs" "r6rs-doc" "r6rs-lib"))
887 (racket-packages-origin
888 "racket-cheat" (origin
889 (method git-fetch)
890 (uri (git-reference
891 (url "https://github.com/jeapostrophe/racket-cheat")
892 (commit %racket-commit)))
893 (sha256 (base32
894 "1q0da3hm64fj64f713yxdlg7x1hp162fnn3mc7al2hzk098w242w"))
895 (file-name
896 (git-file-name "jeapostrophe-racket-cheat" %racket-version)))
897 '(("racket-cheat" ".")))
898 (simple-racket-origin
899 "racklog" (base32 "0i2jnghb5vqmk2f0cppgggyp73zy1q0dlhpvxrzdxw39skmhmgkc")
900 '(("racklog" ".")))
901 (simple-racket-origin
902 "rackunit" (base32 "1p3mlhjfwr3522ajr4w76j1hrgsjraz4w02jr6jhfw4slbdrcf6b")
903 '("rackunit"
904 "rackunit-doc"
905 "rackunit-gui"
906 "rackunit-lib"
907 "rackunit-plugin-lib"
908 "rackunit-typed"
909 "schemeunit"
910 "testing-util-lib"))
911 (simple-racket-origin
912 "readline" (base32 "13kbcn2wchv82d709mw3r8n37bk8iwq0y4kpvm9dbzx0w2pxkfwn")
913 '("readline" "readline-doc" "readline-lib"))
914 (simple-racket-origin
915 "realm" (base32 "0rlvwyd6rpyl0zda4a5p8dp346fvqzc8555dgfnrhliymkxb6x4g")
916 '(("realm" ".")))
917 (simple-racket-origin
918 "redex" (base32 "0mh88bz681rsvfadsnlbjmbf4vwa8bxn7kkxpq408dri0rdd3wb4")
919 '("redex"
920 "redex-benchmark"
921 "redex-doc"
922 "redex-examples"
923 "redex-gui-lib"
924 "redex-lib"
925 "redex-pict-lib"))
926 (simple-racket-origin
927 "sasl" (base32 "1l74rkp8m2jfb82678k3lhd2y5k9l8csazwshf9m969i67gzbjh8")
928 '("sasl" "sasl-doc" "sasl-lib"))
929 (simple-racket-origin
930 "scheme-lib" (base32 "0pcf0y8rp4qyjhaz5ww5sr5diq0wpcdfrrnask7zapyklzx1jx8x")
931 '(("scheme-lib" ".")))
932 (simple-racket-origin
933 "scribble" (base32 "0jj045dqc42jga9lxj6frafdh5x2ygw2a9an5d0dfwqjclgzcv9m")
934 '("scribble"
935 "scribble-doc"
936 "scribble-html-lib"
937 "scribble-lib"
938 "scribble-text-lib"))
939 (simple-racket-origin
940 "serialize-cstruct-lib"
941 (base32 "1rq3n1fa7ldjwx3lrh9ybhig7jlsw1crpzyklbzp3xqdw6jymfnz")
942 '(("serialize-cstruct-lib" ".")))
943 (simple-racket-origin
944 "sgl" (base32 "0nkymhdyjrwi5h199j4w5zh7y3x3ai42gsiwxzh0hy7yqrqqg9zv")
945 '(("sgl" ".")))
946 (simple-racket-origin
947 "shell-completion" (base32 "04m144gy2mp4fiq6rcbf12wjr8mws8k9scfhg9lc38vqppp4lxsj")
948 '(("shell-completion" ".")))
949 (simple-racket-origin
950 "simple-tree-text-markup"
951 (base32 "0fyd9gfz6bnv0m1901wv5mnhc05rm8hw9i6ddrqx33hs6qsg2zqr")
952 '("simple-tree-text-markup"
953 "simple-tree-text-markup-doc"
954 "simple-tree-text-markup-lib"))
955 (simple-racket-origin
956 "slatex" (base32 "0pkm2isbbdk63slrbsxcql7rr0wdrw5kapw1xq4ps5k8dhlzv8x0")
957 '(("slatex" ".")))
958 (simple-racket-origin
959 "slideshow" (base32 "1aprcapyj0362lfh2pbcyxf4r2k01zmp6yy9ppag0xbz0jw437im")
960 '("slideshow" "slideshow-doc" "slideshow-exe" "slideshow-lib" "slideshow-plugin"))
961 (simple-racket-origin
962 "snip" (base32 "10727bi2ybn2ahlkpikdknwfzfsppaw5wkvjmzd380jp1fw91q67")
963 '("snip" "snip-lib"))
964 (simple-racket-origin
965 "typed-racket" (base32 "06wi17w371vhfvjdhn61dfwrwsgpivpznzpng0ihkfp40kai1c7k")
966 '("source-syntax"
967 "typed-racket"
968 "typed-racket-compatibility"
969 "typed-racket-doc"
970 "typed-racket-lib"
971 "typed-racket-more"))
972 (simple-racket-origin
973 "srfi" (base32 "1m35kfwlm7wy16ncvx3ylhd77pj5p1gp7gkkva6b4df2bzzd00fs")
974 '("srfi" "srfi-doc" "srfi-lib" "srfi-lite-lib"))
975 (simple-racket-origin
976 "string-constants" (base32 "1nyc56wp3iwfizv0458rv95vncykgrc7y2wg0mh4j55g3pcprw3s")
977 '("string-constants" "string-constants-doc" "string-constants-lib"))
978 (simple-racket-origin
979 "swindle" (base32 "1q8vdxpzczzwdw2mys2caab45yvadmqkixsr29k8pl03n8dsg8j9")
980 '(("swindle" ".")))
981 (simple-racket-origin
982 "syntax-color" (base32 "0rsl8352fad94b3gc9dwmm6r300idfkm0ysj8kr1kaqhikznba80")
983 '("syntax-color" "syntax-color-doc" "syntax-color-lib"))
984 (simple-racket-origin
985 "trace" (base32 "1zx0kfbacidg5rllbvx842x949ra22n004irs3vm1hqmwmixy3is")
986 '(("trace" ".")))
987 (simple-racket-origin
988 "unix-socket" (base32 "039r2aqc6xc4b3x95ggjg4ab1pfiff6pavi4d40662zgwbi61pwk")
989 '("unix-socket" "unix-socket-doc" "unix-socket-lib"))
990 (simple-racket-origin
991 "web-server" (base32 "0v66z9dklf02lc0g357h4rnfq5pnk87d1qz59sfrlzz24phxg9g6")
992 '("web-server" "web-server-doc" "web-server-lib"))
993 (simple-racket-origin
994 "wxme" (base32 "1qp5gr9gqsakiq3alw6m4yyv5vw4i3hp4y4nhq8vl2nkjmirvn0b")
995 '("wxme" "wxme-lib"))
996 (simple-racket-origin
997 "xrepl" (base32 "1kkcm68qyck2d6mp56h1j5fnfbx938a15dnyn1cf5yqpj9cc637m")
998 '("xrepl" "xrepl-doc" "xrepl-lib"))))
999 (build-system gnu-build-system)
1000 (arguments
1001 (substitute-keyword-arguments arguments
1002 ((#:make-flags _ '())
1003 #~`("main-distribution"))
1004 ((#:configure-flags _ '())
1005 #~`("--tethered"
1006 "--extra-foreign-lib-search-dirs"
1007 ,(format #f "~s"
1008 '(#$@(map (lambda (name)
1009 (cond
1010 ((this-package-input name)
1011 => (cut file-append <> "/lib"))
1012 (else
1013 (raise
1014 (formatted-message
1015 (G_ "missing input '~a' to the 'racket' package")
1016 name)))))
1017 '("cairo"
1018 "fontconfig-minimal" ;; aka fontconfig
1019 "glib"
1020 "glu"
1021 "gmp"
1022 "gtk+"
1023 "libjpeg-turbo"
1024 "libpng"
1025 "libx11"
1026 "mesa"
1027 "mpfr"
1028 "pango"
1029 "unixodbc"
1030 "libedit"))))))))
1031 (synopsis "Programmable programming language in the Scheme family")
1032 (description
1033 "Racket is a general-purpose programming language in the Scheme family,
1034with a large set of libraries and a compiler based on Chez Scheme. Racket is
1035also a platform for language-oriented programming, from small domain-specific
1036languages to complete language implementations.
1037
1038The main Racket distribution comes with many bundled packages, including the
1039DrRacket IDE, libraries for GUI and web programming, and implementations of
1040languages such as Typed Racket, R5RS and R6RS Scheme, Algol 60, and Datalog.")))
1041
1042(define configure-layer.rkt
1043 (scheme-file
1044 "configure-layer.rkt"
1045 `(module
1046 configure-layer racket/base
1047 (require racket/cmdline
1048 racket/match
1049 racket/file
1050 racket/port
1051 racket/list
1052 racket/pretty)
1053 (define (build-path-string . args)
1054 (path->string (apply build-path args)))
1055 (define rx:racket
1056 ;; Guile's reader doesn't support #rx"racket"
1057 (regexp "racket"))
1058 (define tethered? #f)
1059 (define parent #f)
1060 (define extra-foreign-lib-search-dirs '())
1061 (define-values [vm-dir prefix]
1062 (command-line
1063 #:once-each
1064 [("--tethered") "create a tethered layer"
1065 (set! tethered? #t)]
1066 [("--parent") dir "path of parent layer, if any"
1067 (set! parent dir)]
1068 [("--extra-foreign-lib-search-dirs") dir-list
1069 "foreign library directories, as a list of strings in `read` syntax"
1070 (set! extra-foreign-lib-search-dirs
1071 (call-with-input-string dir-list read))]
1072 #:args (vm-dir prefix)
1073 (values vm-dir prefix)))
1074 (let* ([config
1075 (for/fold
1076 ([config (file->value
1077 (if parent
1078 (build-path parent "etc/racket/config.rktd")
1079 (build-path vm-dir "etc/config.rktd")))])
1080 ([spec
1081 (in-list
1082 '((lib-dir lib-search-dirs "lib/racket" "lib")
1083 (share-dir share-search-dirs "share/racket" "share")
1084 (links-file links-search-files
1085 "lib/racket/links.rktd"
1086 "share/links.rktd")
1087 (pkgs-dir pkgs-search-dirs "lib/racket/pkgs" "share/pkgs")
1088 ;; Partial workaround for:
1089 ;; https://github.com/racket/racket/issues/4133
1090 #;(bin-dir bin-search-dirs "bin" "bin")
1091 (bin-dir bin-search-dirs
1092 "lib/racket/bogus-untethered-bin"
1093 "bin")
1094 (man-dir man-search-dirs "share/man" "share/man")
1095 (doc-dir doc-search-dirs "share/doc/racket" "doc")
1096 (include-dir include-search-dirs
1097 "include/racket"
1098 "include")))])
1099 (match-define (list main-key search-key pth vm-pth) spec)
1100 (hash-set*
1101 config
1102 main-key
1103 (build-path-string prefix pth)
1104 search-key
1105 (list* #f
1106 (hash-ref config
1107 main-key
1108 (lambda ()
1109 (if parent
1110 (build-path-string parent pth)
1111 (build-path-string vm-dir vm-pth))))
1112 (filter values (hash-ref config search-key null)))))]
1113 [config
1114 (hash-update config
1115 'lib-search-dirs
1116 (lambda (dirs)
1117 ;; add after other layers, but before older
1118 ;; foreign lib search directories
1119 (define-values [rkt old-foreign-dirs]
1120 (partition (lambda (pth)
1121 (or (not pth)
1122 (regexp-match? rx:racket pth)))
1123 dirs))
1124 (append rkt
1125 extra-foreign-lib-search-dirs
1126 old-foreign-dirs)))]
1127 [config
1128 (hash-set* config
1129 'apps-dir
1130 (build-path-string prefix "share/applications")
1131 'absolute-installation? #t
1132 ;; Let Guix coexist with other installation
1133 ;; methods without clobbering user-specific packages.
1134 ;; This could be set in various places, but doing
1135 ;; it here is convenient, at least until we support
1136 ;; cross-compilation.
1137 'installation-name
1138 (string-append (version)
1139 "-guix"
1140 (match (system-type 'gc)
1141 ['cgc "-cgc"]
1142 ;; workaround Guile reader/printer:
1143 ['|3m| "-bc"]
1144 [_ ""])))]
1145 [config
1146 (cond
1147 [tethered?
1148 ;; Partial workaround for:
1149 ;; https://github.com/racket/racket/issues/4133
1150 #;(define bin-dir (hash-ref config 'bin-dir))
1151 (define bin-dir (build-path-string prefix "bin"))
1152 (hash-set* config
1153 'config-tethered-apps-dir (hash-ref config 'apps-dir)
1154 'config-tethered-console-bin-dir bin-dir
1155 'config-tethered-gui-bin-dir bin-dir)]
1156 [else
1157 config])])
1158 (define new-config-pth
1159 (build-path prefix "etc/racket/config.rktd"))
1160 (make-parent-directory* new-config-pth)
1161 (call-with-output-file*
1162 new-config-pth
1163 (lambda (out)
1164 (pretty-write config out)))))))