diff --git a/tests/functional/flakes/unlocked-override.sh b/tests/functional/flakes/unlocked-override.sh deleted file mode 100644 index 8abc8b7d3..000000000 --- a/tests/functional/flakes/unlocked-override.sh +++ /dev/null @@ -1,30 +0,0 @@ -source ./common.sh - -requireGit - -flake1Dir=$TEST_ROOT/flake1 -flake2Dir=$TEST_ROOT/flake2 - -createGitRepo $flake1Dir -cat > $flake1Dir/flake.nix < $flake1Dir/x.nix -git -C $flake1Dir add flake.nix x.nix -git -C $flake1Dir commit -m Initial - -createGitRepo $flake2Dir -cat > $flake2Dir/flake.nix < $flake1Dir/x.nix - -[[ $(nix eval --json $flake2Dir#x --override-input flake1 $TEST_ROOT/flake1) = 456 ]] diff --git a/tests/functional/meson.build b/tests/functional/meson.build index 9257a4970..920a4354d 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -40,7 +40,6 @@ functional_tests_scripts = [ 'flakes/inputs.sh', 'flakes/follow-paths.sh', 'flakes/bundle.sh', - 'flakes/unlocked-override.sh', 'flakes/build-paths.sh', 'flakes/flake-in-submodule.sh', 'flakes/flake-metadata.sh', diff --git a/tests/functional2/flakes/test_unlocked_override.py b/tests/functional2/flakes/test_unlocked_override.py new file mode 100644 index 000000000..71d8006c2 --- /dev/null +++ b/tests/functional2/flakes/test_unlocked_override.py @@ -0,0 +1,53 @@ +from testlib.fixtures.nix import Nix +from testlib.fixtures.git import Git +from testlib.fixtures.file_helper import with_files, File +from testlib.utils import get_global_asset_pack +from pathlib import Path + + +@with_files( + { + "flake1": get_global_asset_pack(".git") + | { + "flake.nix": File("""{ + outputs = { self }: { x = import ./x.nix; }; + }"""), + "x.nix": File("123"), + }, + "flake2": get_global_asset_pack(".git") + | { + "flake.nix": File("""{ + outputs = { self, flake1 }: { x = flake1.x; }; + }""") + }, + } +) +def test_unlocked_override(nix: Nix, files: Path, git: Git): + nix.settings.add_xp_feature("nix-command", "flakes") + + git(files / "flake1", "add", "flake.nix", "x.nix") + git(files / "flake1", "commit", "-m", "Initial") + + git(files / "flake2", "add", "flake.nix") + + assert ( + nix.nix( + ["eval", "--json", f"{files}/flake2#x", "--override-input", "flake1", files / "flake1"] + ) + .run() + .ok() + .stdout_s + == "123\n" + ) + + (files / "flake1/x.nix").write_text("456") + + assert ( + nix.nix( + ["eval", "--json", f"{files}/flake2#x", "--override-input", "flake1", files / "flake1"] + ) + .run() + .ok() + .stdout_s + == "456\n" + )