From 7e83ab3e3579e2b42bb8f94630eb8625e5f891fc Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Mon, 16 Sep 2024 14:14:07 +0200 Subject: [PATCH] Switch nix-derivation-instantiate json output to obect keys instead of list --- src/nix/derivation-instantiate.cc | 4 ++-- tests/functional/derivation-instantiate.sh | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/nix/derivation-instantiate.cc b/src/nix/derivation-instantiate.cc index d044ddb1c..ad1a20226 100644 --- a/src/nix/derivation-instantiate.cc +++ b/src/nix/derivation-instantiate.cc @@ -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; } diff --git a/tests/functional/derivation-instantiate.sh b/tests/functional/derivation-instantiate.sh index a93afcfdc..fea0030c5 100755 --- a/tests/functional/derivation-instantiate.sh +++ b/tests/functional/derivation-instantiate.sh @@ -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