From 3eb982377e32018d7d13c2f492c44a816781787f Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 12 Jun 2012 00:18:14 +0200 Subject: 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. --- guix/derivations.scm | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'guix/derivations.scm') 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))) -- cgit v1.2.3