services: provenance: Save channel introductions.

* gnu/services.scm (channel->code): Include CHANNEL's introduction, if
any, unless CHANNEL is the singleton %DEFAULT-CHANNELS.
(channel->sexp): Add comment.
* guix/scripts/system.scm (sexp->channel): Change pattern to allow for
extensibility.
This commit is contained in:
Ludovic Courtès 2020-06-25 17:54:55 +02:00
parent 6d39f0cb77
commit eb5cf39e66
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
2 changed files with 25 additions and 5 deletions

@ -31,6 +31,7 @@
#:use-module (guix sets) #:use-module (guix sets)
#:use-module (guix ui) #:use-module (guix ui)
#:use-module ((guix utils) #:select (source-properties->location)) #:use-module ((guix utils) #:select (source-properties->location))
#:autoload (guix openpgp) (openpgp-format-fingerprint)
#:use-module (guix modules) #:use-module (guix modules)
#:use-module (gnu packages base) #:use-module (gnu packages base)
#:use-module (gnu packages bash) #:use-module (gnu packages bash)
@ -392,14 +393,31 @@ by the initrd once the root file system is mounted.")))
(define (channel->code channel) (define (channel->code channel)
"Return code to build CHANNEL, ready to be dropped in a 'channels.scm' "Return code to build CHANNEL, ready to be dropped in a 'channels.scm'
file." file."
`(channel (name ',(channel-name channel)) ;; Since the 'introduction' field is backward-incompatible, and since it's
(url ,(channel-url channel)) ;; optional when using the "official" 'guix channel, include it if and only
(branch ,(channel-branch channel)) ;; if we're referring to a different channel.
(commit ,(channel-commit channel)))) (let ((intro (and (not (equal? (list channel) %default-channels))
(channel-introduction channel))))
`(channel (name ',(channel-name channel))
(url ,(channel-url channel))
(branch ,(channel-branch channel))
(commit ,(channel-commit channel))
,@(if intro
`((introduction
(make-channel-introduction
,(channel-introduction-first-signed-commit intro)
(openpgp-fingerprint
,(openpgp-format-fingerprint
(channel-introduction-first-commit-signer
intro))))))
'()))))
(define (channel->sexp channel) (define (channel->sexp channel)
"Return an sexp describing CHANNEL. The sexp is _not_ code and is meant to "Return an sexp describing CHANNEL. The sexp is _not_ code and is meant to
be parsed by tools; it's potentially more future-proof than code." be parsed by tools; it's potentially more future-proof than code."
;; TODO: Add CHANNEL's introduction. Currently we can't do that because
;; older 'guix system describe' expect exactly name/url/branch/commit
;; without any additional fields.
`(channel (name ,(channel-name channel)) `(channel (name ,(channel-name channel))
(url ,(channel-url channel)) (url ,(channel-url channel))
(branch ,(channel-branch channel)) (branch ,(channel-branch channel))

@ -453,7 +453,9 @@ list of services."
(('channel ('name name) (('channel ('name name)
('url url) ('url url)
('branch branch) ('branch branch)
('commit commit)) ('commit commit)
rest ...)
;; XXX: In the future REST may include a channel introduction.
(channel (name name) (url url) (channel (name name) (url url)
(branch branch) (commit commit))))) (branch branch) (commit commit)))))