Select flake output by the flake fragment

This commit is contained in:
adisbladis 2021-08-26 18:48:11 -05:00
parent 434376f8e1
commit 0648bc0cb8
No known key found for this signature in database
GPG key ID: 110BFAD44C6249B7
2 changed files with 10 additions and 9 deletions

View file

@ -112,7 +112,7 @@ static void worker(
if (myArgs.flake) { if (myArgs.flake) {
using namespace flake; using namespace flake;
auto flakeRef = parseFlakeRef(myArgs.releaseExpr, absPath(".")); auto [flakeRef, fragment] = parseFlakeRefWithFragment(myArgs.releaseExpr, absPath("."));
auto vFlake = state.allocValue(); auto vFlake = state.allocValue();
@ -127,14 +127,15 @@ static void worker(
auto vOutputs = vFlake->attrs->get(state.symbols.create("outputs"))->value; auto vOutputs = vFlake->attrs->get(state.symbols.create("outputs"))->value;
state.forceValue(*vOutputs); state.forceValue(*vOutputs);
vTop = *vOutputs;
auto aHydraJobs = vOutputs->attrs->get(state.symbols.create("hydraJobs")); if (fragment.length() > 0) {
if (!aHydraJobs) Bindings & bindings(*state.allocBindings(0));
aHydraJobs = vOutputs->attrs->get(state.symbols.create("checks")); auto [nTop, pos] = findAlongAttrPath(state, fragment, bindings, vTop);
if (!aHydraJobs) if (!nTop)
throw Error("flake '%s' does not provide any Hydra jobs or checks", flakeRef); throw Error("error: attribute '%s' missing", nTop);
vTop = *nTop;
vTop = *aHydraJobs->value; }
} else { } else {
state.evalFile(lookupFileArg(state, myArgs.releaseExpr), vTop); state.evalFile(lookupFileArg(state, myArgs.releaseExpr), vTop);

View file

@ -36,7 +36,7 @@ def common_test(extra_args: List[str]) -> None:
def test_flake() -> None: def test_flake() -> None:
common_test(["--flake", ".#"]) common_test(["--flake", ".#hydraJobs"])
def test_expression() -> None: def test_expression() -> None: