diff options
author | Ludovic Courtès <ludo@gnu.org> | 2012-06-17 16:43:40 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2012-06-17 16:43:40 +0200 |
commit | 0d56a551bf5f1cf94f59cf508b3820bcc8fd8050 (patch) | |
tree | f26b9dab85386c1d7fec7d1a2ad7a2fac0d382fa | |
parent | 5dcfdcaa79800530c4b7ea520b5eb984a5e6b7ca (diff) |
build-expression->derivation: Move module forms at the top-level.
* guix/derivations.scm (build-expression->derivation)[module-form?]: New
procedure.
[prologue]: Add any form of EXP that matches MODULE-FORM?.
[builder]: Remove any MODULE-FORM? from EXP.
-rw-r--r-- | guix/derivations.scm | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/guix/derivations.scm b/guix/derivations.scm index 24ee06c399..b4f27bf74d 100644 --- a/guix/derivations.scm +++ b/guix/derivations.scm @@ -453,7 +453,19 @@ considered to have failed." (string-append (derivation-path->output-path (%guile-for-build)) "/bin/guile")) + (define module-form? + (match-lambda + (((or 'define-module 'use-modules) _ ...) #t) + (_ #f))) + (let* ((prologue `(begin + ,@(match exp + ((_ ...) + ;; Module forms must appear at the top-level so + ;; that any macros they export can be expanded. + (filter module-form? exp)) + (_ `(,exp))) + (define %output (getenv "out")) (define %outputs (map (lambda (o) @@ -473,9 +485,14 @@ considered to have failed." inputs)))) (builder (add-text-to-store store (string-append name "-guile-builder") - (string-append (object->string prologue) - (object->string - `(exit ,exp))) + (string-append + (object->string prologue) + (object->string + `(exit + ,(match exp + ((_ ...) + (remove module-form? exp)) + (_ `(,exp)))))) (map second inputs))) (mod-drv (if (null? modules) #f |