forked from lix-project/lix
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.
This commit is contained in:
parent
904a107d16
commit
5d834c40d0
|
@ -9,16 +9,14 @@ let
|
||||||
(key: node:
|
(key: node:
|
||||||
let
|
let
|
||||||
|
|
||||||
rawSourceInfo =
|
sourceInfo =
|
||||||
if key == lockFile.root
|
if key == lockFile.root
|
||||||
then rootSrc
|
then rootSrc
|
||||||
else fetchTree (node.info or {} // removeAttrs node.locked ["dir"]);
|
else fetchTree (node.info or {} // removeAttrs node.locked ["dir"]);
|
||||||
|
|
||||||
subdir = if key == lockFile.root then rootSubdir else node.locked.dir or "";
|
subdir = if key == lockFile.root then rootSubdir else node.locked.dir or "";
|
||||||
|
|
||||||
outPath = rawSourceInfo + ((if subdir == "" then "" else "/") + subdir);
|
outPath = sourceInfo + ((if subdir == "" then "" else "/") + subdir);
|
||||||
|
|
||||||
sourceInfo = rawSourceInfo // { inherit outPath; };
|
|
||||||
|
|
||||||
flake = import (outPath + "/flake.nix");
|
flake = import (outPath + "/flake.nix");
|
||||||
|
|
||||||
|
@ -47,7 +45,21 @@ let
|
||||||
|
|
||||||
outputs = flake.outputs (inputs // { self = result; });
|
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
|
in
|
||||||
if node.flake or true then
|
if node.flake or true then
|
||||||
assert builtins.isFunction flake.outputs;
|
assert builtins.isFunction flake.outputs;
|
||||||
|
|
|
@ -46,6 +46,7 @@ test_git_subdir_self_path() {
|
||||||
default =
|
default =
|
||||||
assert builtins.readFile ./message == "all good\n";
|
assert builtins.readFile ./message == "all good\n";
|
||||||
assert builtins.readFile (inputs.self + "/message") == "all good\n";
|
assert builtins.readFile (inputs.self + "/message") == "all good\n";
|
||||||
|
assert inputs.self.outPath == inputs.self.sourceInfo.outPath + "/b-low";
|
||||||
import ./simple.nix;
|
import ./simple.nix;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue