forked from lix-project/lix
Pass system to bundler
This commit is contained in:
parent
22fcfdf18a
commit
fa2d1fb36e
|
@ -75,17 +75,21 @@ struct CmdBundle : InstallableCommand
|
||||||
const flake::LockFlags lockFlags{ .writeLockFile = false };
|
const flake::LockFlags lockFlags{ .writeLockFile = false };
|
||||||
auto bundler = InstallableFlake(
|
auto bundler = InstallableFlake(
|
||||||
evalState, std::move(bundlerFlakeRef),
|
evalState, std::move(bundlerFlakeRef),
|
||||||
Strings{bundlerName == "" ? ("defaultBundler." + settings.thisSystem.get()) : bundlerName},
|
Strings{bundlerName == "" ? "defaultBundler" : bundlerName},
|
||||||
Strings({"bundlers." + settings.thisSystem.get() + "."}), lockFlags);
|
Strings({"bundlers."}), lockFlags);
|
||||||
|
|
||||||
Value * arg = evalState->allocValue();
|
Value * arg = evalState->allocValue();
|
||||||
evalState->mkAttrs(*arg, 1);
|
evalState->mkAttrs(*arg, 2);
|
||||||
|
|
||||||
PathSet context;
|
PathSet context;
|
||||||
for (auto & i : app.context)
|
for (auto & i : app.context)
|
||||||
context.insert("=" + store->printStorePath(i.path));
|
context.insert("=" + store->printStorePath(i.path));
|
||||||
mkString(*evalState->allocAttr(*arg, evalState->symbols.create("program")), app.program, context);
|
mkString(*evalState->allocAttr(*arg, evalState->symbols.create("program")), app.program, context);
|
||||||
|
|
||||||
|
mkString(*evalState->allocAttr(*arg, evalState->symbols.create("system")), settings.thisSystem.get());
|
||||||
|
|
||||||
|
arg->attrs->sort();
|
||||||
|
|
||||||
auto vRes = evalState->allocValue();
|
auto vRes = evalState->allocValue();
|
||||||
evalState->callFunction(*bundler.toValue(*evalState).first, *arg, *vRes, noPos);
|
evalState->callFunction(*bundler.toValue(*evalState).first, *arg, *vRes, noPos);
|
||||||
|
|
||||||
|
|
|
@ -374,8 +374,9 @@ struct CmdFlakeCheck : FlakeCommand
|
||||||
if (v.type != tLambda)
|
if (v.type != tLambda)
|
||||||
throw Error("bundler must be a function");
|
throw Error("bundler must be a function");
|
||||||
if (!v.lambda.fun->formals ||
|
if (!v.lambda.fun->formals ||
|
||||||
v.lambda.fun->formals->argNames.find(state->symbols.create("program")) == v.lambda.fun->formals->argNames.end())
|
v.lambda.fun->formals->argNames.find(state->symbols.create("program")) == v.lambda.fun->formals->argNames.end() ||
|
||||||
throw Error("bundler must take formal argument 'program'");
|
v.lambda.fun->formals->argNames.find(state->symbols.create("system")) == v.lambda.fun->formals->argNames.end())
|
||||||
|
throw Error("bundler must take formal arguments 'program' and 'system'");
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
e.addTrace(pos, hintfmt("while checking the template '%s'", attrPath));
|
e.addTrace(pos, hintfmt("while checking the template '%s'", attrPath));
|
||||||
throw;
|
throw;
|
||||||
|
@ -505,21 +506,13 @@ struct CmdFlakeCheck : FlakeCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (name == "defaultBundler")
|
else if (name == "defaultBundler")
|
||||||
for (auto & attr : *vOutput.attrs) {
|
checkBundler(name, vOutput, pos);
|
||||||
checkSystemName(attr.name, *attr.pos);
|
|
||||||
checkBundler(fmt("%s.%s", name, attr.name), *attr.value, *attr.pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (name == "bundlers") {
|
else if (name == "bundlers") {
|
||||||
state->forceAttrs(vOutput, pos);
|
state->forceAttrs(vOutput, pos);
|
||||||
for (auto & attr : *vOutput.attrs) {
|
for (auto & attr : *vOutput.attrs)
|
||||||
checkSystemName(attr.name, *attr.pos);
|
checkBundler(fmt("%s.%s", name, attr.name),
|
||||||
state->forceAttrs(*attr.value, *attr.pos);
|
*attr.value, *attr.pos);
|
||||||
for (auto & attr2 : *attr.value->attrs)
|
|
||||||
checkBundler(
|
|
||||||
fmt("%s.%s.%s", name, attr.name, attr2.name),
|
|
||||||
*attr2.value, *attr2.pos);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue