2024-05-28 19:43:04 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-07-13 21:16:39 +03:00
|
|
|
# Test circular flake dependencies.
|
|
|
|
source ./common.sh
|
|
|
|
|
|
|
|
requireGit
|
|
|
|
|
|
|
|
flakeA=$TEST_ROOT/flakeA
|
|
|
|
flakeB=$TEST_ROOT/flakeB
|
|
|
|
|
2024-06-04 23:33:12 +03:00
|
|
|
createGitRepo "$flakeA"
|
|
|
|
createGitRepo "$flakeB"
|
2022-07-13 21:16:39 +03:00
|
|
|
|
2024-06-04 23:33:12 +03:00
|
|
|
cat > "$flakeA"/flake.nix <<EOF
|
2022-07-13 21:16:39 +03:00
|
|
|
{
|
|
|
|
inputs.b.url = git+file://$flakeB;
|
|
|
|
inputs.b.inputs.a.follows = "/";
|
|
|
|
|
|
|
|
outputs = { self, b }: {
|
|
|
|
foo = 123 + b.bar;
|
|
|
|
xyzzy = 1000;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2024-06-04 23:33:12 +03:00
|
|
|
git -C "$flakeA" add flake.nix
|
2022-07-13 21:16:39 +03:00
|
|
|
|
2024-06-04 23:33:12 +03:00
|
|
|
cat > "$flakeB"/flake.nix <<EOF
|
2022-07-13 21:16:39 +03:00
|
|
|
{
|
|
|
|
inputs.a.url = git+file://$flakeA;
|
|
|
|
|
|
|
|
outputs = { self, a }: {
|
|
|
|
bar = 456 + a.xyzzy;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2024-06-04 23:33:12 +03:00
|
|
|
git -C "$flakeB" add flake.nix
|
|
|
|
git -C "$flakeB" commit -a -m 'Foo'
|
2022-07-13 21:16:39 +03:00
|
|
|
|
2024-06-04 23:33:12 +03:00
|
|
|
[[ $(nix eval "$flakeA#foo") = 1579 ]]
|
|
|
|
[[ $(nix eval "$flakeA#foo") = 1579 ]]
|
2022-07-13 21:16:39 +03:00
|
|
|
|
2024-06-04 23:33:12 +03:00
|
|
|
sed -i "$flakeB"/flake.nix -e 's/456/789/'
|
|
|
|
git -C "$flakeB" commit -a -m 'Foo'
|
2022-07-13 21:16:39 +03:00
|
|
|
|
2024-06-04 23:33:12 +03:00
|
|
|
nix flake update b --flake "$flakeA"
|
|
|
|
[[ $(nix eval "$flakeA#foo") = 1912 ]]
|
2022-07-13 21:16:39 +03:00
|
|
|
|
|
|
|
# Test list-inputs with circular dependencies
|
2024-06-04 23:33:12 +03:00
|
|
|
nix flake metadata "$flakeA"
|
2022-07-13 21:16:39 +03:00
|
|
|
|