diff options
author | Ludovic Courtès <ludo@gnu.org> | 2012-10-21 16:57:50 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2012-10-21 17:52:16 +0200 |
commit | 592ef6c88fa8342d23142154c8392f6f1032275f (patch) | |
tree | 30ac28eb6d35a9c336cb8aaacd85554f6c591c0f /guix/packages.scm | |
parent | 095c7a2683509d8a12e1febfd667fdf7d20127e3 (diff) | |
download | gnu-guix-592ef6c88fa8342d23142154c8392f6f1032275f.tar gnu-guix-592ef6c88fa8342d23142154c8392f6f1032275f.tar.gz |
packages: Add support for system-dependent inputs.
* guix/packages.scm (package-derivation)[intern]: New procedure. Pass
#t as the `recursive?' argument, instead of #f.
[expand-input]: New procedure, with code formerly in the body.
Support inputs where the input is a procedure returning a file name or
an <origin>.
Use `expand-input' in the body.
* tests/packages.scm ("trivial with system-dependent input"): New test.
Diffstat (limited to 'guix/packages.scm')
-rw-r--r-- | guix/packages.scm | 71 |
1 files changed, 46 insertions, 25 deletions
diff --git a/guix/packages.scm b/guix/packages.scm index 4b687717e4..9a54eb747a 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -227,6 +227,51 @@ recursively." (define* (package-derivation store package #:optional (system (%current-system))) "Return the derivation of PACKAGE for SYSTEM." + (define (intern file) + ;; Add FILE to the store. Set the `recursive?' bit to #t, so that + ;; file permissions are preserved. + (add-to-store store (basename file) + #t #t "sha256" file)) + + (define expand-input + ;; Expand the given input tuple such that it contains only + ;; references to derivation paths or store paths. + (match-lambda + (((? string? name) (? package? package)) + (list name (package-derivation store package))) + (((? string? name) (? package? package) + (? string? sub-drv)) + (list name (package-derivation store package) + sub-drv)) + (((? string? name) + (and (? string?) (? derivation-path?) drv)) + (list name drv)) + (((? string? name) + (and (? string?) (? file-exists? file))) + ;; Add FILE to the store. When FILE is in the sub-directory of a + ;; store path, it needs to be added anyway, so it can be used as a + ;; source. + (list name (intern file))) + (((? string? name) (? origin? source)) + (list name (package-source-derivation store source))) + ((and i ((? string? name) (? procedure? proc) sub-drv ...)) + ;; This form allows PROC to make a SYSTEM-dependent choice. + + ;; XXX: Currently PROC must return a .drv, a store path, a local + ;; file name, or an <origin>. If it were allowed to return a + ;; package, then `transitive-inputs' and co. would need to be + ;; adjusted. + (let ((input (proc system))) + (if (or (string? input) (origin? input)) + (expand-input (cons* name input sub-drv)) + (raise (condition (&package-input-error + (package package) + (input i))))))) + (x + (raise (condition (&package-input-error + (package package) + (input x))))))) + (or (cached-derivation package system) ;; Compute the derivation and cache the result. Caching is @@ -241,31 +286,7 @@ recursively." outputs) ;; TODO: For `search-paths', add a builder prologue that calls ;; `set-path-environment-variable'. - (let ((inputs (map (match-lambda - (((? string? name) (? package? package)) - (list name (package-derivation store package))) - (((? string? name) (? package? package) - (? string? sub-drv)) - (list name (package-derivation store package) - sub-drv)) - (((? string? name) - (and (? string?) (? derivation-path?) drv)) - (list name drv)) - (((? string? name) - (and (? string?) (? file-exists? file))) - ;; Add FILE to the store. When FILE is in the - ;; sub-directory of a store path, it needs to be - ;; added anyway, so it can be used as a source. - (list name - (add-to-store store (basename file) - #t #f "sha256" file))) - (((? string? name) (? origin? source)) - (list name - (package-source-derivation store source))) - (x - (raise (condition (&package-input-error - (package package) - (input x)))))) + (let ((inputs (map expand-input (package-transitive-inputs package)))) (apply builder |