@@ -27,6 +27,7 @@ git config --global protocol.file.allow always
2727
2828rootRepo=$TEST_ROOT /rootRepo
2929subRepo=$TEST_ROOT /submodule
30+ otherRepo=$TEST_ROOT /otherRepo
3031
3132
3233createGitRepo " $subRepo "
@@ -91,6 +92,33 @@ git -C "$rootRepo" commit -a -m "Bla"
9192storePath=$( 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