mirror of
https://github.com/NixOS/nix.git
synced 2025-11-27 20:51:00 +01:00
Merge pull request #14560 from obsidiansystems/fill-in-outputs
Dedup some derivation initialization logic, and test
This commit is contained in:
commit
3ba51bf61b
21 changed files with 774 additions and 140 deletions
|
|
@ -4,11 +4,20 @@ source common.sh
|
|||
|
||||
drvPath=$(nix-instantiate simple.nix)
|
||||
|
||||
nix derivation show "$drvPath" | jq .[] > "$TEST_HOME"/simple.json
|
||||
|
||||
drvPath2=$(nix derivation add < "$TEST_HOME"/simple.json)
|
||||
nix derivation show "$drvPath" | jq '.[]' > "$TEST_HOME/simple.json"
|
||||
|
||||
# Round tripping to JSON works
|
||||
drvPath2=$(nix derivation add < "$TEST_HOME/simple.json")
|
||||
[[ "$drvPath" = "$drvPath2" ]]
|
||||
|
||||
# Derivation is input addressed, all outputs have a path
|
||||
jq -e '.outputs | .[] | has("path")' < "$TEST_HOME/simple.json"
|
||||
|
||||
# Input addressed derivations cannot be renamed.
|
||||
jq '.name = "foo"' < "$TEST_HOME"/simple.json | expectStderr 1 nix derivation add | grepQuiet "has incorrect output"
|
||||
jq '.name = "foo"' < "$TEST_HOME/simple.json" | expectStderr 1 nix derivation add | grepQuiet "has incorrect output"
|
||||
|
||||
# If we remove the input addressed to make it a deferred derivation, we
|
||||
# still get the same result because Nix will see that need not be
|
||||
# deferred and fill in the right input address for us.
|
||||
drvPath3=$(jq '.outputs |= map_values(del(.path))' < "$TEST_HOME/simple.json" | nix derivation add)
|
||||
[[ "$drvPath" = "$drvPath3" ]]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue