all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tomas Volf <~@wolfsden.cz>
To: 70839@debbugs.gnu.org
Cc: "Tomas Volf" <~@wolfsden.cz>,
	"Christopher Baines" <guix@cbaines.net>,
	"Josselin Poiret" <dev@jpoiret.xyz>,
	"Ludovic Courtès" <ludo@gnu.org>,
	"Mathieu Othacehe" <othacehe@gnu.org>,
	"Ricardo Wurmus" <rekado@elephly.net>,
	"Simon Tournier" <zimon.toutoune@gmail.com>,
	"Tobias Geerinckx-Rice" <me@tobias.gr>
Subject: [bug#70839] [PATCH 2/3] channels: Add `read-channels-file' procedure.
Date: Thu,  9 May 2024 01:13:23 +0200	[thread overview]
Message-ID: <06234d6dbf04c97da49ecadb8f8d139bf1fe1536.1715208954.git.~@wolfsden.cz> (raw)
In-Reply-To: <cover.1715208953.git.~@wolfsden.cz>

This commit moves non-exported local procedure from (guix pull) in order to
provide a single, canonical way to read a file produced by `guix describe
--format=channels'.

* guix/channels.scm (read-channels-file): New procedure.
(define-module): Export it.
* guix/scripts/pull.scm (channel-list): Use it.

Change-Id: I147fdf3cb177114f4607209de2299f46761b64be
---
 guix/channels.scm     | 14 +++++++++++++-
 guix/scripts/pull.scm | 12 +++---------
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/guix/channels.scm b/guix/channels.scm
index 51024dcad4..38d5c8c325 100644
--- a/guix/channels.scm
+++ b/guix/channels.scm
@@ -37,6 +37,7 @@ (define-module (guix channels)
   #:autoload   (guix git-authenticate) (authenticate-repository)
   #:autoload   (guix openpgp) (openpgp-public-key-fingerprint
                                openpgp-format-fingerprint)
+  #:autoload   (guix ui) (load* make-user-module)
   #:use-module (guix base16)
   #:use-module (guix records)
   #:use-module (guix gexp)
@@ -111,7 +112,9 @@ (define-module (guix channels)
             channel-news-entry-title
             channel-news-entry-body
 
-            channel-news-for-commit))
+            channel-news-for-commit
+
+            read-channels-file))
 
 ;;; Commentary:
 ;;;
@@ -1086,6 +1089,15 @@ (define* (channel->code channel #:key (include-introduction? #t))
                                  intro))))))
             '()))))
 
+(define (read-channels-file file)
+  "Return channel list read from FILE.
+
+The file shall have format produced by `guix describe --format=channels'."
+  (let ((result (load* file (make-user-module '((guix channels))))))
+    (if (and (list? result) (every channel? result))
+        result
+        (leave (G_ "'~a' did not return a list of channels~%") file))))
+
 \f
 ;;;
 ;;; News.
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 58d3cd7e83..7240b2f25e 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -750,21 +750,15 @@ (define (channel-list opts)
   (define global-file
     (string-append %sysconfdir "/guix/channels.scm"))
 
-  (define (load-channels file)
-    (let ((result (load* file (make-user-module '((guix channels))))))
-      (if (and (list? result) (every channel? result))
-          result
-          (leave (G_ "'~a' did not return a list of channels~%") file))))
-
   (define channels
     (cond (file
-           (load-channels file))
+           (read-channels-file file))
           ((and (not ignore-channel-files?)
                 (file-exists? default-file))
-           (load-channels default-file))
+           (read-channels-file default-file))
           ((and (not ignore-channel-files?)
                 (file-exists? global-file))
-           (load-channels global-file))
+           (read-channels-file global-file))
           (else
            %default-channels)))
 
-- 
2.41.0





  parent reply	other threads:[~2024-05-08 23:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-08 22:59 [bug#70839] [PATCH 0/3] Minor changes to `channels' field and related doc Tomas Volf
2024-05-08 23:13 ` [bug#70839] [PATCH 1/3] doc: Warn about extra-special-file usage in /etc Tomas Volf
2024-05-08 23:13 ` Tomas Volf [this message]
2024-05-08 23:13 ` [bug#70839] [PATCH 3/3] services: guix: Default `channels' field to #f Tomas Volf
2024-06-26 21:41 ` bug#70839: [PATCH 0/3] Minor changes to `channels' field and related doc Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='06234d6dbf04c97da49ecadb8f8d139bf1fe1536.1715208954.git.~@wolfsden.cz' \
    --to=~@wolfsden.cz \
    --cc=70839@debbugs.gnu.org \
    --cc=dev@jpoiret.xyz \
    --cc=guix@cbaines.net \
    --cc=ludo@gnu.org \
    --cc=me@tobias.gr \
    --cc=othacehe@gnu.org \
    --cc=rekado@elephly.net \
    --cc=zimon.toutoune@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.