diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-03-19 11:45:34 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-03-19 11:45:34 +0100 |
commit | 8aa354fdfd94db7b63462a4683add04e4eb75c48 (patch) | |
tree | dad091b50f51d935ca579ee0041871bd93dd5fa1 | |
parent | 1c127e6a82dbc128602aa4451dfa8f4c2fe4a751 (diff) |
Register flake-registry.json as a GC root again
-rw-r--r-- | src/libstore/fetchers/registry.cc | 10 | ||||
-rw-r--r-- | tests/flakes.sh | 1 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/libstore/fetchers/registry.cc b/src/libstore/fetchers/registry.cc index 638e6e50a..69c80a5a9 100644 --- a/src/libstore/fetchers/registry.cc +++ b/src/libstore/fetchers/registry.cc @@ -127,10 +127,12 @@ static std::shared_ptr<Registry> getGlobalRegistry(ref<Store> store) static auto reg = [&]() { auto path = settings.flakeRegistry; - if (!hasPrefix(path, "/")) - // FIXME: register as GC root. - // FIXME: if download fails, use previous version if available. - path = store->toRealPath(downloadFile(store, path, "flake-registry.json", false).storePath); + if (!hasPrefix(path, "/")) { + auto storePath = downloadFile(store, path, "flake-registry.json", false).storePath; + if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>()) + store2->addPermRoot(storePath, getCacheDir() + "/nix/flake-registry.json", true); + path = store->toRealPath(storePath); + } return Registry::read(path, Registry::Global); }(); diff --git a/tests/flakes.sh b/tests/flakes.sh index 52f5fabc0..f2ebd7b0c 100644 --- a/tests/flakes.sh +++ b/tests/flakes.sh @@ -269,6 +269,7 @@ nix build -o $TEST_ROOT/result $flake3Dir#sth 2>&1 | grep 'unsupported edition' # Test whether registry caching works. nix flake list --flake-registry file://$registry | grep -q flake3 mv $registry $registry.tmp +nix-store --gc nix flake list --flake-registry file://$registry --refresh | grep -q flake3 mv $registry.tmp $registry |