From ff382c60568ce163460efa473545c6ce5e083a60 Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Tue, 28 Jul 2026 21:57:52 -0600 Subject: [PATCH] Fix guix pull: give channels.scm/channels.d/*.scm real define-module clauses guix pull compiles every .scm file under a channel's checkout as an ordinary package module and then loads each by its path-derived module name to build the package cache. channels.scm and channels.d/*.scm never had define-module clauses -- they relied on guix pull -C's implicit (guix channels) import, which only applies to the -C argument itself, not to files swept up as part of the channel's own module tree. That produced first an unbound-variable error on `channel` at compile time, and after adding plain use-modules imports, a "no code for module" error at package-cache load time. Match the dual-purpose pattern already used by metznet/machines/*.scm: a real define-module (so the module system finds it under its expected name) plus a use-module for (guix channels) (so guix pull -C channels.scm still works when it loads these directly). --- channels.d/metznet.scm | 5 +++-- channels.d/nonguix.scm | 5 +++-- channels.d/nonguixgames.scm | 5 +++-- channels.scm | 21 +++++++++++---------- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/channels.d/metznet.scm b/channels.d/metznet.scm index 9bcd3b0..6d5d313 100644 --- a/channels.d/metznet.scm +++ b/channels.d/metznet.scm @@ -1,5 +1,6 @@ -;; See channels.scm for why this needs an explicit import. -(use-modules (guix channels)) +;; See channels.scm for why this needs a real define-module. +(define-module (channels.d metznet) + #:use-module (guix channels)) (channel (name 'metznet-channel) diff --git a/channels.d/nonguix.scm b/channels.d/nonguix.scm index 95520f5..108d749 100644 --- a/channels.d/nonguix.scm +++ b/channels.d/nonguix.scm @@ -1,5 +1,6 @@ -;; See channels.scm for why this needs an explicit import. -(use-modules (guix channels)) +;; See channels.scm for why this needs a real define-module. +(define-module (channels.d nonguix) + #:use-module (guix channels)) (channel (name 'nonguix) diff --git a/channels.d/nonguixgames.scm b/channels.d/nonguixgames.scm index ce1c6ba..544b787 100644 --- a/channels.d/nonguixgames.scm +++ b/channels.d/nonguixgames.scm @@ -1,5 +1,6 @@ -;; See channels.scm for why this needs an explicit import. -(use-modules (guix channels)) +;; See channels.scm for why this needs a real define-module. +(define-module (channels.d nonguixgames) + #:use-module (guix channels)) (channel (name 'guix-gaming-games) diff --git a/channels.scm b/channels.scm index 47e82ff..d37ae87 100644 --- a/channels.scm +++ b/channels.scm @@ -1,14 +1,15 @@ ;; channels.scm -- reads the channels.d dir to get a list of channel objects - -;; guix pull -C pre-imports (guix channels) into the file's environment -;; (see load-channels/make-user-module in guix/scripts/pull.scm), which is -;; why this worked without an explicit import. But `guix pull` also -;; compiles every .scm file under this channel's own checkout as an -;; ordinary package module (see standard-module-derivation), and that -;; environment does NOT pre-import it -- so `channel` (a macro from (guix -;; channels), used in channels.d/*.scm) and %default-channels come up -;; unbound there unless imported explicitly. -(use-modules (gnu) (guix channels) ((ice-9 ftw) #:select (scandir))) +;; +;; `guix pull` also compiles every .scm file under this channel's own +;; checkout as an ordinary package module (see standard-module-derivation) +;; and then loads each by its path-derived module name (e.g. this file as +;; (channels)) to build the package cache -- so, like metznet/machines/*.scm, +;; this needs a real define-module matching its path, not just a bare +;; script relying on guix pull -C's implicit (guix channels) import. +(define-module (channels) + #:use-module (gnu) + #:use-module (guix channels) + #:use-module ((ice-9 ftw) #:select (scandir))) (define channel-files (scandir "./channels.d"