all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob 4e2d498364edb243f2e8a3411d0228955d0f4dea 31604 bytes (raw)
name: gnu/packages/racket.scm 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
 
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014, 2015, 2016, 2018, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2020 Pierre Neidhardt <mail@ambrevar.xyz>
;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages racket)
  #:use-module ((guix licenses)
                #:select (asl2.0 expat lgpl3+))
  #:use-module (guix packages)
  #:use-module (guix base16)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix utils)
  #:use-module (guix gexp)
  #:use-module (guix build-system gnu)
  #:use-module (srfi srfi-1)
  #:use-module (ice-9 match)
  #:use-module (gnu packages)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages bash)
  #:use-module (gnu packages chez)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages databases)
  #:use-module (gnu packages fontutils)
  #:use-module (gnu packages gl)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages image)
  #:use-module (gnu packages libedit)
  #:use-module (gnu packages libffi)
  #:use-module (gnu packages multiprecision)
  #:use-module (gnu packages sqlite)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages xorg))

;; Commentary:
;;
;; Preliminary guidelines on naming things:
;;
;;   - `racket` is the main package. It corresponds to `racket-minimal`
;;     with the Racket-level package "main-distribution" installed.
;;   - `racket-minimal` is Racket runtime system and core libraries:
;;     just enough to implement the package system and install the rest.
;;     Upstream refers to this as "minimal Racket".
;;   - `racket-pkg-` should probably be the prefix for Racket packages
;;     available as Guix packages, once we're able to build those.
;;     More specifically, it should correspond
;;     to packages registered in the catalog at https://pkgs.rackat-lang.org.
;;     This is a social convention to manage the namespace, not a technical
;;     limitation: Racket can use other catalogs (e.g. for pre-built packages
;;     or packages pinned to specific versions), unregistered package source
;;     urls, or purely local packages. But we also need a convention to
;;     manage the namespace, so we should use this one. In practice,
;;     all generally useful libre Racket packages are registered there.
;;     We probably will need a clever encoding scheme to deal with the fact
;;     that Racket package names can contain [A-Za-z_-], i.e. including "_",
;;     which is not allowed in Guix package names.
;;   - `racket-next` is a development version of `racket`, following either
;;     the upstrean Git HEAD or the release candidate, when one exists.
;;   - `racket-next-` is the prefix for other development packages,
;;     including `racket-next-minimal`. When we can build Racket packages
;;     individually, we will need `racket-next-pkg-` for the packages
;;     that make up `racket-next`.
;;
;; Here's how bootstrapping minimal Racket works:
;;
;;   - Racket BC [CGC] can be built with only a C compiler (except for
;;     one caveat discussed below).
;;   - Racket BC [3M] needs an existing Racket to run "xform",
;;     which transforms its own C source code to add additional annotations
;;     for the precise garbage collector.
;;   - Racket CS needs (bootfiles for) Racket's fork of Chez Scheme.
;;     It also needs an existing Racket to compile Racket-implemented
;;     parts of the runtime system to R6RS libraries.
;;   - Chez Scheme also needs bootfiles for itself, but Racket can simulate
;;     enough of Chez Scheme to load Racket's fork of the Chez Scheme compiler
;;     purely from source into Racket and apply the compiler to itself,
;;     producing the needed bootfiles (albeit very slowly).
;;     Any variant of Racket since version 7.1 can run the simulation.
;;
;; So, we build CGC to build 3M to build bootfiles and CS.
;;
;; One remaining bootstrapping limitation is that Racket's reader, module
;; system, and macro expander are implemented in Racket. For Racket CS,
;; they are compiled to R6RS libraries as discussed above. This note from the
;; README file applies to all such subsystems:
;;
;;     The Racket version must be practically the same as the current Racket
;;     verson, although it can be the Racket BC implementation (instead of
;;     the Racket CS implementation).
;;
;;     Unlike Chez Scheme boot files, the files generated in "schemified"
;;     are human-readable and -editable Scheme code. That provides a way
;;     out of bootstrapping black holes, even without BC.
;;
;; However, other Racket subsystems implemented in Racket for Racket CS
;; use older C implementations for Racket BC, whereas the reader, expander,
;; and module system were completely replaced with the Racket implementation
;; as of Racket 7.0.
;;
;; For Racket BC, the compiled "linklet" s-expressions (primitive modules)
;; are embeded in C as a static string constant. Eventually, they are further
;; compiled by the C-implemented Racket BC bytecode and JIT compilers.
;; (On platforms where Racket BC's JIT is not supported, yet another compiler
;; instead compiles the linklets to C code, but this is not a bootstrapping
;; issue.)
;;
;; Code:


