mirror of
https://github.com/NixOS/nix.git
synced 2025-11-16 15:32:43 +01:00
`nix derivation add`, and its C API counterpart, now works a bit closer to `builtins.derivation` in that they don't require the user to fill-in input addressed paths correctly ahead of time. The logic for this is carefully deduplicated, between all 3 entry points, and also between the existing `checkInvariants` function. There are some more functional tests, and there are also many more unit tests.
23 lines
882 B
Bash
Executable file
23 lines
882 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
source common.sh
|
|
|
|
drvPath=$(nix-instantiate simple.nix)
|
|
|
|
nix derivation show "$drvPath" | jq '.[]' > "$TEST_HOME/simple.json"
|
|
|
|
# Round tripping to JSON works
|
|
drvPath2=$(nix derivation add < "$TEST_HOME/simple.json")
|
|
[[ "$drvPath" = "$drvPath2" ]]
|
|
|
|
# Derivaiton 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"
|
|
|
|
# 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" ]]
|