aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/flake
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr/flake')
-rw-r--r--src/libexpr/flake/call-flake.nix22
-rw-r--r--src/libexpr/flake/flake.cc11
2 files changed, 31 insertions, 2 deletions
diff --git a/src/libexpr/flake/call-flake.nix b/src/libexpr/flake/call-flake.nix
new file mode 100644
index 000000000..c59a0c75f
--- /dev/null
+++ b/src/libexpr/flake/call-flake.nix
@@ -0,0 +1,22 @@
+locks: rootSrc: rootSubdir:
+
+let
+
+ callFlake = sourceInfo: subdir: locks:
+ let
+ flake = import (sourceInfo + "/" + subdir + "/flake.nix");
+
+ inputs = builtins.mapAttrs (n: v:
+ if v.flake or true
+ then callFlake (fetchTree (removeAttrs v.locked ["dir"])) (v.locked.dir or "") v.inputs
+ else fetchTree v.locked) locks;
+
+ outputs = flake.outputs (inputs // { self = result; });
+
+ result = outputs // sourceInfo // { inherit inputs; inherit outputs; inherit sourceInfo; };
+ in
+ assert flake.edition == 201909;
+
+ result;
+
+in callFlake rootSrc rootSubdir (builtins.fromJSON locks).inputs
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc
index 9d8a5f950..249ceba6c 100644
--- a/src/libexpr/flake/flake.cc
+++ b/src/libexpr/flake/flake.cc
@@ -623,7 +623,6 @@ void callFlake(EvalState & state,
const LockedInputs & lockedInputs,
Value & vRes)
{
- auto vCallFlake = state.allocValue();
auto vLocks = state.allocValue();
auto vRootSrc = state.allocValue();
auto vRootSubdir = state.allocValue();
@@ -636,7 +635,15 @@ void callFlake(EvalState & state,
mkString(*vRootSubdir, flake.lockedRef.subdir);
- state.evalFile(canonPath(settings.nixDataDir + "/nix/corepkgs/call-flake.nix", true), *vCallFlake);
+ static Value * vCallFlake = nullptr;
+
+ if (!vCallFlake) {
+ vCallFlake = state.allocValue();
+ state.eval(state.parseExprFromString(
+ #include "call-flake.nix.gen.hh"
+ , "/"), *vCallFlake);
+ }
+
state.callFunction(*vCallFlake, *vLocks, *vTmp1, noPos);
state.callFunction(*vTmp1, *vRootSrc, *vTmp2, noPos);
state.callFunction(*vTmp2, *vRootSubdir, vRes, noPos);