Subject: bug#53210: [WIP PATCH 3/4] gnu: current-guix: Support when running outside a checkout.

From: Ludovic Courtès <[email-masked]>
Date: Mon, 14 Feb 2022 18:15:14 +0100

Josselin Poiret <[email-masked]> skribis:

> * guix/channels.scm (channel-build-system): Add build system that
> turns a channel record into a package.
> * gnu/packages/package-management.scm (current-guix): Use
> channel-build-system.

[...]

>  (define-public current-guix
> -  (let* ((repository-root (delay (canonicalize-path
> -                                  (string-append (current-source-directory)
> -                                                 "/../.."))))
> -         (select? (delay (or (git-predicate (force repository-root))
> -                             source-file?))))
> -    (lambda ()
> -      "Return a package representing Guix built from the current source tree.
> -This works by adding the current source tree to the store (after filtering it
> -out) and returning a package that uses that as its 'source'."
> +  (lambda ()
> +    "Return a package representing Guix built from the currently used one.
> +This works by either looking up profile or build metadata, and building from
> +the current Guix channel.  If that metadata is missing, assume we are running
> +from a Git checkout, so add the current source tree to the store (after
> +filtering it out) and return a package that uses that as its 'source'."
> +    (let* ((guix-channel (find guix-channel? (current-channels)))
> +           (repository-root (canonicalize-path
> +                             (string-append (current-source-directory)
> +                                            "/../..")))
> +           (select? (or (git-predicate  repository-root)
> +                        source-file?)))

We should keep these two variables as promises in the closure, to make
sure we don’t recompute them over and over… unless ‘lambda’ is changed
to ‘mlambda’ in the same commit, which is probably the best course of
action.