[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/07: gexp: Factorize load-path-setting expression.
From: |
Ludovic Courtès |
Subject: |
05/07: gexp: Factorize load-path-setting expression. |
Date: |
Mon, 4 Jul 2016 22:17:31 +0000 (UTC) |
civodul pushed a commit to branch wip-gexp-imported-modules
in repository guix.
commit 01221561c6c077a0242fdbd0d996b3c372e488b9
Author: Ludovic Courtès <address@hidden>
Date: Mon Jul 4 22:19:23 2016 +0200
gexp: Factorize load-path-setting expression.
* guix/gexp.scm (load-path-expression): New procedure.
(gexp->script): Use it.
---
guix/gexp.scm | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 8e1c56c..de0a98a 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -989,6 +989,18 @@ they can refer to each other."
(module-ref (resolve-interface '(gnu packages commencement))
'guile-final))
+(define (load-path-expression modules)
+ "Return as a monadic value a gexp that sets '%load-path' and
+'%load-compiled-path' to point to MODULES, a list of module names."
+ (mlet %store-monad ((modules (imported-modules modules))
+ (compiled (compiled-modules modules)))
+ (return (gexp (eval-when (expand load eval)
+ (set! %load-path
+ (cons (ungexp modules) %load-path))
+ (set! %load-compiled-path
+ (cons (ungexp compiled)
+ %load-compiled-path)))))))
+
(define* (gexp->script name exp
#:key (modules '()) (guile (default-guile)))
"Return an executable script NAME that runs EXP using GUILE with MODULES in
@@ -996,8 +1008,7 @@ its search path."
(define %modules
(append (gexp-modules exp) modules))
- (mlet %store-monad ((modules (imported-modules %modules))
- (compiled (compiled-modules %modules)))
+ (mlet %store-monad ((set-load-path (load-path-expression %modules)))
(gexp->derivation name
(gexp
(call-with-output-file (ungexp output)
@@ -1010,16 +1021,7 @@ its search path."
"#!~a/bin/guile --no-auto-compile~%!#~%"
(ungexp guile))
- ;; Write the 'eval-when' form so that it can be
- ;; compiled.
- (write
- '(eval-when (expand load eval)
- (set! %load-path
- (cons (ungexp modules) %load-path))
- (set! %load-compiled-path
- (cons (ungexp compiled)
- %load-compiled-path)))
- port)
+ (write '(ungexp set-load-path) port)
(write '(ungexp exp) port)
(chmod port #o555)))))))
- branch wip-gexp-imported-modules created (now 5cb9908), Ludovic Courtès, 2016/07/04
- 04/07: linux-container: Fix list of imported modules., Ludovic Courtès, 2016/07/04
- 01/07: gexp: Keep only a single 'references' field., Ludovic Courtès, 2016/07/04
- 06/07: gexp: 'gexp->file' emits code to set '%load-path'., Ludovic Courtès, 2016/07/04
- 05/07: gexp: Factorize load-path-setting expression.,
Ludovic Courtès <=
- 02/07: gexp: Add 'with-imported-modules' macro., Ludovic Courtès, 2016/07/04
- 07/07: gnu: Use 'gexp->file' in conjunction with 'with-imported-modules'., Ludovic Courtès, 2016/07/04
- 03/07: gnu: Switch to 'with-imported-modules'., Ludovic Courtès, 2016/07/04