aboutsummaryrefslogtreecommitdiffstats
path: root/oni/gexp.scm
blob: b0d925858eebd9d5bb37995959ea8cdb145d003e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
(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))