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