aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-05-22 23:43:58 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-05-22 23:43:58 +0200
commitf0d6d67af93b63c1da1809dc7630026624c19b14 (patch)
treeda203598db29600c185432bf5631254859e67a5a
parentdf3f5a78d5ab0a1f2dc9d288b271b38a9b8b33b5 (diff)
Prevent the global registry from being GC'ed
Issue #2868.
-rw-r--r--src/libexpr/primops/flake.cc1
-rw-r--r--src/libstore/download.cc3
-rw-r--r--src/libstore/download.hh1
3 files changed, 5 insertions, 0 deletions
diff --git a/src/libexpr/primops/flake.cc b/src/libexpr/primops/flake.cc
index e2fdf08ca..3c3d5e0c7 100644
--- a/src/libexpr/primops/flake.cc
+++ b/src/libexpr/primops/flake.cc
@@ -139,6 +139,7 @@ std::shared_ptr<FlakeRegistry> EvalState::getGlobalFlakeRegistry()
if (!hasPrefix(path, "/")) {
CachedDownloadRequest request(evalSettings.flakeRegistry);
request.name = "flake-registry.json";
+ request.gcRoot = true;
path = getDownloader()->downloadCached(store, request).path;
}
diff --git a/src/libstore/download.cc b/src/libstore/download.cc
index a7c2600f6..0d1974d3b 100644
--- a/src/libstore/download.cc
+++ b/src/libstore/download.cc
@@ -913,6 +913,9 @@ CachedDownloadResult Downloader::downloadCached(
url, request.expectedHash.to_string(), gotHash.to_string());
}
+ if (request.gcRoot)
+ store->addIndirectRoot(fileLink);
+
result.storePath = storePath;
result.path = store->toRealPath(storePath);
return result;
diff --git a/src/libstore/download.hh b/src/libstore/download.hh
index b676a1a7b..404e51195 100644
--- a/src/libstore/download.hh
+++ b/src/libstore/download.hh
@@ -48,6 +48,7 @@ struct CachedDownloadRequest
std::string name;
Hash expectedHash;
unsigned int ttl = settings.tarballTtl;
+ bool gcRoot = false;
CachedDownloadRequest(const std::string & uri)
: uri(uri) { }