mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 06:26:15 +02:00
parent
4588a6ff3c
commit
9b3069a88c
1 changed files with 26 additions and 16 deletions
|
@ -161,21 +161,10 @@ const Registries EvalState::getFlakeRegistries()
|
|||
}
|
||||
|
||||
static FlakeRef lookupFlake(EvalState & state, const FlakeRef & flakeRef, const Registries & registries,
|
||||
std::vector<FlakeRef> pastSearches = {})
|
||||
{
|
||||
if (registries.empty() && !flakeRef.isDirect())
|
||||
throw Error("indirect flake reference '%s' is not allowed", flakeRef);
|
||||
std::vector<FlakeRef> pastSearches = {});
|
||||
|
||||
for (std::shared_ptr<FlakeRegistry> registry : registries) {
|
||||
auto i = registry->entries.find(flakeRef);
|
||||
if (i != registry->entries.end()) {
|
||||
auto newRef = i->second;
|
||||
if (std::get_if<FlakeRef::IsAlias>(&flakeRef.data)) {
|
||||
if (flakeRef.ref || flakeRef.rev) {
|
||||
newRef.ref = flakeRef.ref;
|
||||
newRef.rev = flakeRef.rev;
|
||||
}
|
||||
}
|
||||
FlakeRef updateFlakeRef(EvalState & state, const FlakeRef & newRef, const Registries & registries, std::vector<FlakeRef> pastSearches)
|
||||
{
|
||||
std::string errorMsg = "found cycle in flake registries: ";
|
||||
for (FlakeRef oldRef : pastSearches) {
|
||||
errorMsg += oldRef.to_string();
|
||||
|
@ -186,6 +175,27 @@ static FlakeRef lookupFlake(EvalState & state, const FlakeRef & flakeRef, const
|
|||
pastSearches.push_back(newRef);
|
||||
return lookupFlake(state, newRef, registries, pastSearches);
|
||||
}
|
||||
|
||||
static FlakeRef lookupFlake(EvalState & state, const FlakeRef & flakeRef, const Registries & registries,
|
||||
std::vector<FlakeRef> pastSearches)
|
||||
{
|
||||
if (registries.empty() && !flakeRef.isDirect())
|
||||
throw Error("indirect flake reference '%s' is not allowed", flakeRef);
|
||||
|
||||
for (std::shared_ptr<FlakeRegistry> registry : registries) {
|
||||
auto i = registry->entries.find(flakeRef);
|
||||
if (i != registry->entries.end()) {
|
||||
auto newRef = i->second;
|
||||
return updateFlakeRef(state, newRef, registries, pastSearches);
|
||||
}
|
||||
|
||||
auto j = registry->entries.find(flakeRef.baseRef());
|
||||
if (j != registry->entries.end()) {
|
||||
auto newRef = j->second;
|
||||
newRef.ref = flakeRef.ref;
|
||||
newRef.rev = flakeRef.rev;
|
||||
return updateFlakeRef(state, newRef, registries, pastSearches);
|
||||
}
|
||||
}
|
||||
|
||||
if (!flakeRef.isDirect())
|
||||
|
|
Loading…
Reference in a new issue