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.
master
noah metz 2026-07-28 22:05:52 -06:00
parent ff382c6056
commit e51cb78456
1 changed files with 10 additions and 2 deletions

@ -11,9 +11,17 @@
#:use-module (guix channels)
#:use-module ((ice-9 ftw) #:select (scandir)))
;; ./channels.d only resolves when the process's CWD happens to be this
;; file's own directory, which isn't true once guix pull loads this as a
;; plain module (e.g. from the store) to build its package cache -- anchor
;; to this file's own location instead.
(define here (dirname (current-filename)))
(define channels-directory (string-append here "/channels.d"))
(define channel-files
(scandir "./channels.d"
(scandir channels-directory
(lambda (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)