Skip to content

Commit

Permalink
nix#7796: Ensure that self.outPath == ./.
Browse files Browse the repository at this point in the history
Ported from NixOS/nix#7796
First released in Nix 2.14
  • Loading branch information
roberth committed Oct 2, 2023
1 parent 35bb57c commit bc5e257
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ let

subdir = if key == lockFile.root then "" else node.locked.dir or "";

flake = import (sourceInfo + (if subdir != "" then "/" else "") + subdir + "/flake.nix");
outPath = sourceInfo + ((if subdir == "" then "" else "/") + subdir);

flake = import (outPath + "/flake.nix");

inputs = builtins.mapAttrs
(inputName: inputSpec: allNodes.${resolveInput inputSpec})
Expand All @@ -167,7 +169,20 @@ 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
Expand Down

0 comments on commit bc5e257

Please sign in to comment.