From 0648bc0cb83c1e4c132db5648b3761ce4c0350ea Mon Sep 17 00:00:00 2001 From: adisbladis Date: Thu, 26 Aug 2021 18:48:11 -0500 Subject: [PATCH] Select flake output by the flake fragment --- src/nix-eval-jobs.cc | 17 +++++++++-------- tests/test_eval.py | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/nix-eval-jobs.cc b/src/nix-eval-jobs.cc index ce7462a..c07ca9b 100644 --- a/src/nix-eval-jobs.cc +++ b/src/nix-eval-jobs.cc @@ -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); diff --git a/tests/test_eval.py b/tests/test_eval.py index 7e32d7a..32a31e7 100644 --- a/tests/test_eval.py +++ b/tests/test_eval.py @@ -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: