aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/flake/call-flake.nix
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2023-02-22 03:28:30 +0100
committerRobert Hensing <robert@roberthensing.nl>2023-02-22 03:31:24 +0100
commit5d834c40d0a1e397cc650f88b1544ee2e5912400 (patch)
tree78fedddf2142869b39c0f9473f6e3f162d5c7161 /src/libexpr/flake/call-flake.nix
parent904a107d16b69f28b9d61c677eb27b953d421a54 (diff)
flakes: Differentiate `self.outPath` and `self.sourceInfo.outPath`
It would be incorrect to say that the `sourceInfo` has an `outPath` that isn't the root. `sourceInfo` is about the root, whereas only the flake may not be about the root. Thanks Eelco for pointing that out.
Diffstat (limited to 'src/libexpr/flake/call-flake.nix')
-rw-r--r--src/libexpr/flake/call-flake.nix22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/libexpr/flake/call-flake.nix b/src/libexpr/flake/call-flake.nix
index 7dc03e7f5..4beb0b0fe 100644
--- a/src/libexpr/flake/call-flake.nix
+++ b/src/libexpr/flake/call-flake.nix
@@ -9,16 +9,14 @@ let
(key: node:
let
- rawSourceInfo =
+ sourceInfo =
if key == lockFile.root
then rootSrc
else fetchTree (node.info or {} // removeAttrs node.locked ["dir"]);
subdir = if key == lockFile.root then rootSubdir else node.locked.dir or "";
- outPath = rawSourceInfo + ((if subdir == "" then "" else "/") + subdir);
-
- sourceInfo = rawSourceInfo // { inherit outPath; };
+ outPath = sourceInfo + ((if subdir == "" then "" else "/") + subdir);
flake = import (outPath + "/flake.nix");
@@ -47,7 +45,21 @@ let
outputs = flake.outputs (inputs // { self = result; });
- result = outputs // sourceInfo // { inherit inputs; inherit outputs; inherit sourceInfo; _type = "flake"; };
+ result =
+ outputs
+ # We add the sourceInfo attribute for its metadata, as they are
+ # relevant metadata for the flake. However, the outPath of the
+ # sourceInfo does not necessarily match the outPath of the flake,
+ # as the flake may be in a subdirectory of a source.
+ # This is shadowed in the next //
+ // sourceInfo
+ // {
+ # This shadows the sourceInfo.outPath
+ inherit outPath;
+
+ inherit inputs; inherit outputs; inherit sourceInfo; _type = "flake";
+ };
+
in
if node.flake or true then
assert builtins.isFunction flake.outputs;