From bc5e257a8d0c4df04652ecff9053d05b0dc9484e Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 2 Oct 2023 18:57:55 +0200 Subject: [PATCH] nix#7796: Ensure that `self.outPath == ./.` Ported from https://github.com/NixOS/nix/pull/7796 First released in Nix 2.14 --- default.nix | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index f4f81dc..8c9bc1d 100644 --- a/default.nix +++ b/default.nix @@ -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}) @@ -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