mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
resolveFlake -> lockFlake
"resolve" is ambiguous (also used for registry resolution).
This commit is contained in:
parent
b5c9dbc84f
commit
872a22fa23
5 changed files with 36 additions and 40 deletions
|
@ -302,7 +302,10 @@ static std::pair<Flake, LockedInput> updateLocks(
|
|||
|
||||
/* Compute an in-memory lockfile for the specified top-level flake,
|
||||
and optionally write it to file, it the flake is writable. */
|
||||
ResolvedFlake resolveFlake(EvalState & state, const FlakeRef & topRef, HandleLockFile handleLockFile)
|
||||
LockedFlake lockFlake(
|
||||
EvalState & state,
|
||||
const FlakeRef & topRef,
|
||||
HandleLockFile handleLockFile)
|
||||
{
|
||||
settings.requireExperimentalFeature("flakes");
|
||||
|
||||
|
@ -356,12 +359,7 @@ ResolvedFlake resolveFlake(EvalState & state, const FlakeRef & topRef, HandleLoc
|
|||
warn("using updated lock file without writing it to file");
|
||||
}
|
||||
|
||||
return ResolvedFlake { .flake = std::move(flake), .lockFile = std::move(lockFile) };
|
||||
}
|
||||
|
||||
void updateLockFile(EvalState & state, const FlakeRef & flakeRef, bool recreateLockFile)
|
||||
{
|
||||
resolveFlake(state, flakeRef, recreateLockFile ? RecreateLockFile : UpdateLockFile);
|
||||
return LockedFlake { .flake = std::move(flake), .lockFile = std::move(lockFile) };
|
||||
}
|
||||
|
||||
static void emitSourceInfoAttrs(EvalState & state, const fetchers::Tree & sourceInfo, Value & vAttrs)
|
||||
|
@ -480,16 +478,16 @@ void callFlake(EvalState & state,
|
|||
}
|
||||
|
||||
void callFlake(EvalState & state,
|
||||
const ResolvedFlake & resFlake,
|
||||
const LockedFlake & lockedFlake,
|
||||
Value & v)
|
||||
{
|
||||
callFlake(state, resFlake.flake, resFlake.lockFile, v);
|
||||
callFlake(state, lockedFlake.flake, lockedFlake.lockFile, v);
|
||||
}
|
||||
|
||||
// This function is exposed to be used in nix files.
|
||||
static void prim_getFlake(EvalState & state, const Pos & pos, Value * * args, Value & v)
|
||||
{
|
||||
callFlake(state, resolveFlake(state, parseFlakeRef(state.forceStringNoCtx(*args[0], pos)),
|
||||
callFlake(state, lockFlake(state, parseFlakeRef(state.forceStringNoCtx(*args[0], pos)),
|
||||
evalSettings.pureEval ? AllPure : UseUpdatedLockFile), v);
|
||||
}
|
||||
|
||||
|
@ -497,7 +495,7 @@ static RegisterPrimOp r2("getFlake", 1, prim_getFlake);
|
|||
|
||||
}
|
||||
|
||||
Fingerprint ResolvedFlake::getFingerprint() const
|
||||
Fingerprint LockedFlake::getFingerprint() const
|
||||
{
|
||||
// FIXME: as an optimization, if the flake contains a lock file
|
||||
// and we haven't changed it, then it's sufficient to use
|
||||
|
|
|
@ -46,7 +46,7 @@ Flake getFlake(EvalState & state, const FlakeRef & flakeRef, bool allowLookup);
|
|||
/* Fingerprint of a locked flake; used as a cache key. */
|
||||
typedef Hash Fingerprint;
|
||||
|
||||
struct ResolvedFlake
|
||||
struct LockedFlake
|
||||
{
|
||||
Flake flake;
|
||||
LockFile lockFile;
|
||||
|
@ -54,7 +54,7 @@ struct ResolvedFlake
|
|||
Fingerprint getFingerprint() const;
|
||||
};
|
||||
|
||||
ResolvedFlake resolveFlake(EvalState &, const FlakeRef &, HandleLockFile);
|
||||
LockedFlake lockFlake(EvalState &, const FlakeRef &, HandleLockFile);
|
||||
|
||||
void callFlake(EvalState & state,
|
||||
const Flake & flake,
|
||||
|
@ -62,11 +62,9 @@ void callFlake(EvalState & state,
|
|||
Value & v);
|
||||
|
||||
void callFlake(EvalState & state,
|
||||
const ResolvedFlake & resFlake,
|
||||
const LockedFlake & resFlake,
|
||||
Value & v);
|
||||
|
||||
void updateLockFile(EvalState &, const FlakeRef & flakeRef, bool recreateLockFile);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,9 +41,9 @@ public:
|
|||
return flake::getFlake(*evalState, getFlakeRef(), useRegistries);
|
||||
}
|
||||
|
||||
ResolvedFlake resolveFlake()
|
||||
LockedFlake lockFlake()
|
||||
{
|
||||
return flake::resolveFlake(*getEvalState(), getFlakeRef(), getLockFileMode());
|
||||
return flake::lockFlake(*getEvalState(), getFlakeRef(), getLockFileMode());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -122,16 +122,16 @@ struct CmdFlakeDeps : FlakeCommand
|
|||
{
|
||||
auto evalState = getEvalState();
|
||||
|
||||
std::queue<ResolvedFlake> todo;
|
||||
todo.push(resolveFlake());
|
||||
std::queue<LockedFlake> todo;
|
||||
todo.push(lockFlake());
|
||||
|
||||
stopProgressBar();
|
||||
|
||||
while (!todo.empty()) {
|
||||
auto resFlake = std::move(todo.front());
|
||||
auto lockedFlake = std::move(todo.front());
|
||||
todo.pop();
|
||||
|
||||
for (auto & info : resFlake.flakeDeps) {
|
||||
for (auto & info : lockedFlake.flakeDeps) {
|
||||
printFlakeInfo(*store, info.second.flake);
|
||||
todo.push(info.second);
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ struct CmdFlakeUpdate : FlakeCommand
|
|||
void run(nix::ref<nix::Store> store) override
|
||||
{
|
||||
auto evalState = getEvalState();
|
||||
resolveFlake();
|
||||
lockFlake();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -179,7 +179,7 @@ struct CmdFlakeInfo : FlakeCommand, MixJSON
|
|||
{
|
||||
if (json) {
|
||||
auto state = getEvalState();
|
||||
auto flake = resolveFlake();
|
||||
auto flake = lockFlake();
|
||||
|
||||
auto json = flakeToJson(*store, flake.flake);
|
||||
|
||||
|
@ -235,7 +235,7 @@ struct CmdFlakeCheck : FlakeCommand, MixJSON
|
|||
settings.readOnlyMode = !build;
|
||||
|
||||
auto state = getEvalState();
|
||||
auto flake = resolveFlake();
|
||||
auto flake = lockFlake();
|
||||
|
||||
auto checkSystemName = [&](const std::string & system, const Pos & pos) {
|
||||
// FIXME: what's the format of "system"?
|
||||
|
|
|
@ -240,7 +240,7 @@ struct InstallableAttrPath : InstallableValue
|
|||
|
||||
void makeFlakeClosureGCRoot(Store & store,
|
||||
const FlakeRef & origFlakeRef,
|
||||
const flake::ResolvedFlake & resFlake)
|
||||
const flake::LockedFlake & lockedFlake)
|
||||
{
|
||||
#if 0
|
||||
if (std::get_if<FlakeRef::IsPath>(&origFlakeRef.data)) return;
|
||||
|
@ -248,11 +248,11 @@ void makeFlakeClosureGCRoot(Store & store,
|
|||
/* Get the store paths of all non-local flakes. */
|
||||
StorePathSet closure;
|
||||
|
||||
assert(store.isValidPath(store.parseStorePath(resFlake.flake.sourceInfo.storePath)));
|
||||
closure.insert(store.parseStorePath(resFlake.flake.sourceInfo.storePath));
|
||||
assert(store.isValidPath(store.parseStorePath(lockedFlake.flake.sourceInfo.storePath)));
|
||||
closure.insert(store.parseStorePath(lockedFlake.flake.sourceInfo.storePath));
|
||||
|
||||
std::queue<std::reference_wrapper<const flake::LockedInputs>> queue;
|
||||
queue.push(resFlake.lockFile);
|
||||
queue.push(lockedFlake.lockFile);
|
||||
|
||||
while (!queue.empty()) {
|
||||
const flake::LockedInputs & flake = queue.front();
|
||||
|
@ -301,13 +301,13 @@ std::vector<std::string> InstallableFlake::getActualAttrPaths()
|
|||
return res;
|
||||
}
|
||||
|
||||
Value * InstallableFlake::getFlakeOutputs(EvalState & state, const flake::ResolvedFlake & resFlake)
|
||||
Value * InstallableFlake::getFlakeOutputs(EvalState & state, const flake::LockedFlake & lockedFlake)
|
||||
{
|
||||
auto vFlake = state.allocValue();
|
||||
|
||||
callFlake(state, resFlake, *vFlake);
|
||||
callFlake(state, lockedFlake, *vFlake);
|
||||
|
||||
makeFlakeClosureGCRoot(*state.store, flakeRef, resFlake);
|
||||
makeFlakeClosureGCRoot(*state.store, flakeRef, lockedFlake);
|
||||
|
||||
auto aOutputs = vFlake->attrs->get(state.symbols.create("outputs"));
|
||||
assert(aOutputs);
|
||||
|
@ -321,7 +321,7 @@ std::tuple<std::string, FlakeRef, flake::EvalCache::Derivation> InstallableFlake
|
|||
{
|
||||
auto state = cmd.getEvalState();
|
||||
|
||||
auto resFlake = resolveFlake(*state, flakeRef, cmd.getLockFileMode());
|
||||
auto lockedFlake = lockFlake(*state, flakeRef, cmd.getLockFileMode());
|
||||
|
||||
Value * vOutputs = nullptr;
|
||||
|
||||
|
@ -329,17 +329,17 @@ std::tuple<std::string, FlakeRef, flake::EvalCache::Derivation> InstallableFlake
|
|||
|
||||
auto & evalCache = flake::EvalCache::singleton();
|
||||
|
||||
auto fingerprint = resFlake.getFingerprint();
|
||||
auto fingerprint = lockedFlake.getFingerprint();
|
||||
|
||||
for (auto & attrPath : getActualAttrPaths()) {
|
||||
auto drv = evalCache.getDerivation(fingerprint, attrPath);
|
||||
if (drv) {
|
||||
if (state->store->isValidPath(drv->drvPath))
|
||||
return {attrPath, resFlake.flake.resolvedRef, std::move(*drv)};
|
||||
return {attrPath, lockedFlake.flake.resolvedRef, std::move(*drv)};
|
||||
}
|
||||
|
||||
if (!vOutputs)
|
||||
vOutputs = getFlakeOutputs(*state, resFlake);
|
||||
vOutputs = getFlakeOutputs(*state, lockedFlake);
|
||||
|
||||
try {
|
||||
auto * v = findAlongAttrPath(*state, attrPath, *emptyArgs, *vOutputs);
|
||||
|
@ -357,7 +357,7 @@ std::tuple<std::string, FlakeRef, flake::EvalCache::Derivation> InstallableFlake
|
|||
|
||||
evalCache.addDerivation(fingerprint, attrPath, drv);
|
||||
|
||||
return {attrPath, resFlake.flake.resolvedRef, std::move(drv)};
|
||||
return {attrPath, lockedFlake.flake.resolvedRef, std::move(drv)};
|
||||
} catch (AttrPathNotFound & e) {
|
||||
}
|
||||
}
|
||||
|
@ -375,9 +375,9 @@ std::vector<flake::EvalCache::Derivation> InstallableFlake::toDerivations()
|
|||
|
||||
Value * InstallableFlake::toValue(EvalState & state)
|
||||
{
|
||||
auto resFlake = resolveFlake(state, flakeRef, cmd.getLockFileMode());
|
||||
auto lockedFlake = lockFlake(state, flakeRef, cmd.getLockFileMode());
|
||||
|
||||
auto vOutputs = getFlakeOutputs(state, resFlake);
|
||||
auto vOutputs = getFlakeOutputs(state, lockedFlake);
|
||||
|
||||
auto emptyArgs = state.allocBindings(0);
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ struct InstallableFlake : InstallableValue
|
|||
|
||||
std::vector<std::string> getActualAttrPaths();
|
||||
|
||||
Value * getFlakeOutputs(EvalState & state, const flake::ResolvedFlake & resFlake);
|
||||
Value * getFlakeOutputs(EvalState & state, const flake::LockedFlake & lockedFlake);
|
||||
|
||||
std::tuple<std::string, FlakeRef, flake::EvalCache::Derivation> toDerivation();
|
||||
|
||||
|
|
Loading…
Reference in a new issue