Skip to content

Commit 38f3914

Browse files
committed
Add a test for a flake referencing a flake that has inputs.self
1 parent 25fcc8d commit 38f3914

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/functional/flakes/flake-in-submodule.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ git config --global protocol.file.allow always
2727

2828
rootRepo=$TEST_ROOT/rootRepo
2929
subRepo=$TEST_ROOT/submodule
30+
otherRepo=$TEST_ROOT/otherRepo
3031

3132

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

95+
96+
# Test another repo referring to a repo that uses inputs.self.
97+
createGitRepo "$otherRepo"
98+
cat > "$otherRepo"/flake.nix <<EOF
99+
{
100+
inputs.root.url = "git+file://$rootRepo";
101+
outputs = { self, root }: {
102+
foo = root.foo;
103+
};
104+
}
105+
EOF
106+
git -C "$otherRepo" add flake.nix
107+
108+
# The first call should refetch the root repo...
109+
expectStderr 0 nix eval --raw "$otherRepo#foo" -vvvvv | grepQuiet "refetching"
110+
111+
[[ $(jq .nodes.root_2.locked.submodules "$otherRepo/flake.lock") == true ]]
112+
113+
# ... but the second call should have 'submodules = true' in flake.lock, so it should not refetch.
114+
rm -rf "$TEST_HOME/.cache"
115+
clearStore
116+
expectStderr 0 nix eval --raw "$otherRepo#foo" -vvvvv | grepQuietInverse "refetching"
117+
118+
storePath=$(nix eval --raw "$otherRepo#foo")
119+
[[ -e "$storePath/submodule" ]]
120+
121+
94122
# The root repo may use the submodule repo as an input
95123
# through the relative path. This may change in the future;
96124
# see: https://discourse.nixos.org/t/57783 and #9708.

0 commit comments

Comments
 (0)