derivations: Add #:local-build? parameter for derivations.
* guix/derivations.scm (derivation): Add #:local-build? parameter and honor it. (build-expression->derivation): Likewise. * doc/guix.texi (Derivations): Update documentation of these procedures.
This commit is contained in:
parent
b6cbb314d9
commit
1909431c5b
|
@ -1452,7 +1452,11 @@ derivations as Scheme objects, along with procedures to create and
|
||||||
otherwise manipulate derivations. The lowest-level primitive to create
|
otherwise manipulate derivations. The lowest-level primitive to create
|
||||||
a derivation is the @code{derivation} procedure:
|
a derivation is the @code{derivation} procedure:
|
||||||
|
|
||||||
@deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] [#:hash-mode #f] [#:inputs '()] [#:env-vars '()] [#:system (%current-system)] [#:references-graphs #f]
|
@deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
|
||||||
|
@var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
|
||||||
|
[#:hash-mode #f] [#:inputs '()] [#:env-vars '()] @
|
||||||
|
[#:system (%current-system)] [#:references-graphs #f] @
|
||||||
|
[#:local-build? #f]
|
||||||
Build a derivation with the given arguments, and return the resulting
|
Build a derivation with the given arguments, and return the resulting
|
||||||
@code{<derivation>} object.
|
@code{<derivation>} object.
|
||||||
|
|
||||||
|
@ -1464,6 +1468,11 @@ When @var{references-graphs} is true, it must be a list of file
|
||||||
name/store path pairs. In that case, the reference graph of each store
|
name/store path pairs. In that case, the reference graph of each store
|
||||||
path is exported in the build environment in the corresponding file, in
|
path is exported in the build environment in the corresponding file, in
|
||||||
a simple text format.
|
a simple text format.
|
||||||
|
|
||||||
|
When @var{local-build?} is true, declare that the derivation is not a
|
||||||
|
good candidate for offloading and should rather be built locally
|
||||||
|
(@pxref{Daemon Offload Setup}). This is the case for small derivations
|
||||||
|
where the costs of data transfers would outweigh the benefits.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
|
@ -1494,7 +1503,7 @@ the caller to directly pass a Guile expression as the build script:
|
||||||
[#:system (%current-system)] [#:inputs '()] @
|
[#:system (%current-system)] [#:inputs '()] @
|
||||||
[#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
|
[#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
|
||||||
[#:env-vars '()] [#:modules '()] @
|
[#:env-vars '()] [#:modules '()] @
|
||||||
[#:references-graphs #f] [#:guile-for-build #f]
|
[#:references-graphs #f] [#:local-build? #f] [#:guile-for-build #f]
|
||||||
Return a derivation that executes Scheme expression @var{exp} as a
|
Return a derivation that executes Scheme expression @var{exp} as a
|
||||||
builder for derivation @var{name}. @var{inputs} must be a list of
|
builder for derivation @var{name}. @var{inputs} must be a list of
|
||||||
@code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
|
@code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
|
||||||
|
@ -1516,7 +1525,8 @@ terminates by passing the result of @var{exp} to @code{exit}; thus, when
|
||||||
@var{guile-for-build} is omitted or is @code{#f}, the value of the
|
@var{guile-for-build} is omitted or is @code{#f}, the value of the
|
||||||
@code{%guile-for-build} fluid is used instead.
|
@code{%guile-for-build} fluid is used instead.
|
||||||
|
|
||||||
See the @code{derivation} procedure for the meaning of @var{references-graphs}.
|
See the @code{derivation} procedure for the meaning of @var{references-graphs}
|
||||||
|
and @var{local-build?}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -532,7 +532,8 @@ the derivation called NAME with hash HASH."
|
||||||
(system (%current-system)) (env-vars '())
|
(system (%current-system)) (env-vars '())
|
||||||
(inputs '()) (outputs '("out"))
|
(inputs '()) (outputs '("out"))
|
||||||
hash hash-algo hash-mode
|
hash hash-algo hash-mode
|
||||||
references-graphs)
|
references-graphs
|
||||||
|
local-build?)
|
||||||
"Build a derivation with the given arguments, and return the resulting
|
"Build a derivation with the given arguments, and return the resulting
|
||||||
<derivation> object. When HASH, HASH-ALGO, and HASH-MODE are given, a
|
<derivation> object. When HASH, HASH-ALGO, and HASH-MODE are given, a
|
||||||
fixed-output derivation is created---i.e., one whose result is known in
|
fixed-output derivation is created---i.e., one whose result is known in
|
||||||
|
@ -540,7 +541,11 @@ advance, such as a file download.
|
||||||
|
|
||||||
When REFERENCES-GRAPHS is true, it must be a list of file name/store path
|
When REFERENCES-GRAPHS is true, it must be a list of file name/store path
|
||||||
pairs. In that case, the reference graph of each store path is exported in
|
pairs. In that case, the reference graph of each store path is exported in
|
||||||
the build environment in the corresponding file, in a simple text format."
|
the build environment in the corresponding file, in a simple text format.
|
||||||
|
|
||||||
|
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."
|
||||||
(define (add-output-paths drv)
|
(define (add-output-paths drv)
|
||||||
;; Return DRV with an actual store path for each of its output and the
|
;; Return DRV with an actual store path for each of its output and the
|
||||||
;; corresponding environment variable.
|
;; corresponding environment variable.
|
||||||
|
@ -571,6 +576,10 @@ the build environment in the corresponding file, in a simple text format."
|
||||||
;; Some options are passed to the build daemon via the env. vars of
|
;; Some options are passed to the build daemon via the env. vars of
|
||||||
;; derivations (urgh!). We hide that from our API, but here is the place
|
;; derivations (urgh!). We hide that from our API, but here is the place
|
||||||
;; where we kludgify those options.
|
;; where we kludgify those options.
|
||||||
|
(let ((env-vars (if local-build?
|
||||||
|
`(("preferLocalBuild" . "1")
|
||||||
|
,@env-vars)
|
||||||
|
env-vars)))
|
||||||
(match references-graphs
|
(match references-graphs
|
||||||
(((file . path) ...)
|
(((file . path) ...)
|
||||||
(let ((value (map (cut string-append <> " " <>)
|
(let ((value (map (cut string-append <> " " <>)
|
||||||
|
@ -580,7 +589,7 @@ the build environment in the corresponding file, in a simple text format."
|
||||||
`(("exportReferencesGraph" . ,(string-join value " "))
|
`(("exportReferencesGraph" . ,(string-join value " "))
|
||||||
,@env-vars)))
|
,@env-vars)))
|
||||||
(#f
|
(#f
|
||||||
env-vars)))
|
env-vars))))
|
||||||
|
|
||||||
(define (env-vars-with-empty-outputs env-vars)
|
(define (env-vars-with-empty-outputs env-vars)
|
||||||
;; Return a variant of ENV-VARS where each OUTPUTS is associated with an
|
;; Return a variant of ENV-VARS where each OUTPUTS is associated with an
|
||||||
|
@ -904,7 +913,8 @@ they can refer to each other."
|
||||||
(env-vars '())
|
(env-vars '())
|
||||||
(modules '())
|
(modules '())
|
||||||
guile-for-build
|
guile-for-build
|
||||||
references-graphs)
|
references-graphs
|
||||||
|
local-build?)
|
||||||
"Return a derivation that executes Scheme expression EXP as a builder
|
"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)
|
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
|
tuples; when SUB-DRV is omitted, \"out\" is assumed. MODULES is a list
|
||||||
|
@ -923,7 +933,8 @@ EXP returns #f, the build is considered to have failed.
|
||||||
EXP is built using GUILE-FOR-BUILD (a derivation). When GUILE-FOR-BUILD is
|
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.
|
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."
|
See the `derivation' procedure for the meaning of REFERENCES-GRAPHS and
|
||||||
|
LOCAL-BUILD?."
|
||||||
(define guile-drv
|
(define guile-drv
|
||||||
(or guile-for-build (%guile-for-build)))
|
(or guile-for-build (%guile-for-build)))
|
||||||
|
|
||||||
|
@ -1046,4 +1057,5 @@ See the `derivation' procedure for the meaning of REFERENCES-GRAPHS."
|
||||||
|
|
||||||
#:hash hash #:hash-algo hash-algo
|
#:hash hash #:hash-algo hash-algo
|
||||||
#:outputs outputs
|
#:outputs outputs
|
||||||
#:references-graphs references-graphs)))
|
#:references-graphs references-graphs
|
||||||
|
#:local-build? local-build?)))
|
||||||
|
|
Loading…
Reference in New Issue