[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/16: gexp: Factorize load-path-setting expression.
From: |
Ludovic Courtès |
Subject: |
05/16: gexp: Factorize load-path-setting expression. |
Date: |
Tue, 12 Jul 2016 20:48:20 +0000 (UTC) |
civodul pushed a commit to branch master
in repository guix.
commit dd8d1a30468dae1412762e54801592f6b475f88e
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 e9274a0..e76a281 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -990,6 +990,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
@@ -997,8 +1009,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)
@@ -1011,16 +1022,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 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 <=
- 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, 2016/07/12
- 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