Skip to content

Commit

Permalink
call-flake.nix: Fix relative path resolution
Browse files Browse the repository at this point in the history
`parentNode.sourceInfo.outPath` does not include the subdir of the
parent flake, while `parentNode.outPath` does. So we need to use the
latter.
  • Loading branch information
edolstra committed May 17, 2024
1 parent b2be6fe commit 49f592d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/libexpr/flake/call-flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions tests/functional/flakes/relative-paths.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 49f592d

Please sign in to comment.