diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-12-01 17:05:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-01 17:05:18 +0100 |
commit | 7bba4b343b0b11af818a7ab41a5e83eb42e98776 (patch) | |
tree | 06064b1bc11b2d3bc2ecd01d1cb0abb2df043b54 | |
parent | 16b03f03af2cbd2b8a682d737371c3194096d5e6 (diff) | |
parent | f1e1ba9fe094a774f0fd05e537228e628d0bc8cb (diff) |
Merge pull request #7386 from edolstra/fix-json
Really fix 'nix store make-content-addressed --json'
-rw-r--r-- | src/nix/make-content-addressed.cc | 6 | ||||
-rw-r--r-- | tests/fetchClosure.sh | 21 |
2 files changed, 16 insertions, 11 deletions
diff --git a/src/nix/make-content-addressed.cc b/src/nix/make-content-addressed.cc index f236bebd6..d86b90fc7 100644 --- a/src/nix/make-content-addressed.cc +++ b/src/nix/make-content-addressed.cc @@ -37,13 +37,15 @@ struct CmdMakeContentAddressed : virtual CopyCommand, virtual StorePathsCommand, StorePathSet(storePaths.begin(), storePaths.end())); if (json) { - nlohmann::json jsonRewrites = json::object(); + auto jsonRewrites = json::object(); for (auto & path : storePaths) { auto i = remappings.find(path); assert(i != remappings.end()); jsonRewrites[srcStore->printStorePath(path)] = srcStore->printStorePath(i->second); } - std::cout << nlohmann::json{"rewrites", jsonRewrites}.dump(); + auto json = json::object(); + json["rewrites"] = jsonRewrites; + std::cout << json.dump(); } else { for (auto & path : storePaths) { auto i = remappings.find(path); diff --git a/tests/fetchClosure.sh b/tests/fetchClosure.sh index 44050c878..d88c55c3c 100644 --- a/tests/fetchClosure.sh +++ b/tests/fetchClosure.sh @@ -1,7 +1,6 @@ source common.sh enableFeatures "fetch-closure" -needLocalStore "'--no-require-sigs' can’t be used with the daemon" clearStore clearCacheCache @@ -28,15 +27,19 @@ clearStore [ ! -e $nonCaPath ] [ -e $caPath ] -# In impure mode, we can use non-CA paths. -[[ $(nix eval --raw --no-require-sigs --impure --expr " - builtins.fetchClosure { - fromStore = \"file://$cacheDir\"; - fromPath = $nonCaPath; - } -") = $nonCaPath ]] +if [[ "$NIX_REMOTE" != "daemon" ]]; then + + # In impure mode, we can use non-CA paths. + [[ $(nix eval --raw --no-require-sigs --impure --expr " + builtins.fetchClosure { + fromStore = \"file://$cacheDir\"; + fromPath = $nonCaPath; + } + ") = $nonCaPath ]] + + [ -e $nonCaPath ] -[ -e $nonCaPath ] +fi # 'toPath' set to empty string should fail but print the expected path. nix eval -v --json --expr " |