summaryrefslogtreecommitdiff
path: root/guix/gexp.scm
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2018-04-11 17:19:06 -0400
committerMark H Weaver <mhw@netris.org>2018-04-11 17:19:06 -0400
commit3c0316169b47a1c035390aae8a211dcbedc8f5f3 (patch)
tree3c89536e1ef0c1db4339175bce7ff64d2e42f591 /guix/gexp.scm
parentecfe88b76496c62fad4f6b6c593318378cebba22 (diff)
parent87a841b2d4b7f8bfd661ba2d2cd2bbce7f490fbd (diff)
downloadgnu-guix-3c0316169b47a1c035390aae8a211dcbedc8f5f3.tar
gnu-guix-3c0316169b47a1c035390aae8a211dcbedc8f5f3.tar.gz
Merge branch 'master' into core-updates
Diffstat (limited to 'guix/gexp.scm')
-rw-r--r--guix/gexp.scm39
1 files changed, 26 insertions, 13 deletions
diff --git a/guix/gexp.scm b/guix/gexp.scm
index bedb387edb..5ffe505be1 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -406,23 +406,24 @@ This is the declarative counterpart of 'gexp->script'."
#:guile (or guile (default-guile))))))
(define-record-type <scheme-file>
- (%scheme-file name gexp)
+ (%scheme-file name gexp splice?)
scheme-file?
(name scheme-file-name) ;string
- (gexp scheme-file-gexp)) ;gexp
+ (gexp scheme-file-gexp) ;gexp
+ (splice? scheme-file-splice?)) ;Boolean
-(define* (scheme-file name gexp)
+(define* (scheme-file name gexp #:key splice?)
"Return an object representing the Scheme file NAME that contains GEXP.
This is the declarative counterpart of 'gexp->file'."
- (%scheme-file name gexp))
+ (%scheme-file name gexp splice?))
(define-gexp-compiler (scheme-file-compiler (file <scheme-file>)
system target)
;; Compile FILE by returning a derivation that builds the file.
(match file
- (($ <scheme-file> name gexp)
- (gexp->file name gexp))))
+ (($ <scheme-file> name gexp splice?)
+ (gexp->file name gexp #:splice? splice?))))
;; Appending SUFFIX to BASE's output file name.
(define-record-type <file-append>
@@ -1170,18 +1171,26 @@ imported modules in its search path. Look up EXP's modules in MODULE-PATH."
(define* (gexp->file name exp #:key
(set-load-path? #t)
- (module-path %load-path))
- "Return a derivation that builds a file NAME containing EXP. When
-SET-LOAD-PATH? is true, emit code in the resulting file to set '%load-path'
-and '%load-compiled-path' to honor EXP's imported modules. Lookup EXP's
-modules in MODULE-PATH."
+ (module-path %load-path)
+ (splice? #f))
+ "Return a derivation that builds a file NAME containing EXP. When SPLICE?
+is true, EXP is considered to be a list of expressions that will be spliced in
+the resulting file.
+
+When SET-LOAD-PATH? is true, emit code in the resulting file to set
+'%load-path' and '%load-compiled-path' to honor EXP's imported modules.
+Lookup EXP's modules in MODULE-PATH."
(match (if set-load-path? (gexp-modules exp) '())
(() ;zero modules
(gexp->derivation name
(gexp
(call-with-output-file (ungexp output)
(lambda (port)
- (write '(ungexp exp) port))))
+ (for-each (lambda (exp)
+ (write exp port))
+ '(ungexp (if splice?
+ exp
+ (gexp ((ungexp exp)))))))))
#:local-build? #t
#:substitutable? #f))
((modules ...)
@@ -1192,7 +1201,11 @@ modules in MODULE-PATH."
(call-with-output-file (ungexp output)
(lambda (port)
(write '(ungexp set-load-path) port)
- (write '(ungexp exp) port))))
+ (for-each (lambda (exp)
+ (write exp port))
+ '(ungexp (if splice?
+ exp
+ (gexp ((ungexp exp)))))))))
#:module-path module-path
#:local-build? #t
#:substitutable? #f)))))