diff options
author | Robert Hensing <roberth@users.noreply.github.com> | 2023-04-07 15:02:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-07 15:02:35 +0200 |
commit | 54b3b6ebc638b148a8804b81e9c17ab52cddf8e1 (patch) | |
tree | 18d5b77e096ecf89f459d26da79cef18b273dec8 /tests/ca/derivation-json.sh | |
parent | 81dfc2b01231c65137017de092c8506838fadd94 (diff) | |
parent | 9d1105824f99ada218387eb8791643f66b25c3f8 (diff) |
Merge pull request #7887 from obsidiansystems/add-derivation
`nix derivation add`, `show-derivation` -> `derivation show`
Diffstat (limited to 'tests/ca/derivation-json.sh')
-rw-r--r-- | tests/ca/derivation-json.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/ca/derivation-json.sh b/tests/ca/derivation-json.sh new file mode 100644 index 000000000..3615177e9 --- /dev/null +++ b/tests/ca/derivation-json.sh @@ -0,0 +1,26 @@ +source common.sh + +export NIX_TESTS_CA_BY_DEFAULT=1 + +drvPath=$(nix-instantiate ../simple.nix) + +nix derivation show $drvPath | jq .[] > $TEST_HOME/simple.json + +drvPath2=$(nix derivation add < $TEST_HOME/simple.json) + +[[ "$drvPath" = "$drvPath2" ]] + +# Content-addressed derivations can be renamed. +jq '.name = "foo"' < $TEST_HOME/simple.json > $TEST_HOME/foo.json +drvPath3=$(nix derivation add --dry-run < $TEST_HOME/foo.json) +# With --dry-run nothing is actually written +[[ ! -e "$drvPath3" ]] + +# Without --dry-run it is actually written +drvPath4=$(nix derivation add < $TEST_HOME/foo.json) +[[ "$drvPath4" = "$drvPath3" ]] +[[ -e "$drvPath3" ]] + +# The modified derivation read back as JSON matches +nix derivation show $drvPath3 | jq .[] > $TEST_HOME/foo-read.json +diff $TEST_HOME/foo.json $TEST_HOME/foo-read.json |