[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
06/16: gexp: 'gexp->file' emits code to set '%load-path'.
From: |
Ludovic Courtès |
Subject: |
06/16: gexp: 'gexp->file' emits code to set '%load-path'. |
Date: |
Tue, 12 Jul 2016 20:48:20 +0000 (UTC) |
civodul pushed a commit to branch master
in repository guix.
commit 2b4185792d3ec9b43a5c1bb204b6846e5ac0f14a
Author: Ludovic Courtès <address@hidden>
Date: Mon Jul 4 23:54:18 2016 +0200
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.
---
doc/guix.texi | 6 +++++-
gnu/system.scm | 3 ++-
guix/gexp.scm | 32 +++++++++++++++++++++++---------
3 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index a0014e7..abd294e 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -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}.
@end deffn
address@hidden {Monadic Procedure} gexp->file @var{name} @var{exp}
address@hidden {Monadic Procedure} gexp->file @var{name} @var{exp} @
+ [#:set-load-path? #t]
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
address@hidden's imported modules.
The resulting file holds references to all the dependencies of @var{exp}
or a subset thereof.
diff --git a/gnu/system.scm b/gnu/system.scm
index 96ea153..a49b3f2 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -731,7 +731,8 @@ this file is the reconstruction of GRUB menu entries for
old configurations."
(kernel #$(operating-system-kernel os))
(kernel-arguments
#$(operating-system-kernel-arguments os))
- (initrd #$initrd)))))
+ (initrd #$initrd))
+ #:set-load-path? #f)))
;;;
diff --git a/guix/gexp.scm b/guix/gexp.scm
index e76a281..60f8905 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1026,15 +1026,29 @@ its search path."
(write '(ungexp exp) port)
(chmod port #o555)))))))
-(define (gexp->file name exp)
- "Return a derivation that builds a file NAME containing EXP."
- (gexp->derivation name
- (gexp
- (call-with-output-file (ungexp output)
- (lambda (port)
- (write '(ungexp exp) port))))
- #:local-build? #t
- #:substitutable? #f))
+(define* (gexp->file name exp #:key (set-load-path? #t))
+ "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."
+ (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))))
+ #: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)
"Return as a monadic value a derivation that builds a text file containing
- branch master updated (0885881 -> bdff55e), Ludovic Courtès, 2016/07/12
- 04/16: linux-container: Fix list of imported modules., Ludovic Courtès, 2016/07/12
- 05/16: gexp: Factorize load-path-setting expression., Ludovic Courtès, 2016/07/12
- 01/16: gexp: Keep only a single 'references' field., Ludovic Courtès, 2016/07/12
- 06/16: gexp: 'gexp->file' emits code to set '%load-path'.,
Ludovic Courtès <=
- 13/16: gexp: Remove more uses of #:modules., Ludovic Courtès, 2016/07/12
- 12/16: gexp: 'program-file' and 'gexp->script' no longer have #:modules., Ludovic Courtès, 2016/07/12
- 14/16: gnu: Remove unneeded 'imported-modules' fields for 'origin'., Ludovic Courtès, 2016/07/12
- 11/16: gexp: 'computed-file' no longer has a #:modules parameter., Ludovic Courtès, 2016/07/12
- 10/16: download: Use 'with-imported-modules'., Ludovic Courtès, 2016/07/12
- 16/16: gnu: emacs-flycheck: Add missing dependency on emacs-seq., Ludovic Courtès, 2016/07/12
- 02/16: gexp: Add 'with-imported-modules' macro., Ludovic Courtès, 2016/07/12
- 15/16: packages: <origin> no longer has an 'imported-modules' field., Ludovic Courtès, 2016/07/12
- 08/16: services: <shepherd-service> no longer has an 'imported-modules' field., Ludovic Courtès, 2016/07/12
- 09/16: profiles: Use 'with-imported-modules'., Ludovic Courtès, 2016/07/12