1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 10:50:24 -04:00

Switch nix-derivation-instantiate json output to obect keys instead of list

This commit is contained in:
Guillaume Maudoux 2024-09-16 14:14:07 +02:00
parent d22a2fe517
commit 7e83ab3e35
2 changed files with 5 additions and 4 deletions

View file

@ -11,9 +11,9 @@ using namespace nix;
static nlohmann::json storePathSetToJSON(const StorePathSet & paths, Store & store)
{
auto res = nlohmann::json::array();
auto res = nlohmann::json::object();
for (auto & path : paths) {
res.push_back(store.printStorePath(path));
res[store.printStorePath(path)] = nlohmann::json::object();
}
return res;
}

View file

@ -30,14 +30,15 @@ rm foobar
nix-store --delete $drvPath
drvPathJson=$(nix derivation instantiate --json --no-link --file simple.nix)
[ "$drvPathJson" = '["'"$drvPath"'"]' ]
[ "$drvPathJson" = '{"'"$drvPath"'":{}}' ]
nix-store --delete $drvPath
drvPaths=($(nix derivation instantiate --json --out-link multidrv --file check.nix | jq '.[]' -r))
drvPaths=($(nix derivation instantiate --json --out-link multidrv --file check.nix | jq 'keys|.[]' -r))
roots=(./multidrv*)
[ "${#roots[@]}" -gt 1 ]
[ "${#roots[@]}" -eq "${#drvPaths[@]}" ]
rootedPaths=($(readlink "${roots[@]}"))
[ "${rootedPaths[*]}" = "${drvPaths[*]}" ]
rm multidrv*
nix-collect-garbage