diff mbox series

[bug#53878,v5,03/22] gnu: racket: Use Git origins for Racket packages.

Message ID 20220226130254.1301333-4-philip@philipmcgrath.com
State Accepted
Headers show
Series Update Racket to 8.4. Adjust Chez Scheme packages. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Philip McGrath Feb. 26, 2022, 1:02 p.m. UTC
* gnu/packages/patches/racket-gui-tethered-launcher-backport.patch:
Adjust path.
* gnu/packages/racket.scm (extract-package-source,
extract-package-source*): New procedures.
(extend-layer): Rename to ...
(make-installation-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
'make-installation-layer.rkt'.
---
 ...acket-gui-tethered-launcher-backport.patch |    6 +-
 gnu/packages/racket.scm                       | 1151 ++++++++++++++---
 2 files changed, 975 insertions(+), 182 deletions(-)

Comments

Liliana Marie Prikler Feb. 26, 2022, 1:47 p.m. UTC | #1
Am Samstag, dem 26.02.2022 um 08:02 -0500 schrieb Philip McGrath:
> * gnu/packages/patches/racket-gui-tethered-launcher-backport.patch:
> Adjust path.
> * gnu/packages/racket.scm (extract-package-source,
> extract-package-source*): New procedures.
> (extend-layer): Rename to ...
> (make-installation-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
> 'make-installation-layer.rkt'.
Since you haven't made this a union-build yet, I will from now on
assume that it is indeed more complicated than one to save us some time
debating whether it should or shouldn't be.  Given that this was my
main complaint w.r.t. the stuff following make-installation-layer, much
is now resolved, except for two things.

First, can we simplify "make-installation-layer.rkt" to "make-
installation-layer"?  I don't think the file extension conveys much
meaning here, or does it?

Second, can we find an abbreviation for
> +      (extract-package-source*
> +       `((,(origin
> +             (method git-fetch)
> +             (uri (git-reference
> +                   (url "https://github.com/racket/2d")
> +                   (commit %racket-commit)))
> +             (sha256 (base32
> +                     
> "1zzcz5qyjv7syi41vb8jkxjp1rqgj61zbsdrg0nlc4qy9qsafzgr"))
> +             (file-name
> +              (git-file-name "racket-2d" %racket-version)))
> +          "2d" "2d-doc" "2d-lib")
> +         (,(origin
> +             (method git-fetch)
> +             (uri (git-reference
> +                   (url "https://github.com/racket/algol60")
> +                   (commit %racket-commit)))
> +             (sha256 (base32
> +                     
> "09kj6asypmc24n29w0izc9p0q8hpga2hpkchsypfwn5c8zpvihlx"))
> +             (file-name
> +              (git-file-name "racket-algol60" %racket-version)))
> +          ("algol60" "."))
> +         (,%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"))
> +         (,(origin
> +             (method git-fetch)
> +             (uri (git-reference
> +                   (url "https://github.com/racket/cext-lib")
> +                   (commit %racket-commit)))
> +             (sha256 (base32
> +                     
> "00w38jpv88fpl4pgj6ndnysvn0s21rjvj0xhznay80msan0vc341"))
> +             (file-name (git-file-name "racket-cext-lib" %racket-
> version)))
> +          "cext-lib" "dynext-lib")
> [...]
I think some way to shorten those origins would do wonders in terms of
the number of lines this patch adds.


Other than that, looks pretty good to me.
Philip McGrath Feb. 26, 2022, 2:20 p.m. UTC | #2
Hi,

On Saturday, February 26, 2022 8:47:45 AM EST Liliana Marie Prikler wrote:
> First, can we simplify "make-installation-layer.rkt" to "make-
> installation-layer"?  I don't think the file extension conveys much
> meaning here, or does it?

To me (I don't know about anyone else), the ".rtk" extension tells me that I 
have to pass the file as an argument to `racket`, i.e. that the file is not a 
launcher from `raco exe` or a script with a shebang that I could `invoke` 
directly.

> 
> Second, can we find an abbreviation for
> 
> > +      (extract-package-source*
> > +       `((,(origin
> > +             (method git-fetch)
> > +             (uri (git-reference
> > +                   (url "https://github.com/racket/2d")
> > +                   (commit %racket-commit)))
> > +             (sha256 (base32
> > +                     
> > "1zzcz5qyjv7syi41vb8jkxjp1rqgj61zbsdrg0nlc4qy9qsafzgr"))
> > +             (file-name
> > +              (git-file-name "racket-2d" %racket-version)))
> > +          "2d" "2d-doc" "2d-lib")
> > +         (,(origin
> > +             (method git-fetch)
> > +             (uri (git-reference
> > +                   (url "https://github.com/racket/algol60")
> > +                   (commit %racket-commit)))
> > +             (sha256 (base32
> > +                     
> > "09kj6asypmc24n29w0izc9p0q8hpga2hpkchsypfwn5c8zpvihlx"))
> > +             (file-name
> > +              (git-file-name "racket-algol60" %racket-version)))
> > +          ("algol60" "."))
> > +         (,%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"))
> > +         (,(origin
> > +             (method git-fetch)
> > +             (uri (git-reference
> > +                   (url "https://github.com/racket/cext-lib")
> > +                   (commit %racket-commit)))
> > +             (sha256 (base32
> > +                     
> > "00w38jpv88fpl4pgj6ndnysvn0s21rjvj0xhznay80msan0vc341"))
> > +             (file-name (git-file-name "racket-cext-lib" %racket-
> > version)))
> > +          "cext-lib" "dynext-lib")
> > [...]
> 
> I think some way to shorten those origins would do wonders in terms of
> the number of lines this patch adds.
> 

At one point, I had abbreviated the origins as something like:

  (REPO-SPEC SHA256 [COMMIT])

where REPO-SPEC is one of:

  (GITHUB-OWNER GITHUB-REPO)
  ; ^ e.g. for https://github.com/RenaissanceBug/racket-cookies
  GITHUB-REPO ; "racket" is owner

and COMMIT defaults to `%racket-commit`, but could be overridden for
<https://github.com/racket/srfi>.

I think I'd given SHA256 as a literal string, but it could be e.g.:

  (extract-package-source*
    `((("2d" ,(base32 "1zzcz5qyjv7syi41vb8jkxjp1rqgj61zbsdrg0nlc4qy9qsafzgr"))
       "2d" "2d-doc" "2d-lib")
      ...))

if that seems better.

I wasn't sure about the trade-off between being slightly more cryptic than 
explicit origins, but a lot shorter.

-Philip
Liliana Marie Prikler Feb. 26, 2022, 2:26 p.m. UTC | #3
Hi, 

Am Samstag, dem 26.02.2022 um 09:20 -0500 schrieb Philip McGrath:
> Hi,
> 
> On Saturday, February 26, 2022 8:47:45 AM EST Liliana Marie Prikler
> wrote:
> > First, can we simplify "make-installation-layer.rkt" to "make-
> > installation-layer"?  I don't think the file extension conveys much
> > meaning here, or does it?
> 
> To me (I don't know about anyone else), the ".rtk" extension tells me
> that I  have to pass the file as an argument to `racket`, i.e. that
> the file is not a launcher from `raco exe` or a script with a shebang
> that I could `invoke` directly.
I'm not talking about the generated file, but the procedure that
generates it.  Special characters like dots and slash are still pretty
special in Scheme, even if they're allowed as identifiers.

> > I think some way to shorten those origins would do wonders in terms
> > of the number of lines this patch adds.
> > 
> 
> At one point, I had abbreviated the origins as something like:
> 
>   (REPO-SPEC SHA256 [COMMIT])
> 
> where REPO-SPEC is one of:
> 
>   (GITHUB-OWNER GITHUB-REPO)
>   ; ^ e.g. for https://github.com/RenaissanceBug/racket-cookies
>   GITHUB-REPO ; "racket" is owner
> 
> and COMMIT defaults to `%racket-commit`, but could be overridden for
> <https://github.com/racket/srfi>.
> 
> I think I'd given SHA256 as a literal string, but it could be e.g.:
> 
>   (extract-package-source*
>     `((("2d" ,(base32
> "1zzcz5qyjv7syi41vb8jkxjp1rqgj61zbsdrg0nlc4qy9qsafzgr"))
>        "2d" "2d-doc" "2d-lib")
>       ...))
I wouldn't do this inside of extract-package-source, but define a one
or two liner for adding specifically packages hosted on racket's
github.  WDYT?

> I wasn't sure about the trade-off between being slightly more cryptic
> than explicit origins, but a lot shorter.
Note that the goal is not to code golf, but to be understandable.  When
adding a bunch of origins as inputs, understandability suffers by
induced scrolling.

Cheers
Philip McGrath Feb. 26, 2022, 5:23 p.m. UTC | #4
Hi,

On Saturday, February 26, 2022 9:26:29 AM EST Liliana Marie Prikler wrote:
> Am Samstag, dem 26.02.2022 um 09:20 -0500 schrieb Philip McGrath:
> > On Saturday, February 26, 2022 8:47:45 AM EST Liliana Marie Prikler
> > 
> > wrote:
> > > First, can we simplify "make-installation-layer.rkt" to "make-
> > > installation-layer"?  I don't think the file extension conveys much
> > > meaning here, or does it?
> > 
> > To me (I don't know about anyone else), the ".rtk" extension tells me
> > that I  have to pass the file as an argument to `racket`, i.e. that
> > the file is not a launcher from `raco exe` or a script with a shebang
> > that I could `invoke` directly.
> 
> I'm not talking about the generated file, but the procedure that
> generates it.  Special characters like dots and slash are still pretty
> special in Scheme, even if they're allowed as identifiers.
> 

Do you mean A, B, C, and/or D of these:
a
>           (replace 'configure
>             (lambda* (#:key inputs configure-flags #:allow-other-keys)
>               (let* ((racket (search-input-file inputs "bin/racket")))
>                 (apply invoke
>                        racket
>                        #$make-installation-layer.rkt ;; <--- A
>                        `(,@configure-flags
>                          ,(dirname (dirname racket))
>                          ,#$output))
>                 (invoke racket
>                         "--config" (string-append #$output "/etc/racket")
>                         "-l" "raco" "setup"
>                         "--no-user"))))
>
> [...]
> 
> (define make-installation-layer.rkt ;; <--- B
>   (scheme-file
>    "make-installation-layer.rkt" ;; <--- C
>    `(module
>      make-installation-layer racket/base ;; <--- D
>      (require racket/cmdline

or something else?

In particular, not to be dense, but B is not a function. 

One of the reasons I particularly like being able to use `.` in identifiers is 
to refer to files by name, without some ad-hoc encoding.

> > > I think some way to shorten those origins would do wonders in terms
> > > of the number of lines this patch adds.
> > 
> > At one point, I had abbreviated the origins as something like:
> > 
> >   (REPO-SPEC SHA256 [COMMIT])
> > 
> > [...]
> 
> I wouldn't do this inside of extract-package-source, but define a one
> or two liner for adding specifically packages hosted on racket's
> github.  WDYT?
> 
> > I wasn't sure about the trade-off between being slightly more cryptic
> > than explicit origins, but a lot shorter.
> 
> Note that the goal is not to code golf, but to be understandable.  When
> adding a bunch of origins as inputs, understandability suffers by
> induced scrolling.
> 

I've done this, and it was a very good idea. In particular, it helped find 
some places where I hadn't switched to using `%racket-commit` once the release 
was tagged.

Other than potentially doing something about "make-installation-layer.rkt", 
I'd plan to squash the WIP/FIXUP commits in
<https://gitlab.com/philip1/guix-patches/-/tree/racket-chez-refactor-hist-28>
and send it as v6.

-Philip
Liliana Marie Prikler Feb. 26, 2022, 6:30 p.m. UTC | #5
Hi,

Am Samstag, dem 26.02.2022 um 12:23 -0500 schrieb Philip McGrath:
> Hi,
> 
> On Saturday, February 26, 2022 9:26:29 AM EST Liliana Marie Prikler
> wrote:
> > I'm not talking about the generated file, but the procedure that
> > generates it.  Special characters like dots and slash are still
> > pretty special in Scheme, even if they're allowed as identifiers.
> 
> Do you mean A, B, C, and/or D of these:
> a
> >           (replace 'configure
> >             (lambda* (#:key inputs configure-flags #:allow-other-
> > keys)
> >               (let* ((racket (search-input-file inputs
> > "bin/racket")))
> >                 (apply invoke
> >                        racket
> >                        #$make-installation-layer.rkt ;; <--- A
> >                        `(,@configure-flags
> >                          ,(dirname (dirname racket))
> >                          ,#$output))
> >                 (invoke racket
> >                         "--config" (string-append #$output
> > "/etc/racket")
> >                         "-l" "raco" "setup"
> >                         "--no-user"))))
> > 
> > [...]
> > 
> > (define make-installation-layer.rkt ;; <--- B
> >   (scheme-file
> >    "make-installation-layer.rkt" ;; <--- C
> >    `(module
> >      make-installation-layer racket/base ;; <--- D
> >      (require racket/cmdline
> 
> or something else?
The name in B is confusing imo, because it implies a procedure when it
is in fact a file.  Of course, that'd affect A as well.  The file name
in C does not matter too much, but should probably be matched with B to
some extent (but importantly keeping the .rkt extension even if we drop
it from B).  I'm not sure if D is a function call or not, but if it's a
module name perhaps we should make it match B.

Given that we pass configure-flags to this thing, how about "configure-
racket-layer", "configure-layer.rkt" or something along those lines?

> In particular, not to be dense, but B is not a function. 
Yeah, that's my bad for only skimming these and not paying too close
attention to brackets.  The name itself implies a function, hence my
confusion.  Looking at things closely would make me see more typos like
";; workaroung Guile reader/printer:"
workaround.

> One of the reasons I particularly like being able to use `.` in
> identifiers is to refer to files by name, without some ad-hoc
> encoding.
I do admit that is helpful, but in this context, metaphors were mixed
in a way that conveyed the wrong message.

> > > > I think some way to shorten those origins would do wonders in
> > > > terms
> > > > of the number of lines this patch adds.
> > > 
> > > At one point, I had abbreviated the origins as something like:
> > > 
> > >   (REPO-SPEC SHA256 [COMMIT])
> > > 
> > > [...]
> > 
> > I wouldn't do this inside of extract-package-source, but define a
> > one or two liner for adding specifically packages hosted on
> > racket's github.  WDYT?
> > 
> > > I wasn't sure about the trade-off between being slightly more
> > > cryptic
> > > than explicit origins, but a lot shorter.
> > 
> > Note that the goal is not to code golf, but to be understandable. 
> > When adding a bunch of origins as inputs, understandability suffers
> > by induced scrolling.
> > 
> 
> I've done this, and it was a very good idea. In particular, it helped
> find some places where I hadn't switched to using `%racket-commit`
> once the release was tagged.
That is better, but can still be improved.  As hinted at in my comment
to your tree, origin snippets might be a better solution here unless
I'm missing something in the heat of the moment.

> Other than potentially doing something about "make-installation-
> layer.rkt", 
> I'd plan to squash the WIP/FIXUP commits in
> <
> https://gitlab.com/philip1/guix-patches/-/tree/racket-chez-refactor-hist-28
> >
> and send it as v6.
I did have a short look at it and apart from the above comment it
appears fine, but I'll have to reevaluate it when it's a full v6
anyway.

Cheers
Philip McGrath Feb. 26, 2022, 7:55 p.m. UTC | #6
On Saturday, February 26, 2022 1:30:08 PM EST Liliana Marie Prikler wrote:
> Hi,
> 
> Am Samstag, dem 26.02.2022 um 12:23 -0500 schrieb Philip McGrath:
> > Hi,
> > 
> > On Saturday, February 26, 2022 9:26:29 AM EST Liliana Marie Prikler
> > 
> > wrote:
> > > I'm not talking about the generated file, but the procedure that
> > > generates it.  Special characters like dots and slash are still
> > > pretty special in Scheme, even if they're allowed as identifiers.
> > 
> > Do you mean A, B, C, and/or D of these:
> > a
> > 
> > >           (replace 'configure
> > >             (lambda* (#:key inputs configure-flags #:allow-other-
> > > keys)
> > >               (let* ((racket (search-input-file inputs
> > > "bin/racket")))
> > >                 (apply invoke
> > >                        racket
> > >                        #$make-installation-layer.rkt ;; <--- A
> > >                        `(,@configure-flags
> > >                          ,(dirname (dirname racket))
> > >                          ,#$output))
> > >                 (invoke racket
> > >                         "--config" (string-append #$output
> > > "/etc/racket")
> > >                         "-l" "raco" "setup"
> > >                         "--no-user"))))
> > > 
> > > [...]
> > > 
> > > (define make-installation-layer.rkt ;; <--- B
> > >   (scheme-file
> > >    "make-installation-layer.rkt" ;; <--- C
> > >    `(module
> > >      make-installation-layer racket/base ;; <--- D
> > >      (require racket/cmdline
> > 
> > or something else?
> 
> The name in B is confusing imo, because it implies a procedure when it
> is in fact a file.  Of course, that'd affect A as well.  The file name
> in C does not matter too much, but should probably be matched with B to
> some extent (but importantly keeping the .rkt extension even if we drop
> it from B).  I'm not sure if D is a function call or not, but if it's a
> module name perhaps we should make it match B.
> 
> Given that we pass configure-flags to this thing, how about "configure-
> racket-layer", "configure-layer.rkt" or something along those lines?
> 

"configure-layer.rkt" seems fine. I do see the potential for confusion about 
whether this was "making" an "installation-layer.rkt".

(D is a module name and should for clarity match C without the suffix. 
Ultimately, for a module that is not a submodule, it is ignored and the name 
comes from context. This is an older way of writing modules that predates 
"#lang" (which would be inconvenient with `scheme-file`). Calling `read` with 
the appropriate parameters on the input "#lang racket/base 42" would produce 
the datum `(module anonymous-module racket/base (#%module-begin 42))`.)

> > In particular, not to be dense, but B is not a function.
> 
> Yeah, that's my bad for only skimming these and not paying too close
> attention to brackets.  The name itself implies a function, hence my
> confusion.  Looking at things closely would make me see more typos like
> ";; workaroung Guile reader/printer:"
> workaround.
> 

Thanks.

> > > > > I think some way to shorten those origins would do wonders in
> > > > > terms
> > > > > of the number of lines this patch adds.
> > > > 
> > > > At one point, I had abbreviated the origins as something like:
> > > > 
> > > >   (REPO-SPEC SHA256 [COMMIT])
> > > > 
> > > > [...]
> > > 
> > > I wouldn't do this inside of extract-package-source, but define a
> > > one or two liner for adding specifically packages hosted on
> > > racket's github.  WDYT?
> > > 
> > > > I wasn't sure about the trade-off between being slightly more
> > > > cryptic
> > > > than explicit origins, but a lot shorter.
> > > 
> > > Note that the goal is not to code golf, but to be understandable. 
> > > When adding a bunch of origins as inputs, understandability suffers
> > > by induced scrolling.
> > 
> > I've done this, and it was a very good idea. In particular, it helped
> > find some places where I hadn't switched to using `%racket-commit`
> > once the release was tagged.
> 
> That is better, but can still be improved.  As hinted at in my comment
> to your tree, origin snippets might be a better solution here unless
> I'm missing something in the heat of the moment.

Could you give an example of what you imagine the result might look like in 
use? E.g. (but I'm not sure this would really be an improvement):

> (cons*
>  ...
>  libedit
>  racket-minimal
>  (append
>   (racket-package-sources
>    "2d" (base32 "1zzcz5qyjv7syi41vb8jkxjp1rqgj61zbsdrg0nlc4qy9qsafzgr")
>    "2d" "2d-doc" "2d-lib")
>   (racket-package-sources
>    "algol60" (base32 "09kj6asypmc24n29w0izc9p0q8hpga2hpkchsypfwn5c8zpvihlx")
>    '("algol60" "."))
>   ...))

-Philip
Liliana Marie Prikler Feb. 26, 2022, 9:09 p.m. UTC | #7
Hi,

Am Samstag, dem 26.02.2022 um 14:55 -0500 schrieb Philip McGrath:
> "configure-layer.rkt" seems fine. I do see the potential for confusion
> about whether this was "making" an "installation-layer.rkt".
configure-layer.rkt it is then :)


> > > > > > I think some way to shorten those origins would do wonders in
> > > > > > terms of the number of lines this patch adds.
> > > > > 
> > > > > At one point, I had abbreviated the origins as something like:
> > > > > 
> > > > >   (REPO-SPEC SHA256 [COMMIT])
> > > > > 
> > > > > [...]
> > > > 
> > > > I wouldn't do this inside of extract-package-source, but define a
> > > > one or two liner for adding specifically packages hosted on
> > > > racket's github.  WDYT?
> > > > 
> > > > > I wasn't sure about the trade-off between being slightly more
> > > > > cryptic
> > > > > than explicit origins, but a lot shorter.
> > > > 
> > > > Note that the goal is not to code golf, but to be understandable.
> > > > When adding a bunch of origins as inputs, understandability
> > > > suffers
> > > > by induced scrolling.
> > > 
> > > I've done this, and it was a very good idea. In particular, it
> > > helped
> > > find some places where I hadn't switched to using `%racket-commit`
> > > once the release was tagged.
> > 
> > That is better, but can still be improved.  As hinted at in my
> > comment
> > to your tree, origin snippets might be a better solution here unless
> > I'm missing something in the heat of the moment.
> 
> Could you give an example of what you imagine the result might look
> like in use? E.g. (but I'm not sure this would really be an
> improvement):
> 
> > (cons*
> >  ...
> >  libedit
> >  racket-minimal
> >  (append
> >   (racket-package-sources
> >    "2d" (base32
> > "1zzcz5qyjv7syi41vb8jkxjp1rqgj61zbsdrg0nlc4qy9qsafzgr")
> >    "2d" "2d-doc" "2d-lib")
> >   (racket-package-sources
> >    "algol60" (base32
> > "09kj6asypmc24n29w0izc9p0q8hpga2hpkchsypfwn5c8zpvihlx")
> >    '("algol60" "."))
> >   ...))
I'd write this as 
--8<---------------cut here---------------start------------->8---
(list
 ... 
 libedit
 racket-minimal
 (simple-racket-origin
  "2d" (base32 "1zzcz5qyjv7syi41vb8jkxjp1rqgj61zbsdrg0nlc4qy9qsafzgr")
  '("2d" "2d-doc" "2d-lib")
 (simple-racket-origin
  "algol60" (base32
"09kj6asypmc24n29w0izc9p0q8hpga2hpkchsypfwn5c8zpvihlx")
  '("algol60" ".")
 ...)
--8<---------------cut here---------------end--------------->8---
I do wonder whether these packages can further be modularized (i.e. so
that they build as packages) with configure-layer.rkt acting as a
profile hook and some racket meta package simply adding racket-minimal
and all the base stuff into the profile, but for now let's just have an
easy way of formulating origins.

Cheers
diff mbox series

Patch

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..9970dacedb 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,939 @@  (define-public racket-bootstrap-chez-bootfiles
 Chez Scheme.")
      (license (list license:asl2.0)))))
 
+(define (extract-package-source origin spec)
+  "Extract the source for a Racket package specified by SPEC from ORIGIN into
+a new file-like object.  In the resulting file-like object, the package source
+will be in the directory \"/share/racket/pkgs/NAME/\", where NAME is the Racket
+name for the package.
 
-(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 %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"))
+SPEC is a list of the form:
 
+  (NAME PATH)
+
+where PATH is the path to the package source relative to ORIGIN---possibly
+`\".\"`.  As a special case, SPEC may also be given a string, which is
+equivalent to:
+
+  (NAME NAME)
+
+Examples:
+
+
+- \"expeditor\"
+- (\"main-distribution\" \".\")
+- (\"racket-lib\" \"pkgs/racket-lib\")"
+  (match (match spec
+           ((? string? name)
+            (list name (file-append origin (string-append "/" name))))
+           ((name ".")
+            (list name origin))
+           ((name path)
+            (list name (file-append origin (string-append "/" path)))))
+    ((name src)
+     (computed-file
+      (string-append "racket-pkg-" name)
+      (with-imported-modules `((guix build utils))
+        #~(begin
+            (use-modules (guix build utils))
+            (mkdir-p (string-append #$output "/share/racket/pkgs"))
+            (copy-recursively #$src (string-append #$output
+                                                   "/share/racket/pkgs/"
+                                                   #$name))))))))
+
+(define (extract-package-source* source-groups)
+  "Return a list of file-like objects containing the sources of the Racket
+packages specified by SOURCE-GROUPS, a list of the form:
+
+  ((ORIGIN SPEC ...) ...)
+
+The result is equivalent to:
+
+  (append (list (extract-package-source ORIGIN SPEC) ...) ...)"
+  (append-map (match-lambda
+                ((origin . specs)
+                 (map (cut extract-package-source origin <>)
+                      specs)))
+              source-groups))
 
 (define-public racket
   (package
-    (inherit racket-minimal)
     (name "racket")
     (version %racket-version)
-    (source
-     (origin
-       (method url-fetch)
-       (uri (map (lambda (base)
-                   (string-append base version "/racket-src.tgz"))
-                 %installer-mirrors))
-       (sha256
-        (base32
-         "0dsv7br85nvh5gjfihznq9jb1dzas0f6gnv5qwc9zmb7yn75nrp5"))
-       (patches
-        ;; remove in Racket 8.5
-        ;; see https://github.com/racket/racket/issues/4133
-        (search-patches "racket-gui-tethered-launcher-backport.patch"))
-       (snippet
-        #~(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))
-            ;; Minimal workaround for FSDG issue:
-            ;; see <https://github.com/racket/srfi/pull/15>.
-            ;; We will backport a better fix once we use Git
-            ;; origins for Racket packages.
-            (delete-file-recursively "share/pkgs/srfi-doc-nonfree")
-            (substitute* "share/pkgs/srfi/info.rkt"
-              (("\"srfi-doc-nonfree\"")
-               ""))))))
+    (source #f)
     (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-minimal)
-       ("extend-layer" ,extend-layer)
-       ("main-repo" ,%racket-origin)))
+     (cons*
+      cairo
+      fontconfig
+      glib
+      glu
+      gmp
+      gtk+ ;; propagates gdk-pixbuf+svg
+      libjpeg-turbo
+      libpng
+      libx11 ;; ?? wayland ??
+      mesa
+      mpfr
+      pango
+      unixodbc
+      libedit ;; TODO reconsider in light of expeditor and readline-gpl
+      racket-minimal ;; <-- TODO non-tethered layer
+      (extract-package-source*
+       `((,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/2d")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1zzcz5qyjv7syi41vb8jkxjp1rqgj61zbsdrg0nlc4qy9qsafzgr"))
+             (file-name
+              (git-file-name "racket-2d" %racket-version)))
+          "2d" "2d-doc" "2d-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/algol60")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "09kj6asypmc24n29w0izc9p0q8hpga2hpkchsypfwn5c8zpvihlx"))
+             (file-name
+              (git-file-name "racket-algol60" %racket-version)))
+          ("algol60" "."))
+         (,%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"))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/cext-lib")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "00w38jpv88fpl4pgj6ndnysvn0s21rjvj0xhznay80msan0vc341"))
+             (file-name (git-file-name "racket-cext-lib" %racket-version)))
+          "cext-lib" "dynext-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/class-iop")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "08z57q83cr7wnh6g8ah3hdhmsmf9zp1jfs7yvxv188l3hzvygy5l"))
+             (file-name (git-file-name "racket-class-iop" %racket-version)))
+          "class-iop-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/compatibility")
+                   (commit "37f11132cdad7ef27386b68383d073f275d67c31")))
+             (sha256 (base32
+                      "0bfqwscjpyi325br5pa6g62g9c8lq18a80zp5g3d2qzn3n3mi6x0"))
+             (file-name
+              (git-file-name "racket-compatibility" %racket-version)))
+          "compatibility" "compatibility-doc" "compatibility-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/contract-profile")
+                   (commit "95d980a076126b8e4e4284e912f2a7d9d3ab6860")))
+             (sha256 (base32
+                      "1xm2z8g0dpv5d9h2sg680vx1a8ix9gbsdpxxb8qv1w7akp73paj3"))
+             (file-name
+              (git-file-name "racket-contract-profile" %racket-version)))
+          ("contract-profile" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/data")
+                   (commit "e32d012b394e32e102e8a9adfcc885bb0541ab51")))
+             (sha256 (base32
+                      "10iabgrk9alaggvksnyb0hdq7f1p30pq6pq2bcakvhzpxwiv1f55"))
+             (file-name (git-file-name "racket-data" %racket-version)))
+          "data" "data-doc" "data-enumerate-lib" "data-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/datalog")
+                   (commit "7d160a86451af8298093d07674a2eb0e1a0161a4")))
+             (sha256 (base32
+                      "0n5j5gnqh7g31mvgx19ggl18hirzbvq2r189lbngmnrmbc7b73fp"))
+             (file-name (git-file-name "racket-datalog" %racket-version)))
+          ("datalog" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/db")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1n02ja0yj3mjjhmz0yv04yfhyvrsznbljn8bjviyfxnm4xf9rcc5"))
+             (file-name (git-file-name "racket-db" %racket-version)))
+          "db" "db-doc" "db-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/deinprogramm")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1is6fapgv6rxfjz47nh6qf3kh7y7sjdinakaxqffi46gf1al8prd"))
+             (file-name
+              (git-file-name "racket-deinprogramm" %racket-version)))
+          "deinprogramm" "deinprogramm-signature")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/distributed-places")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1dajpkj9balqcpv6cdk9hwjz592h1vq8rrx5vncariiac4vbdpa0"))
+             (file-name
+              (git-file-name "racket-distributed-places" %racket-version)))
+          "distributed-places"
+          "distributed-places-doc"
+          "distributed-places-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/draw")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1xgjfbh70hqw67z88iqqajg98d04qwbzn6im2wj47rs28jxlm9ly"))
+             (file-name (git-file-name "racket-draw" %racket-version)))
+          "draw" "draw-doc" "draw-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/drracket")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0m3l4an3nq2ycd1h287s1az2v2zprjbzd8if2x7d5r71vaj4i00c"))
+             (file-name (git-file-name "racket-drracket" %racket-version)))
+          "drracket"
+          "drracket-plugin-lib"
+          "drracket-tool"
+          "drracket-tool-doc"
+          "drracket-tool-lib"
+          "drracket-tool-text-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/ds-store")
+                   (commit "949ca63dd00522b3ab8aec2d71c543ece8266872")))
+             (sha256 (base32
+                      "0ajr27kipp4dr1qlisaghsb3h7lhhjwrfw2r79b5myczsa1mp661"))
+             (file-name (git-file-name "racket-ds-store" %racket-version)))
+          "ds-store" "ds-store-doc" "ds-store-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/eli-tester")
+                   (commit "036e07d43a1f478ea1750881d5591d983ce1ffaf")))
+             (sha256 (base32
+                      "0icx6wn14gjm8kdmq1jppqgq87sxkras4qb5xmdr6wigxafhjqyk"))
+             (file-name (git-file-name "racket-eli-tester" %racket-version)))
+          ("eli-tester"  "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/eopl")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1fmiixj6rxsgzwvgva8lvrvv0gl49v2405mp3s0i7ipis5c4n27s"))
+             (file-name (git-file-name "racket-eopl" %racket-version)))
+          ("eopl" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/errortrace")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "14m7rhaxngj36070iw15am434hm438pfgmwjfsiqhsglz4pcxhip"))
+             (file-name (git-file-name "racket-errortrace" %racket-version)))
+          "errortrace" "errortrace-doc" "errortrace-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/expeditor")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "07djzxs6307l51mcsk3yr2g4g47ayxa3878g7sf5xhqdr4hd9vxf"))
+             (file-name (git-file-name "racket-expeditor" %racket-version)))
+          "expeditor" "expeditor-doc" "expeditor-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/frtime")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0ydz2yn8vvv6z7brwlswcyx0f31a6y6d443i89rysfvd2xkhpfd5"))
+             (file-name (git-file-name "racket-frtime" %racket-version)))
+          ("frtime" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/future-visualizer")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1758qq769m0r14xf64sl2ix2l9z340kvapar0j7s5kdg42lmvnhm"))
+             (file-name
+              (git-file-name "racket-future-visualizer" %racket-version)))
+          "future-visualizer"
+          "future-visualizer-pict"
+          "future-visualizer-typed")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/games")
+
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0kpn3izlx1ccd0pj0dnvmnrhny51b85xy418a7psj70lz8j8415d"))
+             (file-name (git-file-name "racket-games" %racket-version)))
+          ("games" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/gui")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1x33jgrx3r32k7hgwr591z3xqv1m2r5nc4km2fnxv0ak2xa0j3gj"))
+             (patches
+              ;; remove in Racket 8.5
+              ;; see https://github.com/racket/racket/issues/4133
+              (search-patches "racket-gui-tethered-launcher-backport.patch"))
+             (file-name (git-file-name "racket-gui" %racket-version)))
+          "gui" "gui-doc" "gui-lib" "tex-table")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/gui-pkg-manager")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1ji9448d723nklqvycwdswj0ni28sabrncag14f9mx47did5myb5"))
+             (file-name
+              (git-file-name "racket-gui-pkg-manager" %racket-version)))
+          "gui-pkg-manager-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/htdp")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0r4ykybcpr10y2db9rlza9pr0xh58nd7ac389mjcxp8g386hgihl"))
+             (file-name (git-file-name "racket-htdp" %racket-version)))
+          "htdp" "htdp-doc" "htdp-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/html")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "18n1jnjgzfknc8nv8dppi85nb8q08gqdwkg6hfjk08x0p00anx2x"))
+             (file-name (git-file-name "racket-html" %racket-version)))
+          "html" "html-doc" "html-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/icons")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1s5a6j11fg3fdr6b7vm2q7q178d7q8b8igy73bs211r27qrd1gg7"))
+             (file-name (git-file-name "racket-icons" %racket-version)))
+          ("icons" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/images")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0rpjxqw34bq5m08kh1ldl1mr7s9z1lyydxxcyzb292kqh9qiqvfl"))
+             (file-name (git-file-name "racket-images" %racket-version)))
+          "images" "images-doc" "images-gui-lib" "images-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/lazy")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "176ylzgbdsbmqknpihaz519afq71pyjkv1h87j5v8jfbpbddyfsf"))
+             (file-name (git-file-name "racket-lazy" %racket-version)))
+          ("lazy" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/macro-debugger")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "14hyrwbkffr61fk44l02xb47bhv5zccw0ymaa9kxld86hvyqhqbm"))
+             (file-name
+              (git-file-name "racket-macro-debugger" %racket-version)))
+          "macro-debugger" "macro-debugger-text-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/main-distribution")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0m2n9s32s8a4a2gn4ywrm9l8jycdm5ayi5w9kh5wchhrrw7qzq7y"))
+             (file-name
+              (git-file-name "racket-main-distribution" %racket-version)))
+          ("main-distribution" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/make")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "10852fj30bz5r46c3d99s37fkgy5yh44gb01j29sf3kxnhi0g2sa"))
+             (file-name (git-file-name "racket-make" %racket-version)))
+          ("make" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/math")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "02sqbnvxvmvslk33b44fx4v93zafcvhva0cx8z21jqbl5wp217ac"))
+             (file-name (git-file-name "racket-math" %racket-version)))
+          "math" "math-doc" "math-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/mysterx")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "11p9jzrafw0hizhl0cs4sxx7rv281185q8hryic2rpk0kzjdyr48"))
+             (file-name (git-file-name "racket-mysterx" %racket-version)))
+          ("mysterx" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/mzcom")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0rc9pfj7gwm5azghqvcibz6si1x5s2v8mr2yngk7ssq9gzfbi6a4"))
+             (file-name (git-file-name "racket-mzcom" %racket-version)))
+          ("mzcom" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/mzscheme")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "192c52zi726h5wjamxrhivjw2waq1im0zpyxhbrkrxknm8x84bs9"))
+             (file-name (git-file-name "racket-mzscheme" %racket-version)))
+          "mzscheme" "mzscheme-doc" "mzscheme-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/RenaissanceBug/racket-cookies")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0k0hifxhywl5c3hjcaiizc098dpyk001d981p572gly116yvjxc1"))
+             (file-name
+              (git-file-name "RenaissanceBug-racket-cookies" %racket-version)))
+          "net-cookies" "net-cookies-doc" "net-cookies-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/stamourv/optimization-coach")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0b27sw48d7rhz0hin88c7rbr9vpg1c23sn82nd4jkmq54h6gasr1"))
+             (file-name
+              (git-file-name "stamourv-optimization-coach" %racket-version)))
+          ("optimization-coach" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/option-contract")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "026b7n5l0c3024nymshz8zp1yhn493rdzgpflzfd52hj7awafqhk"))
+             (file-name
+              (git-file-name "racket-option-contract" %racket-version)))
+          "option-contract" "option-contract-doc" "option-contract-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/parser-tools")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "08pvz4zramirzm3j64hbhjm0mmh5zfy37iv4s3vmq0rj49cr8fl3"))
+             (file-name (git-file-name "racket-parser-tools" %racket-version)))
+          "parser-tools" "parser-tools-doc" "parser-tools-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/pconvert")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "00czi0p399mmyrvxyrs5kniizpkqfxyz2ncxqi2jy79a7wk79pb1"))
+             (file-name (git-file-name "racket-pconvert" %racket-version)))
+          "pconvert-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/pict")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0g1iwdr6qh1xb0crhj96830vjjnbds409xbpqn7j5sh0ksy6vr5x"))
+             (file-name (git-file-name "racket-pict" %racket-version)))
+          "pict" "pict-doc" "pict-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/pict-snip")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "081nwiy4a0n4f7xws16hqbhf0j3kz5alizndi3nnyr3chm4kng6x"))
+             (file-name (git-file-name "racket-pict-snip" %racket-version)))
+          "pict-snip" "pict-snip-doc" "pict-snip-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/picturing-programs")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1g6xr39hx1j03gb3d4dljm3v91xcj2gfpq3dgy5xvplzr6cmmxgr"))
+             (file-name
+              (git-file-name "racket-picturing-programs" %racket-version)))
+          ("picturing-programs" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/plai")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0i983sh0r0zm2ng4j44m5aw9669kh5fhp91bzpc9jm280rfcqvyl"))
+             (file-name (git-file-name "racket-plai" %racket-version)))
+          "plai" "plai-doc" "plai-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/planet")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0r2yqrzrmdjjyr14k6hhlzc5kzrcx3583m1s02mhrcmpfw0s85w9"))
+             (file-name (git-file-name "racket-planet" %racket-version)))
+          "planet" "planet-doc" "planet-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/plot")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "07kq32si34ybcwz8idxxcrzssg8diyrp1nfgkcj0mmvr45321zm7"))
+             (file-name (git-file-name "racket-plot" %racket-version)))
+          "plot" "plot-compat" "plot-doc" "plot-gui-lib" "plot-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/preprocessor")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1p5aid58ifnjy4xl0ysh85cq39k25661v975jrpk182z3k5621mg"))
+             (file-name (git-file-name "racket-preprocessor" %racket-version)))
+          ("preprocessor" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/profile")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "179i86lyby29nywz60l4vnadi02w8b12h7501nm5h5g4pq9jjmbb"))
+             (file-name (git-file-name "racket-profile" %racket-version)))
+          "profile" "profile-doc" "profile-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/Metaxal/quickscript")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "100g3yqhbjdq06b6l6d72ywsw29awgy8crqg33wj7h12xq07nzcr"))
+             (file-name (git-file-name "Metaxal-quickscript" %racket-version)))
+          ("quickscript" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/r5rs")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1g3cysj7z88r38vkzvi8g2fb2hn4yg1fdhy5smxw303jxgl3inp6"))
+             (file-name (git-file-name "racket-r5rs" %racket-version)))
+          "r5rs" "r5rs-doc" "r5rs-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/r6rs")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0b1ymzdp10r0flw2acbidjsh5ma1pm5hy54jss37sxf89z3xbvm4"))
+             (file-name (git-file-name "racket-r6rs" %racket-version)))
+          "r6rs" "r6rs-doc" "r6rs-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/jeapostrophe/racket-cheat")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "06wcj558rzkbl2bwkmikyspya9v1f4iwlzwnwxpkc33h2xapwabr"))
+             (file-name
+              (git-file-name "jeapostrophe-racket-cheat" %racket-version)))
+          ("racket-cheat" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/racklog")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1rgrvwy3kr9b9w5cghsffiv3ly00yfvvzr5xaaw83g1w7yin0mnb"))
+             (file-name (git-file-name "racket-racklog" %racket-version)))
+          ("racklog" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/rackunit")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "057z31rja6h3nabh5b2xgwfrzmlm6h1cv1qcgf3xfy4g2q5dqn5p"))
+             (file-name (git-file-name "racket-rackunit" %racket-version)))
+          "rackunit"
+          "rackunit-doc"
+          "rackunit-gui"
+          "rackunit-lib"
+          "rackunit-plugin-lib"
+          "rackunit-typed"
+          "schemeunit"
+          "testing-util-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/readline")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "13kbcn2wchv82d709mw3r8n37bk8iwq0y4kpvm9dbzx0w2pxkfwn"))
+             (file-name (git-file-name "racket-readline" %racket-version)))
+          "readline" "readline-doc" "readline-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/realm")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0hxcgla08iack54j8v40fj51811chpy66ym2zq76zb52c7kzn0hi"))
+             (file-name (git-file-name "racket-realm" %racket-version)))
+          ("realm" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/redex")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0vlgxbnbgrlihk1hh5zd6hsc4566ldi4q76f87z5vai54dxkwy2f"))
+             (file-name (git-file-name "racket-redex" %racket-version)))
+          "redex"
+          "redex-benchmark"
+          "redex-doc"
+          "redex-examples"
+          "redex-gui-lib"
+          "redex-lib"
+          "redex-pict-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/sasl")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0ibh4wb4gn8pggx6gkv4vk4d6rwzn5nrvjibhvkzhaynf6lhb824"))
+             (file-name (git-file-name "racket-sasl" %racket-version)))
+          "sasl" "sasl-doc" "sasl-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/scheme-lib")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0pcf0y8rp4qyjhaz5ww5sr5diq0wpcdfrrnask7zapyklzx1jx8x"))
+             (file-name (git-file-name "racket-scheme-lib" %racket-version)))
+          ("scheme-lib" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/scribble")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0rgvnsykrxkah6s5fw1vyp9lxsb4z9w6hgwk5j6wbwjp2gsfczbm"))
+             (file-name (git-file-name "racket-scribble" %racket-version)))
+          "scribble"
+          "scribble-doc"
+          "scribble-html-lib"
+          "scribble-lib"
+          "scribble-text-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/serialize-cstruct-lib")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1rq3n1fa7ldjwx3lrh9ybhig7jlsw1crpzyklbzp3xqdw6jymfnz"))
+             (file-name
+              (git-file-name "racket-serialize-cstruct-lib" %racket-version)))
+          ("serialize-cstruct-lib" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/sgl")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0nkymhdyjrwi5h199j4w5zh7y3x3ai42gsiwxzh0hy7yqrqqg9zv"))
+             (file-name (git-file-name "racket-sgl" %racket-version)))
+          ("sgl" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/shell-completion")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "04m144gy2mp4fiq6rcbf12wjr8mws8k9scfhg9lc38vqppp4lxsj"))
+             (file-name
+              (git-file-name "racket-shell-completion" %racket-version)))
+          ("shell-completion" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/simple-tree-text-markup")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "0fyd9gfz6bnv0m1901wv5mnhc05rm8hw9i6ddrqx33hs6qsg2zqr"))
+             (file-name
+              (git-file-name "racket-simple-tree-text-markup" %racket-version)))
+          "simple-tree-text-markup"
+          "simple-tree-text-markup-doc"
+          "simple-tree-text-markup-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/slatex")
+                   (commit "47e1d3e3e33d826bc2b26f9e8998eb235b23a9a5")))
+             (sha256 (base32
+                      "0pkm2isbbdk63slrbsxcql7rr0wdrw5kapw1xq4ps5k8dhlzv8x0"))
+             (file-name (git-file-name "racket-slatex" %racket-version)))
+          ("slatex" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/slideshow")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1znv1i2d0610hhy71q932xy7wka00q3q50in1xfnk8ibg7nzkagm"))
+             (file-name (git-file-name "racket-slideshow" %racket-version)))
+          "slideshow" "slideshow-doc" "slideshow-exe" "slideshow-lib"
+          "slideshow-plugin")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/snip")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "01r9wc5xr3q3n4yyif6j0a37rgdzmpslxn05k13ksik73b3wj6hj"))
+             (file-name (git-file-name "racket-snip" %racket-version)))
+          "snip" "snip-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/typed-racket")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1462kj9yswsxbnw71casylzlvhd7cxrml2v9j7rcsnn9hmrqx4vv"))
+             (file-name (git-file-name "racket-typed-racket" %racket-version)))
+          "source-syntax"
+          "typed-racket"
+          "typed-racket-compatibility"
+          "typed-racket-doc"
+          "typed-racket-lib"
+          "typed-racket-more")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/srfi")
+                   ;; Includes an FSDG fix: return to %racket-commit in 8.5.
+                   ;; See <https://github.com/racket/srfi/pull/15>.
+                   (commit "7243029b135741ce08ae30f877e2f49a2a460b22")))
+             (sha256 (base32
+                      "0aqbcdv2dfc2xnk0h6zfi56p7bpwqji8s88qds3d03hhh9k28gvn"))
+             ;; Use the relevant version for srfi-doc and srfi-lib,
+             ;; since we're using a newer commit than the v8.4 tag.
+             (file-name (git-file-name "racket-srfi" "1.1")))
+          "srfi" "srfi-doc" "srfi-lib" "srfi-lite-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/string-constants")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1qizjq4n0hzdgdcjjpr94464gsywpsk2g9mnvwzqr7dcqbrsfvn6"))
+             (file-name
+              (git-file-name "racket-string-constants" %racket-version)))
+          "string-constants" "string-constants-doc" "string-constants-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/swindle")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "164gdsphjzdl2vv7zxz7dfk9jwax8njpmim6sidm8qz8a8589y67"))
+             (file-name (git-file-name "racket-swindle" %racket-version)))
+          ("swindle" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/syntax-color")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1vf2fc3qvx8a1igi7swsg8gaqhx786sa0vqxd18xhbsidfgb5ywp"))
+             (file-name (git-file-name "racket-syntax-color" %racket-version)))
+          "syntax-color" "syntax-color-doc" "syntax-color-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/trace")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "070ihla5j796hdarn5wxdwn4xj0xnkm50shgh49jy994mribvhia"))
+             (file-name (git-file-name "racket-trace" %racket-version)))
+          ("trace" "."))
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/unix-socket")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "02dfwas5ynbpyz74w9kwb4wgb37y5wys7svrlmir8k0n9ph9vq0y"))
+             (file-name (git-file-name "racket-unix-socket" %racket-version)))
+          "unix-socket" "unix-socket-doc" "unix-socket-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/web-server")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1zgb6jl7zx6258ljs8f3lvryrq5n5zpd71dqzr698m92kw3x2pkn"))
+             (file-name (git-file-name "racket-web-server" %racket-version)))
+          "web-server" "web-server-doc" "web-server-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/wxme")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "1qp5gr9gqsakiq3alw6m4yyv5vw4i3hp4y4nhq8vl2nkjmirvn0b"))
+             (file-name (git-file-name "racket-wxme" %racket-version)))
+          "wxme" "wxme-lib")
+         (,(origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/racket/xrepl")
+                   (commit %racket-commit)))
+             (sha256 (base32
+                      "12zjgsy5zqm3fck3ihg4a70wj56s2cnnjyb4jlfi5nnsfqyrnxg3"))
+             (file-name (git-file-name "racket-xrepl" %racket-version)))
+          "xrepl" "xrepl-doc" "xrepl-lib")))))
+    (build-system gnu-build-system)
     (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))
