[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Version from file in a package
From: |
Attila Lendvai |
Subject: |
Re: Version from file in a package |
Date: |
Sat, 23 Sep 2023 12:22:15 +0000 |
this may be related (also see the discussion):
(current-filename) is #f when guix pull'ing
https://issues.guix.gnu.org/55464
i haven't yet double-checked Ludo's recommendation to use INCLUDE, which should
work, but it didn't for me. my current solution is this:
(define (%read-module-relative-file module filename)
(with-input-from-file
(or (search-path %load-path
(string-append (dirname (module-filename module))
"/" filename))
(error "%read-module-relative-file failed for" filename))
(lambda _
(values (read) ; version
(read))))) ; hashes
(define-syntax read-hashes-file
(lambda (syn)
(syntax-case syn ()
((_ filename)
(with-syntax
;; Reads the file at compile time and macroexpands to the first form
in it.
((form (call-with-values
(lambda _
(%read-module-relative-file (current-module)
(string-append "hashes/"
(syntax->datum #'filename)
".hashes")))
(lambda (version hashes)
#`(values '#,version '#,hashes)))))
#'form)))))
HTH,
--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“Never argue with someone whose TV is bigger than their bookshelf.”
— Emilia Clarke