diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2019-08-30 11:22:34 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2019-08-30 11:22:34 +0200 |
commit | 89468410d56d2b7b86ac9d60d70757f4d8f33718 (patch) | |
tree | 562cf2f03f3f459e34f4112aacb98653bad3013f /src/libexpr/flake/flake.cc | |
parent | ebc4dae51761cb54c1db28cf4d328d3f2f55b758 (diff) |
Extract flake dependencies from the 'outputs' arguments
That is, instead of
inputs = [ "nixpkgs" ];
outputs = inputs: ... inputs.nixpkgs ...;
you can write
outputs = { nixpkgs }: ... inputs.nixpkgs ...;
Diffstat (limited to 'src/libexpr/flake/flake.cc')
-rw-r--r-- | src/libexpr/flake/flake.cc | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc index e6cef502c..eb40f3b2a 100644 --- a/src/libexpr/flake/flake.cc +++ b/src/libexpr/flake/flake.cc @@ -232,10 +232,10 @@ Flake getFlake(EvalState & state, const FlakeRef & flakeRef) if (edition) { flake.edition = state.forceInt(*(**edition).value, *(**edition).pos); - if (flake.edition < 201906) - throw Error("flake '%s' has illegal edition %d", flakeRef, flake.edition); - if (flake.edition > 201906) + if (flake.edition > 201909) throw Error("flake '%s' requires unsupported edition %d; please upgrade Nix", flakeRef, flake.edition); + if (flake.edition < 201909) + throw Error("flake '%s' has illegal edition %d", flakeRef, flake.edition); } else throw Error("flake '%s' lacks attribute 'edition'", flakeRef); @@ -272,6 +272,15 @@ Flake getFlake(EvalState & state, const FlakeRef & flakeRef) if (auto outputs = vInfo.attrs->get(sOutputs)) { state.forceFunction(*(**outputs).value, *(**outputs).pos); flake.vOutputs = (**outputs).value; + + if (flake.vOutputs->lambda.fun->matchAttrs) { + for (auto & formal : flake.vOutputs->lambda.fun->formals->formals) { + if (formal.name != state.sSelf) { + flake.inputs.push_back(FlakeRef(formal.name)); + } + } + } + } else throw Error("flake '%s' lacks attribute 'outputs'", flakeRef); @@ -538,7 +547,7 @@ void callFlake(EvalState & state, auto vOutputs = state.allocAttr(v, state.symbols.create("outputs")); mkApp(*vOutputs, *flake.vOutputs, v); - v.attrs->push_back(Attr(state.symbols.create("self"), &v)); + v.attrs->push_back(Attr(state.sSelf, &v)); v.attrs->sort(); |