summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-07-03 00:05:16 +0200
committerLudovic Courtès <ludo@gnu.org>2015-07-03 00:30:55 +0200
commit4a6aeb670f74ef895878631bc3d832d08e1cb321 (patch)
treee6c2813bb9d13cb57c4d725614e255392e543a6b /guix
parent322eeb87d0e5bb608ae1c176611a50297c93cbe8 (diff)
downloadgnu-guix-4a6aeb670f74ef895878631bc3d832d08e1cb321.tar
gnu-guix-4a6aeb670f74ef895878631bc3d832d08e1cb321.tar.gz
derivations: Add #:substitutable?, distinguished from #:local-build?.
Fixes <http://bugs.gnu.org/18747>. * guix/derivations.scm (substitutable-derivation?): Rewrite to check for "allowSubstitutes". (derivation): Add #:substitutable? parameter. [user+system-env-vars]: Honor it. (build-expression->derivation): Add #:substitutable? and honor it. * guix/gexp.scm (gexp->derivation): Likewise. * tests/derivations.scm ("derivation-prerequisites-to-build and substitutes, non-substitutable build"): Use #:substitutable? instead of #:local-build?. ("substitutable-derivation?", "derivation-prerequisites-to-build and substitutes, local build"): New tests. * guix/download.scm (url-fetch): Adjust comment. * guix/git-download.scm (git-fetch): Likewise. * guix/build-system/gnu.scm (gnu-build, gnu-cross-build): Use #:substitutable? instead of #:local-build?. * doc/guix.texi (Derivations, G-Expressions): Adjust accordingly.
Diffstat (limited to 'guix')
-rw-r--r--guix/build-system/gnu.scm10
-rw-r--r--guix/derivations.scm29
-rw-r--r--guix/download.scm4
-rw-r--r--guix/gexp.scm5
-rw-r--r--guix/git-download.scm1
5 files changed, 28 insertions, 21 deletions
diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm
index 05b6e6f680..8702c6c915 100644
--- a/guix/build-system/gnu.scm
+++ b/guix/build-system/gnu.scm
@@ -367,10 +367,7 @@ are allowed to refer to."
#:inputs input-drvs
#:outputs outputs
#:modules imported-modules
-
- ;; XXX: Update when
- ;; <http://bugs.gnu.org/18747> is fixed.
- #:local-build? (not substitutable?)
+ #:substitutable? substitutable?
#:allowed-references
(and allowed-references
@@ -513,10 +510,7 @@ platform."
#:inputs (append native-drvs target-drvs)
#:outputs outputs
#:modules imported-modules
-
- ;; XXX: Update when
- ;; <http://bugs.gnu.org/18747> is fixed.
- #:local-build? (not substitutable?)
+ #:substitutable? substitutable?
#:allowed-references
(and allowed-references
diff --git a/guix/derivations.scm b/guix/derivations.scm
index 1056caa70a..f12127f0ed 100644
--- a/guix/derivations.scm
+++ b/guix/derivations.scm
@@ -223,10 +223,13 @@ result is the set of prerequisites of DRV not already in valid."
(("preferLocalBuild" . "1") #f)
(_ #t)))
-(define substitutable-derivation?
- ;; Return #t if the derivation can be substituted. Currently the two are
- ;; synonymous, see <http://bugs.gnu.org/18747>.
- offloadable-derivation?)
+(define (substitutable-derivation? drv)
+ "Return #t if DRV can be substituted."
+ (match (assoc "allowSubstitutes"
+ (derivation-builder-environment-vars drv))
+ (("allowSubstitutes" . value)
+ (string=? value "1"))
+ (_ #t)))
(define (derivation-output-paths drv sub-drvs)
"Return the output paths of outputs SUB-DRVS of DRV."
@@ -692,7 +695,8 @@ HASH-ALGO, of the derivation NAME. RECURSIVE? has the same meaning as for
(inputs '()) (outputs '("out"))
hash hash-algo recursive?
references-graphs allowed-references
- leaked-env-vars local-build?)
+ leaked-env-vars local-build?
+ (substitutable? #t))
"Build a derivation with the given arguments, and return the resulting
<derivation> object. When HASH and HASH-ALGO are given, a
fixed-output derivation is created---i.e., one whose result is known in
@@ -715,7 +719,10 @@ as \"http_proxy\" to be passed to derivations that download files.
When LOCAL-BUILD? is true, declare that the derivation is not a good candidate
for offloading and should rather be built locally. This is the case for small
-derivations where the costs of data transfers would outweigh the benefits."
+derivations where the costs of data transfers would outweigh the benefits.
+
+When SUBSTITUTABLE? is false, declare that substitutes of the derivation's
+output should not be used."
(define (add-output-paths drv)
;; Return DRV with an actual store path for each of its output and the
;; corresponding environment variable.
@@ -753,6 +760,9 @@ derivations where the costs of data transfers would outweigh the benefits."
(let ((env-vars `(,@(if local-build?
`(("preferLocalBuild" . "1"))
'())
+ ,@(if (not substitutable?)
+ `(("allowSubstitutes" . "0"))
+ '())
,@(if allowed-references
`(("allowedReferences"
. ,(string-join allowed-references)))
@@ -1173,7 +1183,7 @@ applied."
guile-for-build
references-graphs
allowed-references
- local-build?)
+ local-build? (substitutable? #t))
"Return a derivation that executes Scheme expression EXP as a builder
for derivation NAME. INPUTS must be a list of (NAME DRV-PATH SUB-DRV)
tuples; when SUB-DRV is omitted, \"out\" is assumed. MODULES is a list
@@ -1193,7 +1203,7 @@ EXP is built using GUILE-FOR-BUILD (a derivation). When GUILE-FOR-BUILD is
omitted or is #f, the value of the `%guile-for-build' fluid is used instead.
See the `derivation' procedure for the meaning of REFERENCES-GRAPHS,
-ALLOWED-REFERENCES, and LOCAL-BUILD?."
+ALLOWED-REFERENCES, LOCAL-BUILD?, and SUBSTITUTABLE?."
(define guile-drv
(or guile-for-build (%guile-for-build)))
@@ -1319,7 +1329,8 @@ ALLOWED-REFERENCES, and LOCAL-BUILD?."
#:outputs outputs
#:references-graphs references-graphs
#:allowed-references allowed-references
- #:local-build? local-build?)))
+ #:local-build? local-build?
+ #:substitutable? substitutable?)))
;;;
diff --git a/guix/download.scm b/guix/download.scm
index 3f7f7badce..9a80af7de6 100644
--- a/guix/download.scm
+++ b/guix/download.scm
@@ -277,8 +277,8 @@ in the store."
;; In general, offloading downloads is not a good idea.
;;#:local-build? #t
;; FIXME: The above would also disable use of
- ;; substitutes, so comment it out; see
- ;; <https://bugs.gnu.org/18747>.
+ ;; substitutes on old daemons, so comment it out;
+ ;; see <https://bugs.gnu.org/18747>.
)))))
(define* (download-to-store store url #:optional (name (basename url))
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 09b51b3936..49dcc99ac3 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -320,7 +320,7 @@ names and file names suitable for the #:allowed-references argument to
references-graphs
allowed-references
leaked-env-vars
- local-build?)
+ local-build? (substitutable? #t))
"Return a derivation NAME that runs EXP (a gexp) with GUILE-FOR-BUILD (a
derivation) on SYSTEM. When TARGET is true, it is used as the
cross-compilation target triplet for packages referred to by EXP.
@@ -439,7 +439,8 @@ The other arguments are as for 'derivation'."
#:references-graphs (and=> graphs graphs-file-names)
#:allowed-references allowed
#:leaked-env-vars leaked-env-vars
- #:local-build? local-build?))))
+ #:local-build? local-build?
+ #:substitutable? substitutable?))))
(define* (gexp-inputs exp #:key native?)
"Return the input list for EXP. When NATIVE? is true, return only native
diff --git a/guix/git-download.scm b/guix/git-download.scm
index f4b48d7a6b..0f2218c13e 100644
--- a/guix/git-download.scm
+++ b/guix/git-download.scm
@@ -90,6 +90,7 @@ HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f."
(gexp->derivation (or name "git-checkout") build
#:system system
;; FIXME: See <https://bugs.gnu.org/18747>.
+ ;; Uncomment when fixed daemons are widely deployed.
;;#:local-build? #t
#:hash-algo hash-algo
#:hash hash