Subject: [bug#53878] [PATCH v6 06/24] gnu: racket-minimal: Change inheritance to follow bootstrapping.

From: Philip McGrath <[email-masked]>
Date: Sat, 26 Feb 2022 21:34:32 -0500

Having the package inheritance chain go in the same direction as the
bootstrapping chain, rather than the opposite, is less confusing. In
some cases, it can also help to avoid unnecessary rebuilds.

* gnu/packages/racket.scm (racket-minimal-bc-cgc): Change to be the root
of the package inheritance chain.
[version, source, inputs, native-inputs, build-system, arguments,
home-page, license]: Inline formerly inherited values.
(racket-minimal-bc-3m): Inherit from 'racket-minimal-bc-cgc' rather than
'racket-minimal'.
[inputs, native-inputs, arguments, license]: Adjust accordingly.
(racket-minimal): Inherit from 'racket-minimal-bc-3m'.
[inputs, native-inputs, arguments, license]: Adjust accordingly.
[properties]: Override effect of 'hidden-package'.
---
 gnu/packages/racket.scm | 130 +++++++++++++++++++++-------------------
 1 file changed, 67 insertions(+), 63 deletions(-)

diff --git a/gnu/packages/racket.scm b/gnu/packages/racket.scm
index b828bbbd3d..00f4fef49f 100644
--- a/gnu/packages/racket.scm
+++ b/gnu/packages/racket.scm
@@ -2,7 +2,7 @@
 ;;; Copyright © 2013, 2014, 2015, 2016, 2018, 2020, 2021 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice <[email-masked]>
 ;;; Copyright © 2020 Pierre Neidhardt <[email-masked]>
-;;; Copyright © 2021 Philip McGrath <[email-masked]>
+;;; Copyright © 2021, 2022 Philip McGrath <[email-masked]>
 ;;; Copyright © 2021 jgart <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -172,9 +172,9 @@ (define (make-unpack-nanopass+stex)
           (display "# to placate ../configure")))))

