Simplify top-level value fetching.
This commit is contained in:
parent
e05e625411
commit
dd8a2e89a0
|
@ -162,6 +162,12 @@ static Value* flakeTopLevelValue(EvalState & state, Bindings & autoArgs) {
|
||||||
return vRoot;
|
return vRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Value * topLevelValue(EvalState & state, Bindings & autoArgs) {
|
||||||
|
return myArgs.flake
|
||||||
|
? flakeTopLevelValue(state, autoArgs)
|
||||||
|
: releaseExprTopLevelValue(state, autoArgs);
|
||||||
|
}
|
||||||
|
|
||||||
static void worker(
|
static void worker(
|
||||||
EvalState & state,
|
EvalState & state,
|
||||||
Bindings & autoArgs,
|
Bindings & autoArgs,
|
||||||
|
@ -169,42 +175,7 @@ static void worker(
|
||||||
AutoCloseFD & from,
|
AutoCloseFD & from,
|
||||||
const Path &gcRootsDir)
|
const Path &gcRootsDir)
|
||||||
{
|
{
|
||||||
Value vTop;
|
auto vRoot = topLevelValue(state, autoArgs);
|
||||||
|
|
||||||
if (myArgs.flake) {
|
|
||||||
using namespace flake;
|
|
||||||
|
|
||||||
auto [flakeRef, fragment] = parseFlakeRefWithFragment(myArgs.releaseExpr, absPath("."));
|
|
||||||
|
|
||||||
auto vFlake = state.allocValue();
|
|
||||||
|
|
||||||
auto lockedFlake = lockFlake(state, flakeRef,
|
|
||||||
LockFlags {
|
|
||||||
.updateLockFile = false,
|
|
||||||
.useRegistries = false,
|
|
||||||
.allowMutable = false,
|
|
||||||
});
|
|
||||||
|
|
||||||
callFlake(state, lockedFlake, *vFlake);
|
|
||||||
|
|
||||||
auto vOutputs = vFlake->attrs->get(state.symbols.create("outputs"))->value;
|
|
||||||
state.forceValue(*vOutputs, noPos);
|
|
||||||
vTop = *vOutputs;
|
|
||||||
|
|
||||||
if (fragment.length() > 0) {
|
|
||||||
Bindings & bindings(*state.allocBindings(0));
|
|
||||||
auto [nTop, pos] = findAlongAttrPath(state, fragment, bindings, vTop);
|
|
||||||
if (!nTop)
|
|
||||||
throw Error("error: attribute '%s' missing", nTop);
|
|
||||||
vTop = *nTop;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
state.evalFile(lookupFileArg(state, myArgs.releaseExpr), vTop);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto vRoot = state.allocValue();
|
|
||||||
state.autoCallFunction(autoArgs, vTop, *vRoot);
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
/* Wait for the master to send us a job name. */
|
/* Wait for the master to send us a job name. */
|
||||||
|
|
Loading…
Reference in a new issue