diff --git a/guix/derivations.scm b/guix/derivations.scm index 69cef1a4cd7cc120bfc588bd6076fb065404feca..5e96d9fa3caa296c184566e5e4cf70027b5aec27 100644 --- a/guix/derivations.scm +++ b/guix/derivations.scm @@ -58,6 +58,7 @@ (define-module (guix derivations) derivation-input-output-paths derivation-name + derivation-output-names fixed-output-derivation? offloadable-derivation? substitutable-derivation? @@ -135,6 +136,12 @@ (define (derivation-name drv) (let ((base (store-path-package-name (derivation-file-name drv)))) (string-drop-right base 4))) +(define (derivation-output-names drv) + "Return the names of the outputs of DRV." + (match (derivation-outputs drv) + (((names . _) ...) + names))) + (define (fixed-output-derivation? drv) "Return #t if DRV is a fixed-output derivation, such as the result of a download with a fixed hash (aka. `fetchurl')." @@ -180,9 +187,7 @@ (define substitutable-derivation? (define* (derivation-prerequisites-to-build store drv #:key (outputs - (map - car - (derivation-outputs drv))) + (derivation-output-names drv)) (use-substitutes? #t)) "Return two values: the list of derivation-inputs required to build the OUTPUTS of DRV and not already available in STORE, recursively, and the list @@ -844,7 +849,7 @@ (define rewritten-input replacements)))) (derivation-builder-environment-vars drv)) #:inputs (append (map list sources) inputs) - #:outputs (map car (derivation-outputs drv)) + #:outputs (derivation-output-names drv) #:hash (match (derivation-outputs drv) ((($ <derivation-output> _ algo hash)) hash) diff --git a/tests/derivations.scm b/tests/derivations.scm index 4b36758c25087a10014cff9b7a6448dbc0cfc80c..25e6f756577fae85957457ee7803f992eca7dcb3 100644 --- a/tests/derivations.scm +++ b/tests/derivations.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -178,6 +178,14 @@ (define prefix-len (string-length dir)) (let ((drv (derivation %store "foo-0.0" %bash '()))) (derivation-name drv))) +(test-equal "derivation-output-names" + '(("out") ("bar" "chbouib")) + (let ((drv1 (derivation %store "foo-0.0" %bash '())) + (drv2 (derivation %store "foo-0.0" %bash '() + #:outputs '("bar" "chbouib")))) + (list (derivation-output-names drv1) + (derivation-output-names drv2)))) + (test-assert "offloadable-derivation?" (and (offloadable-derivation? (derivation %store "foo" %bash '())) (not (offloadable-derivation?