gexp: 'gexp->file' emits code to set '%load-path'.
* guix/gexp.scm (gexp->file): Add #:set-load-path? parameter and honor it. * gnu/system.scm (operating-system-parameters-file): Pass #:set-load-path? #f. * doc/guix.texi (G-Expressions): Adjust accordingly.
This commit is contained in:
parent
dd8d1a3046
commit
2b4185792d
|
@ -3943,8 +3943,12 @@ script, and @var{modules} is the list of modules visible to that script.
|
||||||
This is the declarative counterpart of @code{gexp->script}.
|
This is the declarative counterpart of @code{gexp->script}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Monadic Procedure} gexp->file @var{name} @var{exp}
|
@deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
|
||||||
|
[#:set-load-path? #t]
|
||||||
Return a derivation that builds a file @var{name} containing @var{exp}.
|
Return a derivation that builds a file @var{name} containing @var{exp}.
|
||||||
|
When @var{set-load-path?} is true, emit code in the resulting file to
|
||||||
|
set @code{%load-path} and @code{%load-compiled-path} to honor
|
||||||
|
@var{exp}'s imported modules.
|
||||||
|
|
||||||
The resulting file holds references to all the dependencies of @var{exp}
|
The resulting file holds references to all the dependencies of @var{exp}
|
||||||
or a subset thereof.
|
or a subset thereof.
|
||||||
|
|
|
@ -731,7 +731,8 @@ this file is the reconstruction of GRUB menu entries for old configurations."
|
||||||
(kernel #$(operating-system-kernel os))
|
(kernel #$(operating-system-kernel os))
|
||||||
(kernel-arguments
|
(kernel-arguments
|
||||||
#$(operating-system-kernel-arguments os))
|
#$(operating-system-kernel-arguments os))
|
||||||
(initrd #$initrd)))))
|
(initrd #$initrd))
|
||||||
|
#:set-load-path? #f)))
|
||||||
|
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
|
|
|
@ -1026,15 +1026,29 @@ its search path."
|
||||||
(write '(ungexp exp) port)
|
(write '(ungexp exp) port)
|
||||||
(chmod port #o555)))))))
|
(chmod port #o555)))))))
|
||||||
|
|
||||||
(define (gexp->file name exp)
|
(define* (gexp->file name exp #:key (set-load-path? #t))
|
||||||
"Return a derivation that builds a file NAME containing EXP."
|
"Return a derivation that builds a file NAME containing EXP. When
|
||||||
(gexp->derivation name
|
SET-LOAD-PATH? is true, emit code in the resulting file to set '%load-path'
|
||||||
(gexp
|
and '%load-compiled-path' to honor EXP's imported modules."
|
||||||
(call-with-output-file (ungexp output)
|
(match (if set-load-path? (gexp-modules exp) '())
|
||||||
(lambda (port)
|
(() ;zero modules
|
||||||
(write '(ungexp exp) port))))
|
(gexp->derivation name
|
||||||
#:local-build? #t
|
(gexp
|
||||||
#:substitutable? #f))
|
(call-with-output-file (ungexp output)
|
||||||
|
(lambda (port)
|
||||||
|
(write '(ungexp exp) port))))
|
||||||
|
#:local-build? #t
|
||||||
|
#:substitutable? #f))
|
||||||
|
((modules ...)
|
||||||
|
(mlet %store-monad ((set-load-path (load-path-expression modules)))
|
||||||
|
(gexp->derivation name
|
||||||
|
(gexp
|
||||||
|
(call-with-output-file (ungexp output)
|
||||||
|
(lambda (port)
|
||||||
|
(write '(ungexp set-load-path) port)
|
||||||
|
(write '(ungexp exp) port))))
|
||||||
|
#:local-build? #t
|
||||||
|
#:substitutable? #f)))))
|
||||||
|
|
||||||
(define* (text-file* name #:rest text)
|
(define* (text-file* name #:rest text)
|
||||||
"Return as a monadic value a derivation that builds a text file containing
|
"Return as a monadic value a derivation that builds a text file containing
|
||||||
|
|
Loading…
Reference in New Issue