forked from lix-project/lix
Fixed flake pin issues
This commit is contained in:
parent
b4e367bf4a
commit
7587d62d02
2 changed files with 17 additions and 2 deletions
|
@ -63,6 +63,8 @@ struct NonFlake
|
||||||
NonFlake(const FlakeRef flakeRef) : ref(flakeRef) {};
|
NonFlake(const FlakeRef flakeRef) : ref(flakeRef) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::shared_ptr<FlakeRegistry> getGlobalRegistry();
|
||||||
|
|
||||||
Flake getFlake(EvalState &, const FlakeRef &, bool impureIsAllowed);
|
Flake getFlake(EvalState &, const FlakeRef &, bool impureIsAllowed);
|
||||||
|
|
||||||
struct Dependencies
|
struct Dependencies
|
||||||
|
|
|
@ -129,6 +129,8 @@ struct CmdFlakeInfo : FlakeCommand, MixJSON, MixEvalArgs, StoreCommand
|
||||||
return "list info about a given flake";
|
return "list info about a given flake";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CmdFlakeInfo () { evalSettings.pureEval = false; }
|
||||||
|
|
||||||
void run(nix::ref<nix::Store> store) override
|
void run(nix::ref<nix::Store> store) override
|
||||||
{
|
{
|
||||||
auto evalState = std::make_shared<EvalState>(searchPath, store);
|
auto evalState = std::make_shared<EvalState>(searchPath, store);
|
||||||
|
@ -156,6 +158,7 @@ struct CmdFlakeAdd : MixEvalArgs, Command
|
||||||
{
|
{
|
||||||
expectArg("alias", &alias);
|
expectArg("alias", &alias);
|
||||||
expectArg("flake-uri", &uri);
|
expectArg("flake-uri", &uri);
|
||||||
|
evalSettings.pureEval = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void run() override
|
void run() override
|
||||||
|
@ -186,6 +189,7 @@ struct CmdFlakeRemove : virtual Args, MixEvalArgs, Command
|
||||||
CmdFlakeRemove()
|
CmdFlakeRemove()
|
||||||
{
|
{
|
||||||
expectArg("alias", &alias);
|
expectArg("alias", &alias);
|
||||||
|
evalSettings.pureEval = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void run() override
|
void run() override
|
||||||
|
@ -214,6 +218,7 @@ struct CmdFlakePin : virtual Args, StoreCommand, MixEvalArgs
|
||||||
CmdFlakePin()
|
CmdFlakePin()
|
||||||
{
|
{
|
||||||
expectArg("alias", &alias);
|
expectArg("alias", &alias);
|
||||||
|
evalSettings.pureEval = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void run(nix::ref<nix::Store> store) override
|
void run(nix::ref<nix::Store> store) override
|
||||||
|
@ -227,8 +232,16 @@ struct CmdFlakePin : virtual Args, StoreCommand, MixEvalArgs
|
||||||
it->second = getFlake(*evalState, it->second, true).ref;
|
it->second = getFlake(*evalState, it->second, true).ref;
|
||||||
// The 'ref' in 'flake' is immutable.
|
// The 'ref' in 'flake' is immutable.
|
||||||
writeRegistry(userRegistry, userRegistryPath);
|
writeRegistry(userRegistry, userRegistryPath);
|
||||||
|
} else {
|
||||||
|
std::shared_ptr<FlakeRegistry> globalReg = getGlobalRegistry();
|
||||||
|
it = globalReg->entries.find(FlakeRef(alias));
|
||||||
|
if (it != globalReg->entries.end()) {
|
||||||
|
FlakeRef newRef = getFlake(*evalState, it->second, true).ref;
|
||||||
|
userRegistry.entries.insert_or_assign(alias, newRef);
|
||||||
|
writeRegistry(userRegistry, userRegistryPath);
|
||||||
} else
|
} else
|
||||||
throw Error("the flake alias '%s' does not exist in the user registry", alias);
|
throw Error("the flake alias '%s' does not exist in the user or global registry", alias);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue