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).
master
noah metz 2026-07-28 21:57:52 -06:00
parent 7a6a30f515
commit ff382c6056
4 changed files with 20 additions and 16 deletions

@ -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)

@ -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)

@ -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)

@ -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"