From dfe569fdc02b1101ecc3bf055789d63799aa1b22 Mon Sep 17 00:00:00 2001 From: Hilton Chain Date: Fri, 12 Sep 2025 14:33:50 +0800 Subject: [PATCH] utils: computed-substitution-with-inputs: Support directory substitution. * modules/rosenthal/utils/file.scm (computed-substitution-with-inputs): Support directory substitution. Error when pattern not found. --- modules/rosenthal/utils/file.scm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/rosenthal/utils/file.scm b/modules/rosenthal/utils/file.scm index e9eb61a..b1c71a7 100644 --- a/modules/rosenthal/utils/file.scm +++ b/modules/rosenthal/utils/file.scm @@ -16,11 +16,20 @@ (computed-file name #~(begin - (use-modules (guix build utils)) + (use-modules (ice-9 match) + (guix build utils)) (copy-file #$file #$output) (substitute* #$output (("\\$\\$([^\\$]+)\\$\\$" _ path) - (search-path '#$inputs path))))))) + (let loop ((candidates '#$inputs)) + (if (null? candidates) + (error "file '~a' not found" path) + (match candidates + ((candidate . rest) + (let ((full-path (in-vicinity candidate path))) + (if (file-exists? full-path) + full-path + (loop rest))))))))))))) (define (file-content file) (call-with-input-file (canonicalize-path file) get-string-all))