From fc93e309196ee8009a975b4c0acf712f54581a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 28 Oct 2014 18:05:17 +0100 Subject: [PATCH] derivations: Add 'offloadable-derivation?' and 'substitutable-derivation?'. * guix/derivations.scm (offloadable-derivation?, substitutable-derivation?): New procedures. * tests/derivations.scm ("offloadable-derivation?"): New test. --- guix/derivations.scm | 14 ++++++++++++++ tests/derivations.scm | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/guix/derivations.scm b/guix/derivations.scm index ae9d2f46c7..5a8cc2c57a 100644 --- a/guix/derivations.scm +++ b/guix/derivations.scm @@ -57,6 +57,8 @@ derivation-input-output-paths fixed-output-derivation? + offloadable-derivation? + substitutable-derivation? derivation-hash read-derivation @@ -156,6 +158,18 @@ download with a fixed hash (aka. `fetchurl')." read-derivation)) inputs))))) +(define (offloadable-derivation? drv) + "Return true if DRV can be offloaded, false otherwise." + (match (assoc "preferLocalBuild" + (derivation-builder-environment-vars drv)) + (("preferLocalBuild" . "1") #f) + (_ #t))) + +(define substitutable-derivation? + ;; Return #t if the derivation can be substituted. Currently the two are + ;; synonymous, see . + offloadable-derivation?) + (define* (derivation-prerequisites-to-build store drv #:key (outputs diff --git a/tests/derivations.scm b/tests/derivations.scm index e774fed4c3..698640b548 100644 --- a/tests/derivations.scm +++ b/tests/derivations.scm @@ -173,6 +173,12 @@ (= (stat:ino (lstat file1)) (stat:ino (lstat file2)))))))) +(test-assert "offloadable-derivation?" + (and (offloadable-derivation? (derivation %store "foo" %bash '())) + (not (offloadable-derivation? + (derivation %store "foo" %bash '() + #:local-build? #t))))) + (test-assert "fixed-output-derivation?" (let* ((builder (add-text-to-store %store "my-fixed-builder.sh" "echo -n hello > $out" '()))