summaryrefslogtreecommitdiff
path: root/guix/derivations.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2012-06-12 00:18:14 +0200
committerLudovic Courtès <ludo@gnu.org>2012-06-12 00:18:14 +0200
commit3eb982377e32018d7d13c2f492c44a816781787f (patch)
treee0829f40fcc33d456b4ffccd6994761347fe4e43 /guix/derivations.scm
parent99634e3ff4e16edc1c14145a5913d7c1440dc479 (diff)
Augment `build-expression->derivation' with #:modules; add `http-fetch'.
* guix/derivations.scm (imported-modules): New procedure. (build-expression->derivation): New keyword argument `modules'. Use `imported-modules' when MODULES is non-empty, and pass it with `-L' to GUILE. * guix/build/http.scm, guix/http.scm, tests/builders.scm: New files.
Diffstat (limited to 'guix/derivations.scm')
-rw-r--r--guix/derivations.scm35
1 files changed, 31 insertions, 4 deletions
diff --git a/guix/derivations.scm b/guix/derivations.scm
index c35595fd1e..47023f566c 100644
--- a/guix/derivations.scm
+++ b/guix/derivations.scm
@@ -418,9 +418,27 @@ system, imported, and appears under FINAL-PATH in the resulting store path."
(build-expression->derivation store name (%current-system)
builder files)))
+(define* (imported-modules store modules
+ #:key (name "module-import")
+ (system (%current-system)))
+ "Return a derivation that contains the source files of MODULES, a list of
+module names such as `(ice-9 q)'. All of MODULES must be in the current
+search path."
+ ;; TODO: Determine the closure of MODULES, build the `.go' files,
+ ;; canonicalize the source files through read/write, etc.
+ (let ((files (map (lambda (m)
+ (let ((f (string-append
+ (string-join (map symbol->string m) "/")
+ ".scm")))
+ (cons f (search-path %load-path f))))
+ modules)))
+ (imported-files store files #:name name #:system system)))
+
+
(define* (build-expression->derivation store name system exp inputs
#:key (outputs '("out"))
- hash hash-algo)
+ hash hash-algo
+ (modules '()))
"Return a derivation that executes Scheme expression EXP as a builder for
derivation NAME. INPUTS must be a list of string/derivation-path pairs. EXP
is evaluated in an environment where %OUTPUT is bound to the main output
@@ -449,10 +467,19 @@ INPUTS."
(string-append name "-guile-builder")
(string-append (object->string prologue)
(object->string exp))
- (map cdr inputs))))
- (derivation store name system guile `("--no-auto-compile" ,builder)
+ (map cdr inputs)))
+ (mod-drv (if (null? modules)
+ #f
+ (imported-modules store modules)))
+ (mod-dir (and mod-drv
+ (derivation-path->output-path mod-drv))))
+ (derivation store name system guile
+ `("--no-auto-compile"
+ ,@(if mod-dir `("-L" ,mod-dir) '())
+ ,builder)
'(("HOME" . "/homeless"))
`((,(%guile-for-build))
- (,builder))
+ (,builder)
+ ,@(if mod-drv `((,mod-drv)) '()))
#:hash hash #:hash-algo hash-algo
#:outputs outputs)))