derivations: Move 3 positional parameters into keyword parameters.
* guix/derivations.scm (derivation): Turn `system', `env-vars', and `inputs' into keyword parameters. (build-expression->derivation): Adjust accordingly. * gnu/packages/bootstrap.scm (%bootstrap-guile): Likewise. * tests/derivations.scm, tests/store.scm: Likewise. * doc/guix.texi (Derivations): Likewise.
This commit is contained in:
parent
3e9066fcfc
commit
a987d2c025
@ -1113,7 +1113,7 @@ derivations as Scheme objects, along with procedures to create and
|
||||
otherwise manipulate derivations. The lowest-level primitive to create
|
||||
a derivation is the @code{derivation} procedure:
|
||||
|
||||
@deffn {Scheme Procedure} derivation @var{store} @var{name} @var{system} @var{builder} @var{args} @var{env-vars} @var{inputs} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] [#:hash-mode #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)]
|
||||
Build a derivation with the given arguments. Return the resulting store
|
||||
path and @code{<derivation>} object.
|
||||
|
||||
@ -1137,9 +1137,9 @@ to a Bash executable in the store:
|
||||
(let ((builder ; add the Bash script to the store
|
||||
(add-text-to-store store "my-builder.sh"
|
||||
"echo hello world > $out\n" '())))
|
||||
(derivation store "foo" (%current-system)
|
||||
(derivation store "foo"
|
||||
bash `("-e" ,builder)
|
||||
'(("HOME" . "/homeless")) '())))
|
||||
#:env-vars '(("HOME" . "/homeless")))))
|
||||
list)
|
||||
@result{} ("/nix/store/@dots{}-foo.drv" #<<derivation> @dots{}>)
|
||||
@end lisp
|
||||
|
@ -184,9 +184,10 @@ cd $out
|
||||
$out/bin/guile --version~%"
|
||||
mkdir xz guile tar)
|
||||
(list mkdir xz guile tar))))
|
||||
(derivation store name system
|
||||
bash `(,builder) '()
|
||||
`((,bash) (,builder)))))))))
|
||||
(derivation store name
|
||||
bash `(,builder)
|
||||
#:system system
|
||||
#:inputs `((,bash) (,builder)))))))))
|
||||
(package
|
||||
(name "guile-bootstrap")
|
||||
(version "2.0")
|
||||
|
@ -497,8 +497,11 @@ the derivation called NAME with hash HASH."
|
||||
name
|
||||
(string-append name "-" output))))
|
||||
|
||||
(define* (derivation store name system builder args env-vars inputs
|
||||
#:key (outputs '("out")) hash hash-algo hash-mode)
|
||||
(define* (derivation store name builder args
|
||||
#:key
|
||||
(system (%current-system)) (env-vars '())
|
||||
(inputs '()) (outputs '("out"))
|
||||
hash hash-algo hash-mode)
|
||||
"Build a derivation with the given arguments. Return the resulting
|
||||
store path and <derivation> object. When HASH, HASH-ALGO, and HASH-MODE
|
||||
are given, a fixed-output derivation is created---i.e., one whose result is
|
||||
@ -747,8 +750,8 @@ omitted or is #f, the value of the `%guile-for-build' fluid is used instead."
|
||||
|
||||
(define module-form?
|
||||
(match-lambda
|
||||
(((or 'define-module 'use-modules) _ ...) #t)
|
||||
(_ #f)))
|
||||
(((or 'define-module 'use-modules) _ ...) #t)
|
||||
(_ #f)))
|
||||
|
||||
(define source-path
|
||||
;; When passed an input that is a source, return its path; otherwise
|
||||
@ -833,22 +836,25 @@ omitted or is #f, the value of the `%guile-for-build' fluid is used instead."
|
||||
#:system system)))
|
||||
(go-dir (and go-drv
|
||||
(derivation-path->output-path go-drv))))
|
||||
(derivation store name system guile
|
||||
(derivation store name guile
|
||||
`("--no-auto-compile"
|
||||
,@(if mod-dir `("-L" ,mod-dir) '())
|
||||
,builder)
|
||||
|
||||
#:system system
|
||||
|
||||
#:inputs `((,(or guile-for-build (%guile-for-build)))
|
||||
(,builder)
|
||||
,@(map cdr inputs)
|
||||
,@(if mod-drv `((,mod-drv) (,go-drv)) '()))
|
||||
|
||||
;; When MODULES is non-empty, shamelessly clobber
|
||||
;; $GUILE_LOAD_COMPILED_PATH.
|
||||
(if go-dir
|
||||
`(("GUILE_LOAD_COMPILED_PATH" . ,go-dir)
|
||||
,@(alist-delete "GUILE_LOAD_COMPILED_PATH"
|
||||
env-vars))
|
||||
env-vars)
|
||||
#:env-vars (if go-dir
|
||||
`(("GUILE_LOAD_COMPILED_PATH" . ,go-dir)
|
||||
,@(alist-delete "GUILE_LOAD_COMPILED_PATH"
|
||||
env-vars))
|
||||
env-vars)
|
||||
|
||||
`((,(or guile-for-build (%guile-for-build)))
|
||||
(,builder)
|
||||
,@(map cdr inputs)
|
||||
,@(if mod-drv `((,mod-drv) (,go-drv)) '()))
|
||||
#:hash hash #:hash-algo hash-algo
|
||||
#:outputs outputs)))
|
||||
|
@ -106,9 +106,9 @@
|
||||
(let* ((builder (add-text-to-store %store "my-builder.sh"
|
||||
"echo hello, world\n"
|
||||
'()))
|
||||
(drv-path (derivation %store "foo" (%current-system)
|
||||
(drv-path (derivation %store "foo"
|
||||
%bash `("-e" ,builder)
|
||||
'(("HOME" . "/homeless")) '())))
|
||||
#:env-vars '(("HOME" . "/homeless")))))
|
||||
(and (store-path? drv-path)
|
||||
(valid-path? %store drv-path))))
|
||||
|
||||
@ -118,12 +118,12 @@
|
||||
"echo hello, world > \"$out\"\n"
|
||||
'()))
|
||||
((drv-path drv)
|
||||
(derivation %store "foo" (%current-system)
|
||||
(derivation %store "foo"
|
||||
%bash `(,builder)
|
||||
'(("HOME" . "/homeless")
|
||||
("zzz" . "Z!")
|
||||
("AAA" . "A!"))
|
||||
`((,builder))))
|
||||
#:env-vars '(("HOME" . "/homeless")
|
||||
("zzz" . "Z!")
|
||||
("AAA" . "A!"))
|
||||
#:inputs `((,builder))))
|
||||
((succeeded?)
|
||||
(build-derivations %store (list drv-path))))
|
||||
(and succeeded?
|
||||
@ -139,18 +139,17 @@
|
||||
"(while read line ; do echo \"$line\" ; done) < $in > $out"
|
||||
'()))
|
||||
(input (search-path %load-path "ice-9/boot-9.scm"))
|
||||
(input* (add-to-store %store (basename input)
|
||||
#t "sha256" input))
|
||||
(drv-path (derivation %store "derivation-with-input-file"
|
||||
(%current-system)
|
||||
%bash `(,builder)
|
||||
`(("in"
|
||||
;; Cheat to pass the actual file
|
||||
;; name to the builder.
|
||||
. ,(add-to-store %store
|
||||
(basename input)
|
||||
#t "sha256"
|
||||
input)))
|
||||
`((,builder)
|
||||
(,input))))) ; ← local file name
|
||||
|
||||
;; Cheat to pass the actual file name to the
|
||||
;; builder.
|
||||
#:env-vars `(("in" . ,input*))
|
||||
|
||||
#:inputs `((,builder)
|
||||
(,input))))) ; ← local file name
|
||||
(and (build-derivations %store (list drv-path))
|
||||
;; Note: we can't compare the files because the above trick alters
|
||||
;; the contents.
|
||||
@ -160,10 +159,9 @@
|
||||
(let* ((builder (add-text-to-store %store "my-fixed-builder.sh"
|
||||
"echo -n hello > $out" '()))
|
||||
(hash (sha256 (string->utf8 "hello")))
|
||||
(drv-path (derivation %store "fixed" (%current-system)
|
||||
(drv-path (derivation %store "fixed"
|
||||
%bash `(,builder)
|
||||
'()
|
||||
`((,builder)) ; optional
|
||||
#:inputs `((,builder)) ; optional
|
||||
#:hash hash #:hash-algo 'sha256))
|
||||
(succeeded? (build-derivations %store (list drv-path))))
|
||||
(and succeeded?
|
||||
@ -178,13 +176,11 @@
|
||||
(builder2 (add-text-to-store %store "fixed-builder2.sh"
|
||||
"echo hey; echo -n hello > $out" '()))
|
||||
(hash (sha256 (string->utf8 "hello")))
|
||||
(drv-path1 (derivation %store "fixed" (%current-system)
|
||||
(drv-path1 (derivation %store "fixed"
|
||||
%bash `(,builder1)
|
||||
'() `()
|
||||
#:hash hash #:hash-algo 'sha256))
|
||||
(drv-path2 (derivation %store "fixed" (%current-system)
|
||||
(drv-path2 (derivation %store "fixed"
|
||||
%bash `(,builder2)
|
||||
'() `()
|
||||
#:hash hash #:hash-algo 'sha256))
|
||||
(succeeded? (build-derivations %store
|
||||
(list drv-path1 drv-path2))))
|
||||
@ -201,27 +197,25 @@
|
||||
(builder2 (add-text-to-store %store "fixed-builder2.sh"
|
||||
"echo hey; echo -n hello > $out" '()))
|
||||
(hash (sha256 (string->utf8 "hello")))
|
||||
(fixed1 (derivation %store "fixed" (%current-system)
|
||||
(fixed1 (derivation %store "fixed"
|
||||
%bash `(,builder1)
|
||||
'() `()
|
||||
#:hash hash #:hash-algo 'sha256))
|
||||
(fixed2 (derivation %store "fixed" (%current-system)
|
||||
(fixed2 (derivation %store "fixed"
|
||||
%bash `(,builder2)
|
||||
'() `()
|
||||
#:hash hash #:hash-algo 'sha256))
|
||||
(fixed-out (derivation-path->output-path fixed1))
|
||||
(builder3 (add-text-to-store
|
||||
%store "final-builder.sh"
|
||||
;; Use Bash hackery to avoid Coreutils.
|
||||
"echo $in ; (read -u 3 c; echo $c) 3< $in > $out" '()))
|
||||
(final1 (derivation %store "final" (%current-system)
|
||||
(final1 (derivation %store "final"
|
||||
%bash `(,builder3)
|
||||
`(("in" . ,fixed-out))
|
||||
`((,builder3) (,fixed1))))
|
||||
(final2 (derivation %store "final" (%current-system)
|
||||
#:env-vars `(("in" . ,fixed-out))
|
||||
#:inputs `((,builder3) (,fixed1))))
|
||||
(final2 (derivation %store "final"
|
||||
%bash `(,builder3)
|
||||
`(("in" . ,fixed-out))
|
||||
`((,builder3) (,fixed2))))
|
||||
#:env-vars `(("in" . ,fixed-out))
|
||||
#:inputs `((,builder3) (,fixed2))))
|
||||
(succeeded? (build-derivations %store
|
||||
(list final1 final2))))
|
||||
(and succeeded?
|
||||
@ -232,12 +226,12 @@
|
||||
(let* ((builder (add-text-to-store %store "my-fixed-builder.sh"
|
||||
"echo one > $out ; echo two > $second"
|
||||
'()))
|
||||
(drv-path (derivation %store "fixed" (%current-system)
|
||||
(drv-path (derivation %store "fixed"
|
||||
%bash `(,builder)
|
||||
'(("HOME" . "/homeless")
|
||||
("zzz" . "Z!")
|
||||
("AAA" . "A!"))
|
||||
`((,builder))
|
||||
#:env-vars '(("HOME" . "/homeless")
|
||||
("zzz" . "Z!")
|
||||
("AAA" . "A!"))
|
||||
#:inputs `((,builder))
|
||||
#:outputs '("out" "second")))
|
||||
(succeeded? (build-derivations %store (list drv-path))))
|
||||
(and succeeded?
|
||||
@ -255,10 +249,9 @@
|
||||
(let* ((builder (add-text-to-store %store "my-fixed-builder.sh"
|
||||
"echo one > $out ; echo two > $AAA"
|
||||
'()))
|
||||
(drv-path (derivation %store "fixed" (%current-system)
|
||||
(drv-path (derivation %store "fixed"
|
||||
%bash `(,builder)
|
||||
'()
|
||||
`((,builder))
|
||||
#:inputs `((,builder))
|
||||
#:outputs '("out" "AAA")))
|
||||
(succeeded? (build-derivations %store (list drv-path))))
|
||||
(and succeeded?
|
||||
@ -273,10 +266,9 @@
|
||||
(let* ((builder1 (add-text-to-store %store "my-mo-builder.sh"
|
||||
"echo one > $out ; echo two > $two"
|
||||
'()))
|
||||
(mdrv (derivation %store "multiple-output" (%current-system)
|
||||
(mdrv (derivation %store "multiple-output"
|
||||
%bash `(,builder1)
|
||||
'()
|
||||
`((,builder1))
|
||||
#:inputs `((,builder1))
|
||||
#:outputs '("out" "two")))
|
||||
(builder2 (add-text-to-store %store "my-mo-user-builder.sh"
|
||||
"read x < $one;
|
||||
@ -284,16 +276,17 @@
|
||||
echo \"($x $y)\" > $out"
|
||||
'()))
|
||||
(udrv (derivation %store "multiple-output-user"
|
||||
(%current-system)
|
||||
%bash `(,builder2)
|
||||
`(("one" . ,(derivation-path->output-path
|
||||
mdrv "out"))
|
||||
("two" . ,(derivation-path->output-path
|
||||
mdrv "two")))
|
||||
`((,builder2)
|
||||
;; two occurrences of MDRV:
|
||||
(,mdrv)
|
||||
(,mdrv "two")))))
|
||||
#:env-vars `(("one"
|
||||
. ,(derivation-path->output-path
|
||||
mdrv "out"))
|
||||
("two"
|
||||
. ,(derivation-path->output-path
|
||||
mdrv "two")))
|
||||
#:inputs `((,builder2)
|
||||
;; two occurrences of MDRV:
|
||||
(,mdrv)
|
||||
(,mdrv "two")))))
|
||||
(and (build-derivations %store (list (pk 'udrv udrv)))
|
||||
(let ((p (derivation-path->output-path udrv)))
|
||||
(and (valid-path? %store p)
|
||||
@ -314,14 +307,14 @@
|
||||
"echo $PATH ; mkdir --version ; mkdir $out ; touch $out/good"
|
||||
'()))
|
||||
(drv-path
|
||||
(derivation %store "foo" (%current-system)
|
||||
(derivation %store "foo"
|
||||
%bash `(,builder)
|
||||
`(("PATH" .
|
||||
,(string-append
|
||||
(derivation-path->output-path %coreutils)
|
||||
"/bin")))
|
||||
`((,builder)
|
||||
(,%coreutils))))
|
||||
#:env-vars `(("PATH" .
|
||||
,(string-append
|
||||
(derivation-path->output-path %coreutils)
|
||||
"/bin")))
|
||||
#:inputs `((,builder)
|
||||
(,%coreutils))))
|
||||
(succeeded?
|
||||
(build-derivations %store (list drv-path))))
|
||||
(and succeeded?
|
||||
|
@ -80,9 +80,9 @@
|
||||
;; (b (add-text-to-store %store "link-builder"
|
||||
;; (format #f "echo ~a > $out" p1)
|
||||
;; '()))
|
||||
;; (d1 (derivation %store "link" (%current-system)
|
||||
;; "/bin/sh" `("-e" ,b) '()
|
||||
;; `((,b) (,p1))))
|
||||
;; (d1 (derivation %store "link"
|
||||
;; "/bin/sh" `("-e" ,b)
|
||||
;; #:inputs `((,b) (,p1))))
|
||||
;; (p2 (derivation-path->output-path d1)))
|
||||
;; (and (add-temp-root %store p2)
|
||||
;; (build-derivations %store (list d1))
|
||||
@ -130,9 +130,10 @@
|
||||
(s (add-to-store %store "bash" #t "sha256"
|
||||
(search-bootstrap-binary "bash"
|
||||
(%current-system))))
|
||||
(d (derivation %store "the-thing" (%current-system)
|
||||
s `("-e" ,b) `(("foo" . ,(random-text)))
|
||||
`((,b) (,s))))
|
||||
(d (derivation %store "the-thing"
|
||||
s `("-e" ,b)
|
||||
#:env-vars `(("foo" . ,(random-text)))
|
||||
#:inputs `((,b) (,s))))
|
||||
(o (derivation-path->output-path d)))
|
||||
(and (build-derivations %store (list d))
|
||||
(equal? (query-derivation-outputs %store d)
|
||||
|
Loading…
Reference in New Issue
Block a user