-         (delete 'install))
-       ;; we still don't have these:
-       #:tests? #f))
+     ;; We're using #:configure-flags to pass flags for
+     ;; `make-installation-layer.rkt` and #:make-flags to pass arguments for
+     ;; `raco pkg install`.
+     (list
+      #:configure-flags
+      #~`("--extra-foreign-lib-search-dirs"
+          ,(format #f "~s"
+                   '(#$@(map (lambda (name)
+                               (cond
+                                ((this-package-input name)
+                                 => (cut file-append <> "/lib"))
+                                (else
+                                 (raise-exception
+                                  (make-exception
+                                   (make-assertion-failure)
+                                   (make-exception-with-message
+                                    "missing input to the 'racket' package")
+                                   (make-exception-with-irritants
+                                    (list name)))))))
+                             '("cairo"
+                               "fontconfig-minimal" ;; aka fontconfig
+                               "glib"
+                               "glu"
+                               "gmp"
+                               "gtk+"
+                               "libjpeg-turbo"
+                               "libpng"
+                               "libx11"
+                               "mesa"
+                               "mpfr"
+                               "pango"
+                               "unixodbc"
+                               "libedit")))))
+      #:make-flags #~`("main-distribution")
+      #:tests? #f ;; packaged separately
+      #:modules '((guix build gnu-build-system)
+                  (guix build utils)
+                  (guix build union)
+                  (ice-9 match))
+      #:imported-modules `((guix build union)
+                           ,@%gnu-build-system-modules)
+      #:phases
+      #~(modify-phases %standard-phases
+          (delete 'unpack)
+          (replace 'configure
+            (lambda* (#:key inputs configure-flags #:allow-other-keys)
+              (let* ((racket (search-input-file inputs "bin/racket")))
+                (apply invoke
+                       racket
+                       #$make-installation-layer.rkt
+                       `(,@configure-flags
+                         ,(dirname (dirname racket))
+                         ,#$output))
+                (invoke racket
+                        "--config" (string-append #$output "/etc/racket")
+                        "-l" "raco" "setup"
+                        "--no-user"))))
+          (replace 'build
+            (lambda* (#:key inputs #:allow-other-keys)
+              ;; We use "share/racket/pkgs" for sources to distinguish them
+              ;; from the "lib/racket/pkgs" of a potential parent layer.
+              (union-build (string-append #$output "/lib/racket/pkgs")
+                           (search-path-as-list '("share/racket/pkgs")
+                                                (map cdr inputs))
+                           #:create-all-directories? #t)))
+          (replace 'install
+            (lambda* (#:key inputs make-flags #:allow-other-keys)
+              (let ((racket (search-input-file inputs "/bin/racket")))
+                (unless (null? make-flags)
+                  (invoke racket
+                          "-l-"
+                          "pkg/dirs-catalog"
+                          "--link"
+                          "local-catalog"
+                          (string-append #$output "/lib/racket/pkgs"))
+                  (apply invoke
+                         racket
+                         "--config" (string-append #$output "/etc/racket")
+                         "-l" "raco"
+                         "pkg" "install"
+                         "--installation"
+                         "--auto"
+                         "--catalog" "local-catalog"
+                         make-flags))))))))
+    (home-page "https://racket-lang.org")
     (synopsis "Programmable programming language in the Scheme family")
     (description
      "Racket is a general-purpose programming language in the Scheme family,
@@ -564,17 +1333,20 @@  (define dest (string-append pkgs-dir "/" pkg))
 
 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.")))
-
+languages such as Typed Racket, R5RS and R6RS Scheme, Algol 60, and Datalog.")
+    ;; https://download.racket-lang.org/license.html
+    ;; The LGPL components are only used by Racket BC.
+    (license (list license:asl2.0 license:expat))))
 
-(define extend-layer
+(define make-installation-layer.rkt
   (scheme-file
-   "extend-layer.rkt"
+   "make-installation-layer.rkt"
    `(module
-     extend-layer racket/base
+     make-installation-layer racket/base
      (require racket/cmdline
               racket/match
               racket/file
+              racket/port
               racket/list
               racket/pretty)
      (define config-file-pth
@@ -584,8 +1356,14 @@  (define (build-path-string . args)
      (define rx:racket
        ;; Guile's reader doesn't support #rx"racket"
        (regexp "racket"))
+     (define extra-foreign-lib-search-dirs '())
      (command-line
-      #:args (parent-layer prefix . lib-dir*)
+      #:once-each
+      [("--extra-foreign-lib-search-dirs") dir-list
+       "foreign library directories, as a list of strings in `read` syntax"
+       (set! extra-foreign-lib-search-dirs
+             (call-with-input-string dir-list read))]
+      #:args (parent-layer prefix)
       (let* ([config
               (for/fold
                ([config (file->value (build-path parent-layer
@@ -615,27 +1393,42 @@  (define rx:racket
                                  (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"))]
+              (hash-update config
+                           'lib-search-dirs
+                           (lambda (dirs)
+                             ;; add after other layers, but before older
+                             ;; foreign lib search directories
+                             (define-values [rkt old-foreign-dirs]
+                               (partition (lambda (pth)
+                                            (or (not pth)
+                                                (regexp-match? rx:racket pth)))
+                                          dirs))
+                             (append rkt
+                                     extra-foreign-lib-search-dirs
+                                     old-foreign-dirs)))]
              [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)))]
+              (hash-set* config
+                         'apps-dir
+                         (build-path-string prefix "share/applications")
+                         'absolute-installation? #t
+                         ;; Let Guix coexist with other installation
+                         ;; methods without clobbering user-specific packages.
+                         ;; This could be set in various places, but doing
+                         ;; it here is convienient, at least until we support
+                         ;; cross-compilation.
+                         'installation-name
+                         (string-append (version)
+                                        "-guix"
+                                        (match (system-type 'gc)
+                                          ['cgc "-cgc"]
+                                          ;; workaroung Guile reader/printer:
+                                          ['|3m| "-bc"]
+                                          [_ ""])))]
              [bin-dir
               (hash-ref config 'bin-dir)]
              [config
               (hash-set* config
+                         'config-tethered-apps-dir (hash-ref config 'apps-dir)
                          'config-tethered-console-bin-dir bin-dir
                          'config-tethered-gui-bin-dir bin-dir)]
              [new-config-pth