(define %installer-mirrors
  ;; Source:
  ;; https://github.com/racket/racket-lang-org/blob/master/download/data.rkt#L58
  ;; Matthew Flatt says: "note that many are commented out"
  ;; INVARIANT: End with a trailing "/"!
  '("https://mirror.racket-lang.org/installers/"
    "https://www.cs.utah.edu/plt/installers/"
    "https://plt.cs.northwestern.edu/racket-mirror/"
    "https://mirror.csclub.uwaterloo.ca/racket/racket-installers/"
    ;; Universität Tübingen is using a self-signed HTTPS certificate:
    "http://mirror.informatik.uni-tuebingen.de/mirror/racket/"
    "https://racket.infogroep.be/"
    ))


(define-public racket-minimal
  (package
    (name "racket-minimal")
    (version "8.1")            ; note: remember to also update racket!
    (source
     (origin
       (method url-fetch)
       (uri (map (lambda (base)
                   (string-append base version "/racket-minimal-src.tgz"))
                 %installer-mirrors))
       (sha256 "04zzqybpxss50n1jrwwq98539gw0y0ygpw9civl2sq3s4ww7m8l3")
       (patches (search-patches
                 "racket-sh-via-rktio.patch"))))
    (home-page "https://racket-lang.org")
    (synopsis "Racket without bundled packages such as DrRacket")
    (inputs
     `(("openssl" ,openssl)
       ("sqlite" ,sqlite)
       ("sh" ,bash-minimal)
       ("zlib" ,zlib)
       ("zlib:static" ,zlib "static")
       ("lz4" ,lz4)
       ("lz4:static" ,lz4 "static")))
    (build-system gnu-build-system)
    (arguments
     `(#:configure-flags
       `(,(string-append "CPPFLAGS=-DGUIX_RKTIO_PATCH_BIN_SH="
                         (assoc-ref %build-inputs "sh")
                         "/bin/sh")
         "--enable-libz"
         "--enable-liblz4")
       #:modules
       ((guix build gnu-build-system)
        (guix build utils)
        (srfi srfi-1))
       #:phases
       (modify-phases %standard-phases
         (add-before 'configure 'pre-configure-minimal
           (lambda* (#:key inputs #:allow-other-keys)
             (chdir "src")
             #t))
         (add-after 'build 'patch-config.rktd-lib-search-dirs
           (lambda* (#:key inputs outputs #:allow-other-keys)
             ;; We do this between the `build` and `install` phases
             ;; so that we have racket to read and write the hash table,
             ;; but it comes before `raco setup`, when foreign libraries
             ;; are needed to build the documentation.
             (define out (assoc-ref outputs "out"))
             (apply invoke
                    "./cs/c/racketcs"
                    "-e"
                    ,(format #f
                             "~s"
                             '(let* ((args
                                      (vector->list
                                       (current-command-line-arguments)))
                                     (file (car args))
                                     (extra-lib-search-dirs (cdr args)))
                                (write-to-file
                                 (hash-update
                                  (file->value file)
                                  'lib-search-dirs
                                  (lambda (dirs)
                                    (append dirs extra-lib-search-dirs))
                                  '(#f))
                                 #:exists 'truncate/replace
                                 file)))
                    "--"
                    "../etc/config.rktd"
                    (filter-map (lambda (lib)
                                  (cond
                                   ((assoc-ref inputs lib)
                                    => (lambda (pth)
                                         (string-append pth "/lib")))
                                   (else
                                    #f)))
                                '("cairo"
                                  "fontconfig"
                                  "glib"
                                  "glu"
                                  "gmp"
                                  "gtk+"
                                  "libjpeg"
                                  "libpng"
                                  "libx11"
                                  "mesa"
                                  "mpfr"
                                  "openssl"
                                  "pango"
                                  "sqlite"
                                  "unixodbc"
                                  "libedit")))
             #t)))
       ;; Tests are in packages like racket-test-core and
       ;; main-distribution-test that aren't part of the main distribution.
       #:tests? #f))
    (description
     "Racket is a general-purpose programming language in the Scheme family,
with a large set of libraries and a compiler based on Chez Scheme.  Racket is
also a platform for language-oriented programming, from small domain-specific
languages to complete language implementations.

The ``minimal Racket'' distribution includes just enough of Racket for you to
use @command{raco pkg} to install more.  Bundled packages, such as the
DrRacket IDE, are not included.")
    ;; https://download.racket-lang.org/license.html
    (license (list lgpl3+ asl2.0 expat))))

(define-public racket
  (package
    (inherit racket-minimal)
    (name "racket")
    (version (package-version racket-minimal)) ; needed for origin uri to work
    (source
     (origin
       (inherit (package-source racket-minimal))
       (uri (map (lambda (base)
                   (string-append base version "/racket-src.tgz"))
                 %installer-mirrors))
       (sha256
        (base32
         "0xdqwrwm604bbnr97h75dps2ixxz2svlw0fn0f674bn04dcfd60f"))))
    (inputs
     `(;; sqlite and libraries for `racket/draw' are needed to build the doc.
       ("cairo" ,cairo)
       ("fontconfig" ,fontconfig)
       ("glib" ,glib)
       ("glu" ,glu)
       ("gmp" ,gmp)
       ("gtk+" ,gtk+)                   ; propagates gdk-pixbuf+svg
       ("libjpeg" ,libjpeg-turbo)
       ("libpng" ,libpng)
       ("libx11" ,libx11)
       ("mesa" ,mesa)
       ("mpfr" ,mpfr)
       ("pango" ,pango)
       ("unixodbc" ,unixodbc)
       ("libedit" ,libedit)
       ,@(package-inputs racket-minimal)))
    (synopsis "A programmable programming language in the Scheme family")
    (description
     "Racket is a general-purpose programming language in the Scheme family,
with a large set of libraries and a compiler based on Chez Scheme.  Racket is
also a platform for language-oriented programming, from small domain-specific
languages to complete language implementations.

The main Racket distribution comes with many bundled packages, including the
DrRacket IDE, libraries for GUI and web programming, and implementations of
languages such as Typed Racket, R5RS and R6RS Scheme, Algol 60, and Datalog.")))


(define cfg-flag:sh-for-rktio
  `(string-append "CPPFLAGS=-DGUIX_RKTIO_PATCH_BIN_SH="
                  (assoc-ref %build-inputs "sh")
                  "/bin/sh"))
(define cfg-flag:enable-lt
  `(string-append "--enable-lt="
                  (assoc-ref %build-inputs "libtool")
                  "/bin/libtool"))
(define cfg-flag:enable-racket
  `(let ((racket (assoc-ref %build-inputs "racket")))
     (string-append "--enable-racket="
                    racket
                    "/bin/racket")))

(define unpack-nanopass+stex
  ;; Copied from chez-scheme.
  ;; TODO: Eventually, we should refactor Chez Scheme
  ;; enough to share more directly, so that we can make
  ;; Racket's version of Chez avalable as a Guix package,
  ;; e.g. for architectures not supported upstream.
  ;; For now, we let Racket drive the Chez build process
  ;; other than this step.
  `(for-each (lambda (dep)
               (define src
                 (assoc-ref (or native-inputs inputs) dep))
               (copy-recursively src dep
                                 #:keep-mtime? #t))
             '("nanopass" "stex")))

(define-public racket-next-minimal
  (package
    (inherit racket-minimal)
    (name "racket-next-minimal")
    (version "8.1.900")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/racket/racket")
             (commit "0874b76de4f147ada46607857d8acf8445a1073d")))
       (sha256
        (base32
         "0gy6rwyrpaij5k5pcyiif821b4vffqiaxg1vpg4iykw2c5ypfp43"))
       (file-name
        (git-file-name name version))
       (patches
        (search-patches
         "racket-next-minimal-sh-via-rktio.patch"))
       (snippet
        (with-imported-modules '((guix build utils))
          #~(begin
              (use-modules (guix build utils))
              ;; unbundle Chez submodules
              (with-directory-excursion "racket/src/ChezScheme"
                #$(origin-snippet (package-source chez-scheme)))
              ;; unbundle libffi
              (for-each
               delete-file-recursively
               '("racket/src/bc/foreign/libffi")))))))
    (inputs
     `(;; common to all racket-minimal variants:
       ("openssl" ,openssl)
       ("sqlite" ,sqlite)
       ("sh" ,bash-minimal)
       ;; only for CS
       ("zlib" ,zlib)
       ("zlib:static" ,zlib "static")
       ("lz4" ,lz4)
       ("lz4:static" ,lz4 "static")))
    (native-inputs
     `(("bootfiles" ,racket-next-bootstrap-chez-bootfiles)
       ,@(package-native-inputs racket-next-bootstrap-chez-bootfiles)))
    (build-system gnu-build-system)
    (arguments
     `(#:configure-flags
       (list "--enable-csonly"
             "--enable-libz"
             "--enable-liblz4"
             ,cfg-flag:enable-racket
             ,cfg-flag:sh-for-rktio)
       #:out-of-source? #true
       #:tests? #f ;; not yet
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'unpack-nanopass+stex
           (lambda* (#:key inputs native-inputs #:allow-other-keys)
             (with-directory-excursion "racket/src/ChezScheme"
               ,unpack-nanopass+stex)))
         (add-after 'unpack-nanopass+stex 'unpack-bootfiles
           (lambda* (#:key inputs #:allow-other-keys)
             (with-directory-excursion "racket/src/ChezScheme"
               (copy-recursively
                (string-append (assoc-ref inputs "bootfiles") "/boot")
                "boot"))))
         (add-before 'configure 'initialize-config.rktd
           (lambda* (#:key inputs #:allow-other-keys)
             (mkdir-p "racket/etc")
             (with-output-to-file "racket/etc/config.rktd"
               (lambda ()
                 (format #t
                         "#hash((lib-search-dirs . ~s))\n"
                         (cons #f
                               (map (lambda (lib)
                                      (string-append (assoc-ref inputs lib)
                                                     "/lib"))
                                    '("openssl"
                                      "sqlite"))))))
             #t))
         (replace 'configure
           (let ((inner (assq-ref %standard-phases 'configure)))
             (lambda args
               (chdir "racket/src")
               (apply inner args))))
         (add-after 'install 'remove-pkgs-directory
           ;; otherwise, e.g., `raco pkg show` will try and fail to
           ;; create a lock file
           (lambda* (#:key outputs #:allow-other-keys)
             ;; rmdir because we want an error if it isn't empty
             (rmdir (string-append (assoc-ref outputs "out")
                                   "/share/racket/pkgs"))
             #t)))))
    ;; https://download.racket-lang.org/license.html
    ;; The LGPL components are only used by Racket BC.
    (license (list asl2.0 expat))))

(define-public racket-next-minimal-bc-3m
  (hidden-package
   (package/inherit racket-next-minimal
     (name "racket-next-minimal-bc-3m")
     (inputs
      `(("libffi" ,libffi) ;; <- only for BC variants
        ,@(filter (match-lambda
                    ((label . _)
                     (not (member label
                                  '("zlib" "zlib:static"
                                    "lz4" "lz4:static")))))
                  (package-inputs racket-next-minimal))))
     (native-inputs
      `(("libtool" ,libtool)
        ("racket" ,(if (%current-target-system)
                       racket-next-minimal
                       racket-next-minimal-bc-cgc))))
     (arguments
      (substitute-keyword-arguments (package-arguments racket-next-minimal)
        ((#:configure-flags _ '())
         `(list "--enable-bconly"
                ,cfg-flag:enable-racket
                ,cfg-flag:enable-lt
                ,cfg-flag:sh-for-rktio))
        ((#:phases usual-phases)
         `(modify-phases ,usual-phases
            (delete 'unpack-nanopass+stex)
            (delete 'unpack-bootfiles)))))
     (synopsis "Minimal Racket with the BC [3M] runtime system")
     (description "The Racket BC (``before Chez'' or ``bytecode'') implementation was the default before Racket 8.0. It uses a compiler written in C targeting architecture-independent bytecode, plus a JIT compiler on most platforms. Racket BC has a different C API than the newer runtune system (Racket CS) supports a slightly different set of architectures than the current runtime system, Racket CS (based on ``Chez Scheme'').

This packackage is the normal implementation of Racket BC with a precise garbage collector, 3M (``Moving Memory Manager'')."))))

(define-public racket-next-minimal-bc-cgc
  (package/inherit racket-next-minimal-bc-3m
    (name "racket-next-minimal-bc-cgc")
    (native-inputs
     (filter (match-lambda
               (("racket" . _)
                #f)
               (_
                #t))
             (package-native-inputs racket-next-minimal-bc-3m)))
    (arguments
     (substitute-keyword-arguments (package-arguments racket-next-minimal-bc-3m)
       ((#:configure-flags _ '())
        `(list "--enable-cgcdefault"
               ,cfg-flag:enable-lt
               ,cfg-flag:sh-for-rktio))))
    (synopsis "Old Racket implemetation used for bootstapping")
    (description "This variant of the Racket BC (``before Chez'' or ``bytecode'') implementation is not recommended for general use. It uses CGC (a ``Conservative Garbage Collector''), which was succeeded as default in PLT Scheme version 370 (which translates to 3.7 in the current versioning scheme) by the 3M variant, which in turn was succeeded in version 8.0 by the Racket CS implementation.

Racket BC [CGC] is primarily used for bootstrapping Racket BC [3M]. It may also be used for embedding applications without the annotations needed in C code to use the 3M garbage collector.")))

(define-public racket-next-bootstrap-chez-bootfiles
  (hidden-package
   (package/inherit racket-next-minimal
     (name "racket-next-bootstrap-chez-bootfiles")
     (inputs `())
     (native-inputs
      `(("racket" ,(if (%current-target-system)
                       racket-next-minimal
                       racket-next-minimal-bc-3m))
        ("stex" ,@(assoc-ref (package-native-inputs chez-scheme) "stex"))
        ("nanopass" ,@(assoc-ref (package-native-inputs chez-scheme)
                                 "nanopass"))))
     (arguments
      `(#:phases
        (modify-phases %standard-phases
          (add-after 'unpack 'unpack-nanopass+stex
            (lambda* (#:key inputs native-inputs #:allow-other-keys)
              (with-directory-excursion "racket/src/ChezScheme"
                ,unpack-nanopass+stex)))
          (delete 'configure)
          (delete 'patch-generated-file-shebangs)
          (replace 'build
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (with-directory-excursion "racket/src/ChezScheme"
                (invoke (string-append (assoc-ref inputs "racket")
                                       "/bin/racket")
                        "rktboot/main.rkt"
                        "--dest" (assoc-ref outputs "out")))
              #t))
          (delete 'check)
          (delete 'install))))
     (synopsis "Chez Scheme bootfiles bootstrapped by Racket")
     (description "Chez Scheme is a self-hosting compiler: building it requires ``bootfiles'' containing the Scheme-implemented portions compiled for the current platform. (Chez can then cross-compile bootfiles for all other supported platforms.)

The Racket package ``cs-bootstrap'' (part of the main Racket Git repository) implements enough of a Chez Scheme simulation to load the Chez Scheme compiler purely from source into Racket and apply the compiler to itself, thus bootstrapping Chez Scheme. Bootstrapping takes about 10 times as long as using an existing Chez Scheme, but ``cs-bootstap'' supports Racket 7.1 and later, including the Racket BC variant.

Note that the generated bootfiles are specific to Racket's fork of Chez Scheme, and ``cs-bootstrap'' does not currently support building upstream Chez Scheme.")
     (license (package-license chez-scheme)))))


(define %pre-release-installers
  "https://pre-release.racket-lang.org/installers/")

(define %main-repo-main-distribution-pkgs
  ;; These are the packages developed in the main Racket Git repository
  ;; that are part of the main distribution.
  '("at-exp-lib"
    "base"
    "compiler-lib"
    ;; NOT "compiler-test"
    "compiler"
    "net-doc"
    "net-lib"
    ;; NOT "net-test"
    "net"
    ;; NOT "plt-services"
    ;; NOT "racket-benchmarks"
    ;; NOT "racket-build-guide"
    "racket-doc"
    "racket-index"
    "racket-lib"
    ;; NOT "racket-test-core"
    ;; NOT "racket-test-extra"
    ;; NOT "racket-test"
    "zo-lib"))

(define-public racket-next
  (package
    (inherit racket)
    (name "racket-next")
    (version (package-version racket-next-minimal))
    (source
     (origin
       (inherit (package-source racket))
       (sha256
        (base32
         "0ysvzgm0lx4b1p4k9balvcbvh2kapbfx91c9ls80ba062cd8y5qv"))
       (uri (string-append %pre-release-installers
                           "racket-src.tgz"))
       (snippet
        (with-imported-modules '((guix build utils)
                                 (ice-9 match)
                                 (ice-9 regex))
          #~(begin
              (use-modules (guix build utils)
                           (ice-9 match)
                           (ice-9 regex))
              ;; unbundle minimal Racket
              (for-each delete-file-recursively
                        '("collects"
                          "doc"
                          "etc"
                          "README"
                          "src"))
              ;; unbundle package sources included elsewhere
              (with-directory-excursion "share/pkgs"
                (for-each delete-file-recursively
                          '#+%main-repo-main-distribution-pkgs))
              #t)))))
    (inputs
     `(("cairo" ,cairo)
       ("fontconfig" ,fontconfig)
       ("glib" ,glib)
       ("glu" ,glu)
       ("gmp" ,gmp)
       ("gtk+" ,gtk+)                   ; propagates gdk-pixbuf+svg
       ("libjpeg" ,libjpeg-turbo)
       ("libpng" ,libpng)
       ("libx11" ,libx11)
       ("mesa" ,mesa)
       ("mpfr" ,mpfr)
       ("pango" ,pango)
       ("unixodbc" ,unixodbc)
       ("libedit" ,libedit)))
    (native-inputs
     `(("racket" ,racket-next-minimal)
       ("extend-layer" ,extend-layer)
       ("main-repo" ,(package-source racket-next-minimal))))
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-before 'configure 'unpack-packages
           (let ((unpack (assoc-ref %standard-phases 'unpack)))
             (lambda* (#:key  native-inputs inputs outputs #:allow-other-keys)
               (let* ((racket (assoc-ref (or native-inputs inputs) "racket"))
                      (prefix (assoc-ref outputs "out"))
                      (pkgs-dir (string-append prefix "/share/racket/pkgs")))
                 (mkdir-p pkgs-dir)
                 (copy-recursively
                  "share/links.rktd"
                  (string-append prefix "/share/racket/links.rktd"))
                 (copy-recursively "share/pkgs" pkgs-dir)
                 ;; NOTE: unpack changes the working directory
                 (unpack #:source (assoc-ref (or native-inputs inputs)
                                             "main-repo"))
                 (for-each (lambda (pkg)
                             (define dest (string-append pkgs-dir "/" pkg))
                             (mkdir-p dest)
                             (copy-recursively (string-append "pkgs/" pkg)
                                               dest))
                           ',%main-repo-main-distribution-pkgs)
                 #t))))
         (replace 'configure
           (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
             (let ((racket (assoc-ref (or native-inputs inputs) "racket"))
                   (prefix (assoc-ref outputs "out")))
               (apply invoke
                      (string-append racket "/bin/racket")
                      (assoc-ref inputs "extend-layer")
                      racket
                      prefix
                      (map
                       (lambda (lib)
                         (string-append (assoc-ref inputs lib) "/lib"))
                       '("cairo"
                         "fontconfig"
                         "glib"
                         "glu"
                         "gmp"
                         "gtk+"
                         "libjpeg"
                         "libpng"
                         "libx11"
                         "mesa"
                         "mpfr"
                         "pango"
                         "unixodbc"
                         "libedit")))
               #t)))
         (replace 'build
           (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
             (invoke (string-append (assoc-ref (or native-inputs inputs)
                                               "racket")
                                    "/bin/racket")
                     "--config"
                     (string-append (assoc-ref outputs "out")
                                    "/etc/racket")
                     "-l"
                     "raco"
                     "setup")
             #t))
         ;; we still don't have these:
         (delete 'install))
       #:tests? #f))))

(define extend-layer
  (scheme-file
   "extend-layer.rkt"
   `(module
     extend-layer racket/base
     (require racket/cmdline
              racket/match
              racket/file
              racket/list
              racket/pretty)
     (define config-file-pth
       "etc/racket/config.rktd")
     (define (build-path-string . args)
       (path->string (apply build-path args)))
     (define rx:racket
       ;; Guile's reader doesn't support #rx"racket"
       (regexp "racket"))
     (command-line
      #:args (parent-layer prefix . lib-dir*)
      (let* ([config
              (for/fold
               ([config (file->value (build-path parent-layer
                                                 config-file-pth))])
               ([spec (in-list
                       '((lib-dir lib-search-dirs "lib/racket")
                         (share-dir share-search-dirs "share/racket")
                         (links-file
                          links-search-files
                          "share/racket/links.rktd")
                         (pkgs-dir pkgs-search-dirs "share/racket/pkgs")
                         (bin-dir bin-search-dirs "bin")
                         (man-dir man-search-dirs "share/man")
                         (doc-dir doc-search-dirs "share/doc/racket")
                         (include-dir
                          include-search-dirs
                          "include/racket")))])
               (match-define (list main-key search-key pth) spec)
               (hash-set*
                config
                main-key
                (build-path-string prefix pth)
                search-key
                (list* #f
                       (hash-ref config
                                 main-key
                                 (build-path-string parent-layer pth))
                       (filter values (hash-ref config search-key null)))))]
             [config
              (hash-set config
                        'apps-dir
                        (build-path-string prefix "share/applications"))]
             [config
              ;; place new foreign lib-search-dirs before old
              ;; foreign dirs, but after Racket layers
              (let-values
                  ([(rkt extra)
                    (partition (lambda (pth)
                                 (or (not pth)
                                     (regexp-match? rx:racket pth)))
                               (hash-ref config 'lib-search-dirs))])
                (hash-set config
                          'lib-search-dirs
                          (append rkt
                                  lib-dir*
                                  extra)))]
             [bin-dir
              (hash-ref config 'bin-dir)]
             [config
              (hash-set* config
                         'config-tethered-console-bin-dir bin-dir
                         'config-tethered-gui-bin-dir bin-dir)]
             [new-config-pth
              (build-path prefix config-file-pth)])
        (make-parent-directory* new-config-pth)
        (call-with-output-file*
         new-config-pth
         (lambda (out)
           (pretty-write config out))))))))

debug log:

solving 4e2d498364 ...
found 4e2d498364 in https://yhetil.org/guix/20210629215742.3112654-4-philip@philipmcgrath.com/
found cf0240be5c in https://yhetil.org/guix/20210629215742.3112654-3-philip@philipmcgrath.com/
found 363f19825b in https://yhetil.org/guix/20210629215742.3112654-2-philip@philipmcgrath.com/
found d0cfed7292 in https://yhetil.org/guix/20210629215742.3112654-1-philip@philipmcgrath.com/
found 2d606071fe in https://git.savannah.gnu.org/cgit/guix.git
preparing index
index prepared:
100644 2d606071fe026e9b268d20897bb0aa8b6be69bb5	gnu/packages/racket.scm

applying [1/4] https://yhetil.org/guix/20210629215742.3112654-1-philip@philipmcgrath.com/
diff --git a/gnu/packages/racket.scm b/gnu/packages/racket.scm
index 2d606071fe..d0cfed7292 100644


applying [2/4] https://yhetil.org/guix/20210629215742.3112654-2-philip@philipmcgrath.com/
diff --git a/gnu/packages/racket.scm b/gnu/packages/racket.scm
index d0cfed7292..363f19825b 100644


applying [3/4] https://yhetil.org/guix/20210629215742.3112654-3-philip@philipmcgrath.com/
diff --git a/gnu/packages/racket.scm b/gnu/packages/racket.scm
index 363f19825b..cf0240be5c 100644


applying [4/4] https://yhetil.org/guix/20210629215742.3112654-4-philip@philipmcgrath.com/
diff --git a/gnu/packages/racket.scm b/gnu/packages/racket.scm
index cf0240be5c..4e2d498364 100644

Checking patch gnu/packages/racket.scm...
Applied patch gnu/packages/racket.scm cleanly.
Checking patch gnu/packages/racket.scm...
Applied patch gnu/packages/racket.scm cleanly.
Checking patch gnu/packages/racket.scm...
Applied patch gnu/packages/racket.scm cleanly.
Checking patch gnu/packages/racket.scm...
Applied patch gnu/packages/racket.scm cleanly.

index at:
100644 4e2d498364edb243f2e8a3411d0228955d0f4dea	gnu/packages/racket.scm

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.