diff options
author | Ludovic Courtès <ludo@gnu.org> | 2021-01-27 14:46:10 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2021-02-04 09:23:39 +0100 |
commit | 316fc2acbb112bfa572ae30f95a93bcd56621234 (patch) | |
tree | 88b313298e8adba90c87be3358b3d694cd7a8399 /guix/describe.scm | |
parent | 814ee99da89a0bcc6cf53d61763d345ed95e067c (diff) | |
download | guix-patches-316fc2acbb112bfa572ae30f95a93bcd56621234.tar guix-patches-316fc2acbb112bfa572ae30f95a93bcd56621234.tar.gz |
channels: Record 'guix' channel metadata in (guix config).
Partially fixes <https://bugs.gnu.org/45896>.
* guix/config.scm.in (%channel-metadata): New variable.
* guix/describe.scm (channel-metadata): Use it.
(current-channels): New procedure.
(current-profile-entries): Clarify docstring.
* guix/self.scm (compiled-guix): Add #:channel-metadata and pass it to
'make-config.scm'.
(make-config.scm): Add #:channel-metadata and define '%channel-metadata'
in the generated file.
(guix-derivation): Add #:channel-metadata and pass it to 'compiled-guix'.
* guix/channels.scm (build-from-source): Replace 'name', 'source', and
'commit' parameters with 'instance'. Pass #:channel-metadata to BUILD.
(build-channel-instance): Adjust accordingly.
* build-aux/build-self.scm (build-program): Add #:channel-metadata
and pass it to 'guix-derivation'.
(build): Add #:channel-metadata and pass it to 'build-program'.
* guix/scripts/describe.scm (display-profile-info): Add optional
'channels' parameter. Pass it to 'display-profile-content'.
(display-profile-content): Add optional 'channels' parameter and honor
it. Iterate on CHANNELS rather than on the manifest entries of
PROFILE.
(guix-describe): When PROFILE is #f, call 'current-channels' and pass it
to 'display-profile-info', unless it returns the empty list.
Diffstat (limited to 'guix/describe.scm')
-rw-r--r-- | guix/describe.scm | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/guix/describe.scm b/guix/describe.scm index ac89fc0d7c..6a31c707f0 100644 --- a/guix/describe.scm +++ b/guix/describe.scm @@ -23,12 +23,13 @@ #:use-module ((guix utils) #:select (location-file)) #:use-module ((guix store) #:select (%store-prefix store-path?)) #:use-module ((guix config) #:select (%state-directory)) - #:autoload (guix channels) (sexp->channel) + #:autoload (guix channels) (sexp->channel manifest-entry-channel) #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (current-profile current-profile-date current-profile-entries + current-channels package-path-entries package-provenance @@ -87,10 +88,19 @@ as a number of seconds since the Epoch, or #f if it could not be determined." (string-append (dirname file) "/" target))))) (const #f))))))) +(define (channel-metadata) + "Return the 'guix' channel metadata sexp from (guix config) if available; +otherwise return #f." + ;; Older 'build-self.scm' would create a (guix config) file without the + ;; '%channel-metadata' variable. Thus, properly deal with a lack of + ;; information. + (let ((module (resolve-interface '(guix config)))) + (and=> (module-variable module '%channel-metadata) variable-ref))) + (define current-profile-entries (mlambda () "Return the list of entries in the 'guix pull' profile the calling process -lives in, or #f if this is not applicable." +lives in, or the empty list if this is not applicable." (match (current-profile) (#f '()) (profile @@ -105,6 +115,20 @@ lives in, or #f if this is not applicable." (string=? (manifest-entry-name entry) "guix")) (current-profile-entries)))) +(define current-channels + (mlambda () + "Return the list of channels currently available, including the 'guix' +channel. Return the empty list if this information is missing." + (match (current-profile-entries) + (() + ;; As a fallback, if we're not running from a profile, use 'guix' + ;; channel metadata from (guix config). + (match (channel-metadata) + (#f '()) + (sexp (or (and=> (sexp->channel sexp 'guix) list) '())))) + (entries + (filter-map manifest-entry-channel entries))))) + (define (package-path-entries) "Return two values: the list of package path entries to be added to the package search path, and the list to be added to %LOAD-COMPILED-PATH. These |