gexp: Add 'load-path?' field to <scheme-file>.

* guix/gexp.scm (<scheme-file>)[load-path?]: New field.
(scheme-file): Add #:set-load-path? and honor it.
(scheme-file-compiler): Pass #:set-load-path? to 'gexp->file'.
* doc/guix.texi (G-Expressions): Document it.
This commit is contained in:
Ludovic Courtès 2020-04-22 15:24:47 +02:00
parent f916ac128a
commit 34faf63ebc
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
2 changed files with 9 additions and 6 deletions

View File

@ -7955,7 +7955,8 @@ The resulting file holds references to all the dependencies of @var{exp}
or a subset thereof. or a subset thereof.
@end deffn @end deffn
@deffn {Scheme Procedure} scheme-file @var{name} @var{exp} [#:splice? #f] @deffn {Scheme Procedure} scheme-file @var{name} @var{exp} @
[#:splice? #f] [#:set-load-path? #t]
Return an object representing the Scheme file @var{name} that contains Return an object representing the Scheme file @var{name} that contains
@var{exp}. @var{exp}.

View File

@ -472,24 +472,26 @@ This is the declarative counterpart of 'gexp->script'."
#:target target)))) #:target target))))
(define-record-type <scheme-file> (define-record-type <scheme-file>
(%scheme-file name gexp splice?) (%scheme-file name gexp splice? load-path?)
scheme-file? scheme-file?
(name scheme-file-name) ;string (name scheme-file-name) ;string
(gexp scheme-file-gexp) ;gexp (gexp scheme-file-gexp) ;gexp
(splice? scheme-file-splice?)) ;Boolean (splice? scheme-file-splice?) ;Boolean
(load-path? scheme-file-set-load-path?)) ;Boolean
(define* (scheme-file name gexp #:key splice?) (define* (scheme-file name gexp #:key splice? (set-load-path? #t))
"Return an object representing the Scheme file NAME that contains GEXP. "Return an object representing the Scheme file NAME that contains GEXP.
This is the declarative counterpart of 'gexp->file'." This is the declarative counterpart of 'gexp->file'."
(%scheme-file name gexp splice?)) (%scheme-file name gexp splice? set-load-path?))
(define-gexp-compiler (scheme-file-compiler (file <scheme-file>) (define-gexp-compiler (scheme-file-compiler (file <scheme-file>)
system target) system target)
;; Compile FILE by returning a derivation that builds the file. ;; Compile FILE by returning a derivation that builds the file.
(match file (match file
(($ <scheme-file> name gexp splice?) (($ <scheme-file> name gexp splice? set-load-path?)
(gexp->file name gexp (gexp->file name gexp
#:set-load-path? set-load-path?
#:splice? splice? #:splice? splice?
#:system system #:system system
#:target target)))) #:target target))))