mirror of
https://github.com/NixOS/nix.git
synced 2025-12-09 02:21:02 +01:00
As discussed today at great length in the Nix meeting, we don't want to break the format, but we also don't want to impede the improvement of JSON formats. The solution is to add a new flag for control the output format. Note that prior to the release, we may want to replace `--json --json-format N` with `--json=N`, but this is being left for a separate PR, as we don't yet have `=` support for CLI flags.
39 lines
1.1 KiB
Bash
Executable file
39 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
source common.sh
|
|
|
|
echo foo > "$TEST_ROOT"/foo
|
|
foo=$(nix store add-file "$TEST_ROOT"/foo)
|
|
|
|
echo bar > "$TEST_ROOT"/bar
|
|
bar=$(nix store add-file "$TEST_ROOT"/bar)
|
|
|
|
echo baz > "$TEST_ROOT"/baz
|
|
baz=$(nix store add-file "$TEST_ROOT"/baz)
|
|
nix-store --delete "$baz"
|
|
|
|
diff --unified --color=always \
|
|
<(nix path-info --json --json-format 2 "$foo" "$bar" "$baz" |
|
|
jq --sort-keys 'map_values(.narHash)') \
|
|
<(jq --sort-keys <<-EOF
|
|
{
|
|
"$foo": {
|
|
"algorithm": "sha256",
|
|
"format": "base16",
|
|
"hash": "42fb4031b525feebe2f8b08e6e6a8e86f34e6a91dd036ada888e311b9cc8e690"
|
|
},
|
|
"$bar": {
|
|
"algorithm": "sha256",
|
|
"format": "base16",
|
|
"hash": "f5f8581aef5fab17100b629cf35aa1d91328d5070b054068f14fa93e7fa3b614"
|
|
},
|
|
"$baz": null
|
|
}
|
|
EOF
|
|
)
|
|
|
|
# Test that storeDir is returned in the JSON output
|
|
nix path-info --json --json-format 2 "$foo" | jq -e \
|
|
--arg foo "$foo" \
|
|
--arg storeDir "${NIX_STORE_DIR:-/nix/store}" \
|
|
'.[$foo].storeDir == $storeDir'
|