aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/flake/call-flake.nix
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-03-11 16:34:46 +0100
committerEelco Dolstra <edolstra@gmail.com>2020-03-11 17:04:51 +0100
commite188fe7c6d4b243ed62ca3d0e47abfd0eec95f79 (patch)
tree4fbb0a36dd2a295930abe9c1a3722350de48926e /src/libexpr/flake/call-flake.nix
parent35f66517350402792aded1b677a47526e23e78ef (diff)
Move call-flake.nix into libexpr
Diffstat (limited to 'src/libexpr/flake/call-flake.nix')
-rw-r--r--src/libexpr/flake/call-flake.nix22
1 files changed, 22 insertions, 0 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