-(define-public racket-minimal
+(define-public racket-minimal-bc-cgc
   (package
-    (name "racket-minimal")
+    (name "racket-minimal-bc-cgc")
     (version %racket-version)
     (source %racket-origin)
     (inputs
@@ -184,19 +184,14 @@ (define-public racket-minimal
       sqlite
       bash-minimal ;; <- for `system`
       ncurses ;; <- for #%terminal
-      ;; only for CS
-      zlib
-      lz4))
-    (native-inputs
-     (list chez-scheme-for-racket-bootstrap-bootfiles
-           racket-minimal-bc-3m))
+      ;; only for BC variants:
+      libffi))
+    (native-inputs (list libtool)) ;; <- only for BC variants
     (build-system gnu-build-system)
     (arguments
      (list
       #:configure-flags
-      #~(cons* "--enable-csonly"
-               "--enable-libz"
-               "--enable-lz4"
+      #~(cons* "--enable-cgcdefault"
                #$(racket-vm-common-configure-flags))
       ;; Tests are in packages like racket-test-core and
       ;; main-distribution-test that aren't part of the main
@@ -210,17 +205,6 @@ (define-public racket-minimal
                   (guix build utils))
       #:phases
       #~(modify-phases %standard-phases
-          (add-after 'unpack 'unpack-nanopass+stex
-            (lambda args
-              (with-directory-excursion "racket/src/ChezScheme"
-                #$(make-unpack-nanopass+stex))))
-          (add-after 'unpack-nanopass+stex 'unpack-bootfiles
-            (lambda* (#:key native-inputs inputs #:allow-other-keys)
-              (with-directory-excursion "racket/src/ChezScheme"
-                (copy-recursively
-                 (search-input-directory (or native-inputs inputs)
-                                         "lib/chez-scheme-bootfiles")
-                 "boot"))))
           (add-before 'configure 'initialize-config.rktd
             (lambda* (#:key inputs #:allow-other-keys)
               (define (write-racket-hash alist)
@@ -265,43 +249,37 @@ (define maybe-release-catalog
               ;; rmdir because we want an error if it isn't empty
               (rmdir (string-append #$output "/share/racket/pkgs")))))))
     (home-page "https://racket-lang.org")
-    (synopsis "Racket without bundled packages such as DrRacket")
-    (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.
+    (synopsis "Old Racket implementation used for bootstrapping")
+    (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.
 
-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.")
+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.")
     ;; https://download.racket-lang.org/license.html
     ;; The LGPL components are only used by Racket BC.
-    (license (list license:asl2.0 license:expat))))
+    (license (list license:lgpl3+ license:asl2.0 license:expat))
+    ;; Eventually, it may make sense for some vm packages to not be hidden,
+    ;; but this one is especially likely to remain hidden.
+    (properties `((hidden? . #t)))))
 
 (define-public racket-minimal-bc-3m
   (hidden-package
    (package
-     (inherit racket-minimal)
+     (inherit racket-minimal-bc-cgc)
      (name "racket-minimal-bc-3m")
-     (inputs
-      (modify-inputs (package-inputs racket-minimal)
-        (prepend libffi) ;; <- only for BC variants
-        (delete "zlib" "lz4")))
      (native-inputs
-      (list libtool
-            (if (%current-target-system)
-                racket-minimal
-                racket-minimal-bc-cgc)))
+      (modify-inputs (package-native-inputs racket-minimal-bc-cgc)
+        (prepend racket-minimal-bc-cgc)))
      (arguments
-      (substitute-keyword-arguments (package-arguments racket-minimal)
+      (substitute-keyword-arguments (package-arguments racket-minimal-bc-cgc)
         ((#:configure-flags _ '())
          #~(cons "--enable-bconly"
-                 #$(racket-vm-common-configure-flags)))
-        ((#:phases cs-phases)
-         #~(modify-phases #$cs-phases
-             (delete 'unpack-nanopass+stex)
-             (delete 'unpack-bootfiles)))))
+                 #$(racket-vm-common-configure-flags)))))
      (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
@@ -316,27 +294,53 @@ (define-public racket-minimal-bc-3m
      ;; The LGPL components are only used by Racket BC.
      (license (list license:lgpl3+ license:asl2.0 license:expat)))))
 
-(define-public racket-minimal-bc-cgc
+(define-public racket-minimal
   (package
     (inherit racket-minimal-bc-3m)
-    (name "racket-minimal-bc-cgc")
-    (native-inputs (list libtool))
+    (name "racket-minimal")
+    (inputs
+     (modify-inputs (package-inputs racket-minimal-bc-cgc)
+       (prepend zlib lz4)
+       (delete "libffi")))
+    (native-inputs
+     (modify-inputs (package-native-inputs racket-minimal-bc-cgc)
+       (delete "libtool")
+       (prepend chez-scheme-for-racket-bootstrap-bootfiles
+                racket-minimal-bc-3m)))
     (arguments
      (substitute-keyword-arguments (package-arguments racket-minimal-bc-3m)
+       ((#:phases bc-phases)
+        #~(modify-phases #$bc-phases
+            (add-after 'unpack 'unpack-nanopass+stex
+              (lambda args
+                (with-directory-excursion "racket/src/ChezScheme"
+                  #$(make-unpack-nanopass+stex))))
+            (add-after 'unpack-nanopass+stex 'unpack-bootfiles
+              (lambda* (#:key native-inputs inputs #:allow-other-keys)
+                (with-directory-excursion "racket/src/ChezScheme"
+                  (copy-recursively
+                   (search-input-directory (or native-inputs inputs)
+                                           "lib/chez-scheme-bootfiles")
+                   "boot"))))))
        ((#:configure-flags _ '())
-        #~(cons "--enable-cgcdefault"
-                #$(racket-vm-common-configure-flags)))))
-    (synopsis "Old Racket implementation used for bootstrapping")
-    (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.
+        #~(cons* "--enable-csonly"
+                 "--enable-libz"
+                 "--enable-lz4"
+                 #$(racket-vm-common-configure-flags)))))
+    (synopsis "Racket without bundled packages such as DrRacket")
+    (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.
 
-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.")))
+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.")
+    (properties `())
+    ;; https://download.racket-lang.org/license.html
+    ;; The LGPL components are only used by Racket BC.
+    (license (list license:asl2.0 license:expat))))
 
 (define-public chez-scheme-for-racket-bootstrap-bootfiles
   (package
-- 
2.32.0