mirror of
https://github.com/NixOS/nix
synced 2025-06-25 19:01:16 +02:00
Put flake-related stuff in its own namespace
This commit is contained in:
parent
c356d034f3
commit
6e4a8c47f4
6 changed files with 62 additions and 42 deletions
|
@ -14,6 +14,10 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
using namespace flake;
|
||||
|
||||
namespace flake {
|
||||
|
||||
/* Read a registry. */
|
||||
std::shared_ptr<FlakeRegistry> readRegistry(const Path & path)
|
||||
{
|
||||
|
@ -133,24 +137,6 @@ void writeLockFile(const LockFile & lockFile, const Path & path)
|
|||
writeFile(path, json.dump(4) + "\n"); // '4' = indentation in json file
|
||||
}
|
||||
|
||||
std::shared_ptr<FlakeRegistry> EvalState::getGlobalFlakeRegistry()
|
||||
{
|
||||
std::call_once(_globalFlakeRegistryInit, [&]() {
|
||||
auto path = evalSettings.flakeRegistry;
|
||||
|
||||
if (!hasPrefix(path, "/")) {
|
||||
CachedDownloadRequest request(evalSettings.flakeRegistry);
|
||||
request.name = "flake-registry.json";
|
||||
request.gcRoot = true;
|
||||
path = getDownloader()->downloadCached(store, request).path;
|
||||
}
|
||||
|
||||
_globalFlakeRegistry = readRegistry(path);
|
||||
});
|
||||
|
||||
return _globalFlakeRegistry;
|
||||
}
|
||||
|
||||
Path getUserRegistryPath()
|
||||
{
|
||||
return getHome() + "/.config/nix/registry.json";
|
||||
|
@ -170,17 +156,6 @@ std::shared_ptr<FlakeRegistry> getFlagRegistry(RegistryOverrides registryOverrid
|
|||
return flagRegistry;
|
||||
}
|
||||
|
||||
// This always returns a vector with flakeReg, userReg, globalReg.
|
||||
// If one of them doesn't exist, the registry is left empty but does exist.
|
||||
const Registries EvalState::getFlakeRegistries()
|
||||
{
|
||||
Registries registries;
|
||||
registries.push_back(getFlagRegistry(registryOverrides));
|
||||
registries.push_back(getUserRegistry());
|
||||
registries.push_back(getGlobalFlakeRegistry());
|
||||
return registries;
|
||||
}
|
||||
|
||||
static FlakeRef lookupFlake(EvalState & state, const FlakeRef & flakeRef, const Registries & registries,
|
||||
std::vector<FlakeRef> pastSearches = {});
|
||||
|
||||
|
@ -637,3 +612,34 @@ void gitCloneFlake(FlakeRef flakeRef, EvalState & state, Registries registries,
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
std::shared_ptr<flake::FlakeRegistry> EvalState::getGlobalFlakeRegistry()
|
||||
{
|
||||
std::call_once(_globalFlakeRegistryInit, [&]() {
|
||||
auto path = evalSettings.flakeRegistry;
|
||||
|
||||
if (!hasPrefix(path, "/")) {
|
||||
CachedDownloadRequest request(evalSettings.flakeRegistry);
|
||||
request.name = "flake-registry.json";
|
||||
request.gcRoot = true;
|
||||
path = getDownloader()->downloadCached(store, request).path;
|
||||
}
|
||||
|
||||
_globalFlakeRegistry = readRegistry(path);
|
||||
});
|
||||
|
||||
return _globalFlakeRegistry;
|
||||
}
|
||||
|
||||
// This always returns a vector with flakeReg, userReg, globalReg.
|
||||
// If one of them doesn't exist, the registry is left empty but does exist.
|
||||
const Registries EvalState::getFlakeRegistries()
|
||||
{
|
||||
Registries registries;
|
||||
registries.push_back(getFlagRegistry(registryOverrides));
|
||||
registries.push_back(getUserRegistry());
|
||||
registries.push_back(getGlobalFlakeRegistry());
|
||||
return registries;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue