dotfiles/oni/gexp.scm

20 lines
780 B
Scheme

(define-module (oni gexp)
#:use-module (guix gexp)
#:export (mixed-executable-file))
(define* (mixed-executable-file name #:key guile #:rest text)
"Return an object representing store file NAME containing TEXT and having the
executable bit set. TEXT is a sequence of strings and file-like objects, as in:
(mixed-executable-file \"profile\"
\"export PATH=\" coreutils \"/bin:\" grep \"/bin\")"
(define build
(let ((text (if guile (drop text 2) text)))
(gexp (call-with-output-file (ungexp output "out")
(λ (port)
(set-port-encoding! port "UTF-8")
(display (string-append (ungexp-splicing text)) port)
(chmod port #o555))))))
(computed-file name build #:guile guile))