Compare commits

...

3 Commits

Author SHA1 Message Date
noah metz 963576f8da Declare nonguix as a channel dependency in .guix-channel
metznet/machines/otto.scm uses (nongnu packages mozilla), but guix pull
builds this channel's own modules in isolation unless a dependency is
declared, so that module came up as "no code for module" too. Declare
nonguix using the same introduction already used in channels.d/nonguix.scm.
2026-07-28 22:57:33 -06:00
noah metz e51cb78456 Anchor channels.d path to channels.scm's own location, not CWD
"./channels.d" only resolved because guix pull -C channels.scm happened
to be invoked with CWD == this file's directory. Once guix pull loads
this file as a plain module (e.g. from the store, to build its package
cache), CWD is unrelated to the checkout, so scandir returned #f and map
blew up with "Not a list: #f". Use (current-filename) instead so it works
regardless of how/where this file gets loaded from.
2026-07-28 22:05:52 -06:00
noah metz ff382c6056 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).
2026-07-28 21:57:52 -06:00
5 changed files with 43 additions and 18 deletions

@ -1,2 +1,15 @@
;; metznet/machines/otto.scm uses (nongnu packages mozilla), so guix pull
;; needs to know nonguix is a build-time dependency -- otherwise it tries
;; to compile/load this channel's own modules in isolation and fails with
;; "no code for module (nongnu packages mozilla))".
(channel (channel
(version 0)) (version 0)
(dependencies
(channel
(name nonguix)
(url "https://gitlab.com/nonguix/nonguix")
(introduction
(channel-introduction
(version 0)
(commit "897c1a470da759236cc11798f4e0a5f7d4d59fbc")
(signer "2A39 3FFF 68F4 EF7A 3D29 12AF 6F51 20A0 22FB B2D5"))))))

@ -1,5 +1,6 @@
;; See channels.scm for why this needs an explicit import. ;; See channels.scm for why this needs a real define-module.
(use-modules (guix channels)) (define-module (channels.d metznet)
#:use-module (guix channels))
(channel (channel
(name 'metznet-channel) (name 'metznet-channel)

@ -1,5 +1,6 @@
;; See channels.scm for why this needs an explicit import. ;; See channels.scm for why this needs a real define-module.
(use-modules (guix channels)) (define-module (channels.d nonguix)
#:use-module (guix channels))
(channel (channel
(name 'nonguix) (name 'nonguix)

@ -1,5 +1,6 @@
;; See channels.scm for why this needs an explicit import. ;; See channels.scm for why this needs a real define-module.
(use-modules (guix channels)) (define-module (channels.d nonguixgames)
#:use-module (guix channels))
(channel (channel
(name 'guix-gaming-games) (name 'guix-gaming-games)

@ -1,18 +1,27 @@
;; channels.scm -- reads the channels.d dir to get a list of channel objects ;; channels.scm -- reads the channels.d dir to get a list of channel objects
;;
;; `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)))
;; guix pull -C pre-imports (guix channels) into the file's environment ;; ./channels.d only resolves when the process's CWD happens to be this
;; (see load-channels/make-user-module in guix/scripts/pull.scm), which is ;; file's own directory, which isn't true once guix pull loads this as a
;; why this worked without an explicit import. But `guix pull` also ;; plain module (e.g. from the store) to build its package cache -- anchor
;; compiles every .scm file under this channel's own checkout as an ;; to this file's own location instead.
;; ordinary package module (see standard-module-derivation), and that (define here (dirname (current-filename)))
;; environment does NOT pre-import it -- so `channel` (a macro from (guix
;; channels), used in channels.d/*.scm) and %default-channels come up (define channels-directory (string-append here "/channels.d"))
;; unbound there unless imported explicitly.
(use-modules (gnu) (guix channels) ((ice-9 ftw) #:select (scandir)))
(define channel-files (define channel-files
(scandir "./channels.d" (scandir channels-directory
(lambda (file) (lambda (file)
(string-suffix? ".scm" file)))) (string-suffix? ".scm" file))))
(append (map (lambda (file) (load (string-append "./channels.d/" file))) channel-files) %default-channels) (append (map (lambda (file) (load (string-append channels-directory "/" file))) channel-files) %default-channels)