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) {
using namespace flake;
auto flakeRef = parseFlakeRef(myArgs.releaseExpr, absPath("."));
auto [flakeRef, fragment] = parseFlakeRefWithFragment(myArgs.releaseExpr, absPath("."));
auto vFlake = state.allocValue();
@ -127,14 +127,15 @@ static void worker(
auto vOutputs = vFlake->attrs->get(state.symbols.create("outputs"))->value;
state.forceValue(*vOutputs);
vTop = *vOutputs;
auto aHydraJobs = vOutputs->attrs->get(state.symbols.create("hydraJobs"));
if (!aHydraJobs)
aHydraJobs = vOutputs->attrs->get(state.symbols.create("checks"));
if (!aHydraJobs)
throw Error("flake '%s' does not provide any Hydra jobs or checks", flakeRef);
vTop = *aHydraJobs->value;
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);

View file

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