forked from LnL7/nix
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In the Nix language, given a drv path, we should be able to construct another string referencing to one of its output. We can do this today with `(import drvPath).output`, but this only works for derivations we already have. With dynamic derivations, however, that doesn't work well because the `drvPath` isn't yet built: importing it like would need to trigger IFD, when the whole point of this feature is to do "dynamic build graph" without IFD! Instead, what we want to do is create a placeholder value with the right string context to refer to the output of the as-yet unbuilt derivation. A new primop in the language, analogous to `builtins.placeholder` can be used to create one. This will achieve all the right properties. The placeholder machinery also will match out the `outPath` attribute for CA derivations works. In 60b7121 we added that type of placeholder, and the derived path and string holder changes necessary to support it. Then in the previous commit we cleaned up the code (inspiration finally hit me!) to deduplicate the code and expose exactly what we need. Now, we can wire up the primop trivally! Part of RFC 92: dynamic derivations (tracking issue NixOS#6316)
- Loading branch information
1 parent
8d50c8a
commit 79cd647
Showing
5 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
source common.sh | ||
|
||
out1=$(nix-build ./text-hashed-output.nix -A hello --no-out-link) | ||
|
||
clearStore | ||
|
||
expectStderr 1 nix-build ./text-hashed-output.nix -A wrapper --no-out-link | grepQuiet "Dependencies on the outputs of dynamic derivations are not yet supported" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
|
||
source ./common.sh | ||
|
||
# Without the dynamic-derivations XP feature, we don't have the builtin. | ||
nix --experimental-features 'nix-command' eval --impure --expr \ | ||
'assert ! (builtins ? outputOf); ""' | ||
|
||
# Test with a regular old input-addresed derivation: works without | ||
# ca-derivations and doesn't create a placeholder but just returns the | ||
# output path. | ||
nix --experimental-features 'nix-command dynamic-derivations' eval --impure --expr \ | ||
'let | ||
item = import ../dependencies.nix; | ||
a = item.outPath; | ||
b = builtins.outputOf (builtins.unsafeDiscardOutputDependency item.drvPath) "out"; | ||
in builtins.trace a | ||
(builtins.trace b | ||
(assert a == b; null))' | ||
|
||
# Test with content addressed derivation. | ||
nix eval --impure --expr \ | ||
'with (import ./text-hashed-output.nix); let | ||
a = hello.outPath; | ||
b = builtins.outputOf (builtins.unsafeDiscardOutputDependency hello.drvPath) "out"; | ||
in builtins.trace a | ||
(builtins.trace b | ||
(assert a == b; null))' | ||
|
||
# Test with derivation-producing derivation. | ||
nix eval --impure --expr \ | ||
'with (import ./text-hashed-output.nix); let | ||
a = producingDrv.outPath; | ||
b = builtins.outputOf (builtins.builtins.unsafeDiscardOutputDependency producingDrv.drvPath) "out"; | ||
in builtins.trace a | ||
(builtins.trace b | ||
(assert a == b; null))' | ||
|
||
# Test with unbuilt output of derivation-producing derivation. | ||
nix eval --impure --expr \ | ||
'with (import ./text-hashed-output.nix); let | ||
a = builtins.outputOf producingDrv.out.outPath "out"; | ||
b = builtins.outputOf (builtins.outputOf (builtins.unsafeDiscardOutputDependency producingDrv.drvPath) "out") "out"; | ||
in builtins.trace a | ||
(builtins.trace b | ||
(assert a == b; null))' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters