From 49f592dd99b1b7307ae0968453110b27757c21d7 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 17 May 2024 16:38:01 +0200 Subject: [PATCH] call-flake.nix: Fix relative path resolution `parentNode.sourceInfo.outPath` does not include the subdir of the parent flake, while `parentNode.outPath` does. So we need to use the latter. --- src/libexpr/flake/call-flake.nix | 2 +- tests/functional/flakes/relative-paths.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libexpr/flake/call-flake.nix b/src/libexpr/flake/call-flake.nix index 43ecb7f156f..38dc74ba135 100644 --- a/src/libexpr/flake/call-flake.nix +++ b/src/libexpr/flake/call-flake.nix @@ -47,7 +47,7 @@ let else if node.locked.type == "path" && builtins.substring 0 1 node.locked.path != "/" then parentNode.sourceInfo // { - outPath = parentNode.sourceInfo.outPath + ("/" + node.locked.path); + outPath = parentNode.outPath + ("/" + node.locked.path); } else # FIXME: remove obsolete node.info. diff --git a/tests/functional/flakes/relative-paths.sh b/tests/functional/flakes/relative-paths.sh index cecda44d4bc..38987d6afb1 100644 --- a/tests/functional/flakes/relative-paths.sh +++ b/tests/functional/flakes/relative-paths.sh @@ -63,6 +63,10 @@ git -C $rootFlake add flake.nix sub2/flake.nix [[ $(nix eval $subflake2#y) = 15 ]] +# Make sure that this still works after commiting the lock file. +git -C $rootFlake add sub2/flake.lock +[[ $(nix eval $subflake2#y) = 15 ]] + # Make sure there are no content locks for relative path flakes. (! grep "$TEST_ROOT" $subflake2/flake.lock) (! grep "$NIX_STORE_DIR" $subflake2/flake.lock)