testing: migrate flakes/flakes.sh (part 15)

flake follows handling during locking

Change-Id: Ia3f2b7a8df1d0ec51fd97d14d49788b33dda7754
This commit is contained in:
eldritch horrors
2026-02-26 13:11:25 +00:00
parent 2634585a48
commit cbe4d1b339
2 changed files with 35 additions and 41 deletions
-41
View File
@@ -215,47 +215,6 @@ git -C $flake3Dir add flake.nix flake.lock
git -C $flake3Dir commit -m 'Remove packages.xyzzy'
git -C $flake3Dir checkout master
# Test 'follows' inputs.
cat > $flake3Dir/flake.nix <<EOF
{
inputs.foo = {
type = "indirect";
id = "flake1";
};
inputs.bar.follows = "foo";
outputs = { self, foo, bar }: {
};
}
EOF
nix flake lock $flake3Dir
[[ $(jq -c .nodes.root.inputs.bar $flake3Dir/flake.lock) = '["foo"]' ]]
cat > $flake3Dir/flake.nix <<EOF
{
inputs.bar.follows = "flake2/flake1";
outputs = { self, flake2, bar }: {
};
}
EOF
nix flake lock $flake3Dir
[[ $(jq -c .nodes.root.inputs.bar $flake3Dir/flake.lock) = '["flake2","flake1"]' ]]
cat > $flake3Dir/flake.nix <<EOF
{
inputs.bar.follows = "flake2";
outputs = { self, flake2, bar }: {
};
}
EOF
nix flake lock $flake3Dir
[[ $(jq -c .nodes.root.inputs.bar $flake3Dir/flake.lock) = '["flake2"]' ]]
# Test overriding inputs of inputs.
writeTrivialFlake $flake7Dir
git -C $flake7Dir add flake.nix
+35
View File
@@ -577,6 +577,41 @@ class TestLock:
assert lock["nodes"]["flake1"]["locked"]["rev"] == flake1_modified_commit
assert lock["nodes"]["flake1_2"]["locked"]["rev"] == flake1_modified_commit
class TestFollows:
def test_simple_explicit(self, nix: Nix, flake3: Path):
(flake3 / "flake.nix").write_text("""{
inputs.foo = {
type = "indirect";
id = "flake1";
};
inputs.bar.follows = "foo";
outputs = { self, foo, bar }: {};
}""")
nix.nix(["flake", "lock", flake3]).run().ok()
lock = json.loads((flake3 / "flake.lock").read_text())
assert lock["nodes"]["root"]["inputs"]["bar"] == ["foo"]
def test_nested_implicit(self, nix: Nix, flake3: Path):
(flake3 / "flake.nix").write_text("""{
inputs.bar.follows = "flake2/flake1";
outputs = { self, flake2, bar }: {};
}""")
nix.nix(["flake", "lock", flake3]).run().ok()
lock = json.loads((flake3 / "flake.lock").read_text())
assert lock["nodes"]["root"]["inputs"]["bar"] == ["flake2", "flake1"]
def test_simple_implicit(self, nix: Nix, flake3: Path):
(flake3 / "flake.nix").write_text("""{
inputs.bar.follows = "flake2";
outputs = { self, flake2, bar }: {};
}""")
nix.nix(["flake", "lock", flake3]).run().ok()
lock = json.loads((flake3 / "flake.lock").read_text())
assert lock["nodes"]["root"]["inputs"]["bar"] == ["flake2"]
@pytest.mark.usefixtures("registry")
class TestMetadata: