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) { }