summary refs log tree commit diff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2023-06-15 10:34:31 +0200
committerLudovic Courtès <ludo@gnu.org>2023-06-16 00:14:52 +0200
commita3beb8d741e88f30765f4e3bc525c3433bf49498 (patch)
treec8c13a910ab4046c82cae5a671bb0e42ca272b6a
parent6e1215fb9c03ccb4a2d4440990aee5a66a935268 (diff)
downloadguix-a3beb8d741e88f30765f4e3bc525c3433bf49498.tar.gz
pull: Preserve channel ordering when using '--commit', '--url', etc.
Previously using '--url', '--commit', or '--branch' would move the
'guix' channel to the front.  This is okay in itself but it gratuitously
leads to a different cache key in 'cached-channel-instance'--IOW, 'guix
time-machine --commit=X' where X is already in cache would gratuitously
recompute the channel derivations.

* guix/scripts/pull.scm (channel-list): Use 'map' instead of 'find' +
'remove' + 'cons'.
-rw-r--r--guix/scripts/pull.scm31
1 files changed, 15 insertions, 16 deletions
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index cd2e470289..ecd264d3fa 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -769,22 +769,21 @@ Use '~/.config/guix/channels.scm' instead."))
         (url (or (assoc-ref opts 'repository-url)
                  (environment-variable))))
     (if (or ref url)
-        (match (find guix-channel? channels)
-          ((? channel? guix)
-           ;; Apply '--url', '--commit', and '--branch' to the 'guix' channel.
-           (let ((url (or url (channel-url guix))))
-             (cons (match ref
-                     (('commit . commit)
-                      (channel (inherit guix)
-                               (url url) (commit commit) (branch #f)))
-                     (('branch . branch)
-                      (channel (inherit guix)
-                               (url url) (commit #f) (branch branch)))
-                     (#f
-                      (channel (inherit guix) (url url))))
-                   (remove guix-channel? channels))))
-          (#f                           ;no 'guix' channel, failure will ensue
-           channels))
+        ;; Apply '--url', '--commit', and '--branch' to the 'guix' channel.
+        (map (lambda (c)
+               (if (guix-channel? c)
+                   (let ((url (or url (channel-url c))))
+                     (match ref
+                       (('commit . commit)
+                        (channel (inherit c)
+                                 (url url) (commit commit) (branch #f)))
+                       (('branch . branch)
+                        (channel (inherit c)
+                                 (url url) (commit #f) (branch branch)))
+                       (#f
+                        (channel (inherit c) (url url)))))
+                   c))
+             channels)
         channels)))
 
 (define (validate-cache-directory-ownership)