mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-30 09:36:15 +02:00
Implemented writeRegistry
This commit is contained in:
parent
9ff1a9ea65
commit
6542de98c2
2 changed files with 14 additions and 0 deletions
|
@ -31,6 +31,18 @@ static std::unique_ptr<FlakeRegistry> readRegistry(const Path & path)
|
||||||
return registry;
|
return registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Write the registry or lock file to a file. */
|
||||||
|
static void writeRegistry(FlakeRegistry registry, Path path = "./flake.lock")
|
||||||
|
{
|
||||||
|
nlohmann::json json = {};
|
||||||
|
json["value"] = 0; // Not sure whether this should be 0.
|
||||||
|
json["flakes"] = {};
|
||||||
|
for (auto elem : registry.entries) {
|
||||||
|
json["flakes"][elem.first] = elem.second.ref.to_string();
|
||||||
|
}
|
||||||
|
writeFile(path, json.dump(4)); // The '4' is the number of spaces used in the indentation in the json file.
|
||||||
|
}
|
||||||
|
|
||||||
const FlakeRegistry & EvalState::getFlakeRegistry()
|
const FlakeRegistry & EvalState::getFlakeRegistry()
|
||||||
{
|
{
|
||||||
std::call_once(_flakeRegistryInit, [&]()
|
std::call_once(_flakeRegistryInit, [&]()
|
||||||
|
|
|
@ -35,4 +35,6 @@ struct Flake
|
||||||
};
|
};
|
||||||
|
|
||||||
Flake getFlake(EvalState & state, const FlakeRef & flakeRef);
|
Flake getFlake(EvalState & state, const FlakeRef & flakeRef);
|
||||||
|
|
||||||
|
void writeRegistry(FlakeRegistry);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue