Skip to content

Commit

Permalink
Add a test for a flake referencing a flake that has inputs.self
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Feb 4, 2025
1 parent 25fcc8d commit 38f3914
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/functional/flakes/flake-in-submodule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ git config --global protocol.file.allow always

rootRepo=$TEST_ROOT/rootRepo
subRepo=$TEST_ROOT/submodule
otherRepo=$TEST_ROOT/otherRepo


createGitRepo "$subRepo"
Expand Down Expand Up @@ -91,6 +92,33 @@ git -C "$rootRepo" commit -a -m "Bla"
storePath=$(nix eval --raw "$rootRepo#foo")
[[ -e "$storePath/submodule" ]]


# Test another repo referring to a repo that uses inputs.self.
createGitRepo "$otherRepo"
cat > "$otherRepo"/flake.nix <<EOF
{
inputs.root.url = "git+file://$rootRepo";
outputs = { self, root }: {
foo = root.foo;
};
}
EOF
git -C "$otherRepo" add flake.nix

# The first call should refetch the root repo...
expectStderr 0 nix eval --raw "$otherRepo#foo" -vvvvv | grepQuiet "refetching"

[[ $(jq .nodes.root_2.locked.submodules "$otherRepo/flake.lock") == true ]]

# ... but the second call should have 'submodules = true' in flake.lock, so it should not refetch.
rm -rf "$TEST_HOME/.cache"
clearStore
expectStderr 0 nix eval --raw "$otherRepo#foo" -vvvvv | grepQuietInverse "refetching"

storePath=$(nix eval --raw "$otherRepo#foo")
[[ -e "$storePath/submodule" ]]


# The root repo may use the submodule repo as an input
# through the relative path. This may change in the future;
# see: https://discourse.nixos.org/t/57783 and #9708.
Expand Down

0 comments on commit 38f3914

Please sign in to comment.