aboutsummaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-03-23 18:21:28 +0100
committerLudovic Courtès <ludo@gnu.org>2018-03-23 18:41:07 +0100
commit1ae16033f34cebe802023922436883867010850f (patch)
tree8627cad912e9238153e64e41ad733dade018f4df /guix
parent7aff5d025d65c0fa44e6f897471b2b8b78b98738 (diff)
downloadgnu-guix-1ae16033f34cebe802023922436883867010850f.tar
gnu-guix-1ae16033f34cebe802023922436883867010850f.tar.gz
gexp: 'gexp->script' and 'gexp->file' have a new #:module-path parameter.
* guix/gexp.scm (load-path-expression): Add 'path' optional parameter. (gexp->script): Add #:module-path and honor it. (gexp->file): Likewise. * tests/gexp.scm ("gexp->script #:module-path"): New test. * doc/guix.texi (G-Expressions): Update accordingly.
Diffstat (limited to 'guix')
-rw-r--r--guix/gexp.scm35
1 files changed, 23 insertions, 12 deletions
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 8dea022e04..4a2e5a682e 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
;;;
;;; This file is part of GNU Guix.
@@ -1116,11 +1116,14 @@ they can refer to each other."
(module-ref (resolve-interface '(gnu packages guile))
'guile-2.2))
-(define (load-path-expression modules)
+(define* (load-path-expression modules #:optional (path %load-path))
"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)))
+'%load-compiled-path' to point to MODULES, a list of module names. MODULES
+are searched for in PATH."
+ (mlet %store-monad ((modules (imported-modules modules
+ #:module-path path))
+ (compiled (compiled-modules modules
+ #:module-path path)))
(return (gexp (eval-when (expand load eval)
(set! %load-path
(cons (ungexp modules) %load-path))
@@ -1129,11 +1132,13 @@ they can refer to each other."
%load-compiled-path)))))))
(define* (gexp->script name exp
- #:key (guile (default-guile)))
+ #:key (guile (default-guile))
+ (module-path %load-path))
"Return an executable script NAME that runs EXP using GUILE, with EXP's
-imported modules in its search path."
+imported modules in its search path. Look up EXP's modules in MODULE-PATH."
(mlet %store-monad ((set-load-path
- (load-path-expression (gexp-modules exp))))
+ (load-path-expression (gexp-modules exp)
+ module-path)))
(gexp->derivation name
(gexp
(call-with-output-file (ungexp output)
@@ -1148,12 +1153,16 @@ imported modules in its search path."
(write '(ungexp set-load-path) port)
(write '(ungexp exp) port)
- (chmod port #o555)))))))
+ (chmod port #o555))))
+ #:module-path module-path)))
-(define* (gexp->file name exp #:key (set-load-path? #t))
+(define* (gexp->file name exp #:key
+ (set-load-path? #t)
+ (module-path %load-path))
"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."
+and '%load-compiled-path' to honor EXP's imported modules. Lookup EXP's
+modules in MODULE-PATH."
(match (if set-load-path? (gexp-modules exp) '())
(() ;zero modules
(gexp->derivation name
@@ -1164,13 +1173,15 @@ and '%load-compiled-path' to honor EXP's imported modules."
#:local-build? #t
#:substitutable? #f))
((modules ...)
- (mlet %store-monad ((set-load-path (load-path-expression modules)))
+ (mlet %store-monad ((set-load-path (load-path-expression modules
+ module-path)))
(gexp->derivation name
(gexp
(call-with-output-file (ungexp output)
(lambda (port)
(write '(ungexp set-load-path) port)
(write '(ungexp exp) port))))
+ #:module-path module-path
#:local-build? #t
#:substitutable? #f)))))