Subject: Re: [PATCH v6 03/24] gnu: racket: Use Git origins for Racket packages.

From: Liliana Marie Prikler <[email-masked]>
Date: Sun, 27 Feb 2022 09:42:46 +0100

Hi,

Am Samstag, dem 26.02.2022 um 21:34 -0500 schrieb Philip McGrath:
> * gnu/packages/patches/racket-gui-tethered-launcher-backport.patch:
> Adjust path.
> * gnu/packages/racket.scm (racket-packages-origin,
> simple-racket-origin): New procedures.
> (extend-layer): Rename to ...
> (configure-layer.rkt): ... this variable. Tweak command-line
> arguments. Adapt to 'config-tethered-apps-dir'.
> (racket): Stop inheriting from 'racket-minimal'.
> [version]: Use '%racket-version'.
> [source]: Stop using bundled tarball.
> [inputs]: Remove labels. Add 'racket-minimal' and package sources.
> [native-inputs]: Remove, since cross-compilation doesn't work yet.
> [arguments]: Rewrite to use G-expressions, package sources from
> 'inputs', an explicit 'install' phase, and the revised
> 'configure-layer.rkt'.
> ---
>  ...acket-gui-tethered-launcher-backport.patch |   6 +-
>  gnu/packages/racket.scm                       | 714 +++++++++++++---
> --
>  2 files changed, 539 insertions(+), 181 deletions(-)
> 
> diff --git a/gnu/packages/patches/racket-gui-tethered-launcher-
> backport.patch b/gnu/packages/patches/racket-gui-tethered-launcher-
> backport.patch
> index abf253486f..1e018eaa79 100644
> --- a/gnu/packages/patches/racket-gui-tethered-launcher-
> backport.patch
> +++ b/gnu/packages/patches/racket-gui-tethered-launcher-
> backport.patch
> @@ -7,13 +7,13 @@ Related to racket/racket#4133
>  
>  (cherry picked from commit 563c68432f127729592f234ef30c31e92618b517)
>  ---
> - share/pkgs/gui-lib/mred/installer.rkt | 3 ++-
> + gui-lib/mred/installer.rkt | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>  
>  diff --git a/gui-lib/mred/installer.rkt b/gui-lib/mred/installer.rkt
>  index b1691472..9ef06c53 100644
> ---- a/share/pkgs/gui-lib/mred/installer.rkt
> -+++ b/share/pkgs/gui-lib/mred/installer.rkt
> +--- a/gui-lib/mred/installer.rkt
> ++++ b/gui-lib/mred/installer.rkt
>  @@ -72,4 +72,5 @@
>      (list "-A" (path->string (find-system-path 'addon-dir)))))
>   
> diff --git a/gnu/packages/racket.scm b/gnu/packages/racket.scm
> index 00ec587eeb..c4e5ee1311 100644
> --- a/gnu/packages/racket.scm
> +++ b/gnu/packages/racket.scm
> @@ -28,7 +28,9 @@ (define-module (gnu packages racket)
>    #:use-module (guix gexp)
>    #:use-module (guix build-system gnu)
>    #:use-module (srfi srfi-1)
> +  #:use-module (srfi srfi-26)
>    #:use-module (ice-9 match)
> +  #:use-module (ice-9 exceptions)
>    #:use-module (gnu packages)
>    #:use-module (gnu packages autotools)
>    #:use-module (gnu packages bash)
> @@ -389,172 +391,504 @@ (define-public racket-bootstrap-chez-
> bootfiles
>  Chez Scheme.")
>       (license (list license:asl2.0)))))
>  
> +(define (racket-packages-origin name origin spec0 . spec*)
> +  "Extract from ORIGIN the sources for the Racket packages specified
> by SPEC0
> +and any additional arguments SPEC*.  In the resulting file-like
> object, each
> +package's source will be in the directory
> \"/share/racket/pkgs/PKG/\", where
> +PKG is the Racket name for the package.  The NAME will be used in
> the store
> +file name for the resulting file-like object.
>  
> -(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/"
> -    ))
> +A package specification is a list of the form:
>  
> -(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"))
> +  (PKG PATH)
>  
> +where PATH is the path to the package source relative to ORIGIN---
> possibly
> +\".\".  As a special case, a package specification may also be a
> string, which
> +is equivalent to:
> +
> +  (PKG PKG)
> +
> +Examples:
> +
> +- \"expeditor\"
> +- (\"main-distribution\" \".\")
> +- (\"racket-lib\" \"pkgs/racket-lib\")"
> +  (computed-file
> +   (string-append "racket-pkg-" name "-sources")
> +   (with-imported-modules `((guix build utils))
> +     #~(begin
> +         (use-modules (guix build utils))
> +         (mkdir-p (string-append #$output "/share/racket/pkgs"))
> +         (chdir (string-append #$output "/share/racket/pkgs"))
> +         #$@(map (match-lambda
> +                   ((? string? name)
> +                    #~(copy-recursively #$(file-append origin
> (string-append "/" name))
> +                                        #$name))
> +                   ((name ".")
> +                    #~(copy-recursively #$origin #$name))
> +                   ((name path)
> +                    #~(copy-recursively #$(file-append origin
> (string-append "/" path))
> +                                        #$name)))
> +                 (cons spec0 spec*))))))
Perhaps I wasn't clear enough about this in v5, but I think spec should
be a single argument rather than multiple ones.  This way, if we do
find that we need to extend it to support an additional argument, we
don't have to awkwardly code around the #:rest.

> +(define (simple-racket-origin repo hash spec0 . spec*)
> +  "Like 'racket-packages-origin', but specialized for packages
> hosted at
> +\"https://github.com/racket/REPO\" with sha256 checksum HASH.  REPO
> is also
> +used to build the name of the resulting store item."
> +  (apply racket-packages-origin
> +         repo
> +         (origin
> +           (method git-fetch)
> +           (uri (git-reference
> +                 (url (format #f "https://github.com/racket/~a"
> repo))
> +                 (commit %racket-commit)))
> +           (sha256 hash)
> +           (file-name (git-file-name (string-append "racket-" repo)
> +                                     %racket-version)))
> +         spec0
> +         spec*))
Same here, plus it saves us the trouble of a additional "apply".

The effect for 
> +      (simple-racket-origin
> +       "2d" (base32
> "1zzcz5qyjv7syi41vb8jkxjp1rqgj61zbsdrg0nlc4qy9qsafzgr")
> +       "2d" "2d-doc" "2d-lib")
would be that '("2d" "2d-doc" "2d-lib") is more clearly delimited from
the package name and hash, and

> +      (racket-packages-origin
> +       "racket" %racket-origin
> +       '("base" "pkgs/base") ;; FIXME belongs in racket-minimal
> +       '("racket-lib" "pkgs/racket-lib") ;; FIXME belongs in racket-
> minimal
> +       '("at-exp-lib" "pkgs/at-exp-lib")
> +       '("compiler" "pkgs/compiler")
> +       '("compiler-lib" "pkgs/compiler-lib")
> +       '("net" "pkgs/net")
> +       '("net-doc" "pkgs/net-doc")
> +       '("net-lib" "pkgs/net-lib")
> +       '("racket-doc" "pkgs/racket-doc")
> +       '("racket-index" "pkgs/racket-index")
> +       '("sandbox-lib" "pkgs/sandbox-lib")
> +       '("zo-lib" "pkgs/zo-lib"))
'(("base" "pkgs/base") ("racket-lib" "pkgs/racket-lib") ...)
needs less quoting over-all.

> +      (simple-racket-origin
> +       "class-iop" (base32
> "08z57q83cr7wnh6g8ah3hdhmsmf9zp1jfs7yvxv188l3hzvygy5l")
> +       "class-iop-lib")
While single strings like this do each cost three additional characters
that way, I wouldn't special-case them.

Cheers