aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/primops
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-05-22 22:56:46 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-05-22 22:56:46 +0200
commit66f1d7ee95ba693a15ae5dc413289fee954f0f04 (patch)
treeeec6d8093bada22f8927c0f4184d4a75dcebf61c /src/libexpr/primops
parent55a0451e5132b460ec80eb30647c3d957fc1ce98 (diff)
Fetch the flake registry from the NixOS/flake-registry repo
Diffstat (limited to 'src/libexpr/primops')
-rw-r--r--src/libexpr/primops/flake.cc16
-rw-r--r--src/libexpr/primops/flake.hh2
2 files changed, 13 insertions, 5 deletions
diff --git a/src/libexpr/primops/flake.cc b/src/libexpr/primops/flake.cc
index 9131080bf..c6c380118 100644
--- a/src/libexpr/primops/flake.cc
+++ b/src/libexpr/primops/flake.cc
@@ -131,9 +131,19 @@ void writeLockFile(const LockFile & lockFile, const Path & path)
writeFile(path, json.dump(4) + "\n"); // '4' = indentation in json file
}
-std::shared_ptr<FlakeRegistry> getGlobalRegistry()
+std::shared_ptr<FlakeRegistry> EvalState::getGlobalFlakeRegistry()
{
- return readRegistry(evalSettings.flakeRegistry);
+ std::call_once(_globalFlakeRegistryInit, [&]() {
+ auto path = evalSettings.flakeRegistry;
+
+ if (!hasPrefix(path, "/"))
+ path = getDownloader()->downloadCached(store,
+ evalSettings.flakeRegistry, false, "registry").path;
+
+ _globalFlakeRegistry = readRegistry(path);
+ });
+
+ return _globalFlakeRegistry;
}
Path getUserRegistryPath()
@@ -162,7 +172,7 @@ const Registries EvalState::getFlakeRegistries()
Registries registries;
registries.push_back(getFlagRegistry(registryOverrides));
registries.push_back(getUserRegistry());
- registries.push_back(getGlobalRegistry());
+ registries.push_back(getGlobalFlakeRegistry());
return registries;
}
diff --git a/src/libexpr/primops/flake.hh b/src/libexpr/primops/flake.hh
index 983c0eab6..b965aa9e7 100644
--- a/src/libexpr/primops/flake.hh
+++ b/src/libexpr/primops/flake.hh
@@ -120,8 +120,6 @@ struct NonFlake
resolvedRef(sourceInfo.resolvedRef), revCount(sourceInfo.revCount), storePath(sourceInfo.storePath) {};
};
-std::shared_ptr<FlakeRegistry> getGlobalRegistry();
-
Flake getFlake(EvalState &, const FlakeRef &, bool impureIsAllowed);
struct ResolvedFlake