Loading pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/models.py +1 −1 Original line number Diff line number Diff line Loading @@ -122,7 +122,7 @@ class Flake: m = cls._re.match(flake_str) assert m is not None, f"got no matches for {flake_str}" attr = m.group("attr") nixos_attr = f"nixosConfigurations.{attr or hostname_fn() or 'default'}" nixos_attr = f'nixosConfigurations."{attr or hostname_fn() or "default"}"' path_str = m.group("path") if ":" in path_str: return cls(path_str, nixos_attr) Loading pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_main.py +7 −7 Original line number Diff line number Diff line Loading @@ -385,7 +385,7 @@ def test_execute_nix_build_image_flake(mock_run: Mock, tmp_path: Path) -> None: "nix", "eval", "--json", "/path/to/config#nixosConfigurations.hostname.config.system.build.images", '/path/to/config#nixosConfigurations."hostname".config.system.build.images', "--apply", "builtins.attrNames", ], Loading @@ -400,7 +400,7 @@ def test_execute_nix_build_image_flake(mock_run: Mock, tmp_path: Path) -> None: "nix-command flakes", "build", "--print-out-paths", "/path/to/config#nixosConfigurations.hostname.config.system.build.images.azure", '/path/to/config#nixosConfigurations."hostname".config.system.build.images.azure', ], check=True, stdout=PIPE, Loading @@ -411,7 +411,7 @@ def test_execute_nix_build_image_flake(mock_run: Mock, tmp_path: Path) -> None: "nix", "eval", "--json", "/path/to/config#nixosConfigurations.hostname.config.system.build.images.azure.passthru.filePath", '/path/to/config#nixosConfigurations."hostname".config.system.build.images.azure.passthru.filePath', ], check=True, stdout=PIPE, Loading Loading @@ -462,7 +462,7 @@ def test_execute_nix_switch_flake(mock_run: Mock, tmp_path: Path) -> None: "nix-command flakes", "build", "--print-out-paths", "/path/to/config#nixosConfigurations.hostname.config.system.build.toplevel", '/path/to/config#nixosConfigurations."hostname".config.system.build.toplevel', "-v", "--option", "narinfo-cache-negative-ttl", Loading Loading @@ -756,7 +756,7 @@ def test_execute_nix_switch_flake_target_host( "nix-command flakes", "build", "--print-out-paths", "/path/to/config#nixosConfigurations.hostname.config.system.build.toplevel", '/path/to/config#nixosConfigurations."hostname".config.system.build.toplevel', "--no-link", ], check=True, Loading Loading @@ -860,7 +860,7 @@ def test_execute_nix_switch_flake_build_host( "nix-command flakes", "eval", "--raw", "/path/to/config#nixosConfigurations.hostname.config.system.build.toplevel.drvPath", '/path/to/config#nixosConfigurations."hostname".config.system.build.toplevel.drvPath', ], check=True, stdout=PIPE, Loading Loading @@ -1063,7 +1063,7 @@ def test_execute_test_flake(mock_run: Mock, tmp_path: Path) -> None: "nix-command flakes", "build", "--print-out-paths", "github:user/repo#nixosConfigurations.hostname.config.system.build.toplevel", 'github:user/repo#nixosConfigurations."hostname".config.system.build.toplevel', ], check=True, stdout=PIPE, Loading pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_models.py +19 −15 Original line number Diff line number Diff line Loading @@ -32,38 +32,42 @@ def test_build_attr_to_attr() -> None: def test_flake_parse(tmpdir: Path, monkeypatch: MonkeyPatch) -> None: assert m.Flake.parse("/path/to/flake#attr") == m.Flake( Path("/path/to/flake"), "nixosConfigurations.attr" Path("/path/to/flake"), 'nixosConfigurations."attr"' ) assert m.Flake.parse("/path/ to /flake", lambda: "hostname") == m.Flake( Path("/path/ to /flake"), "nixosConfigurations.hostname" Path("/path/ to /flake"), 'nixosConfigurations."hostname"' ) assert m.Flake.parse("/path/to/flake", lambda: "hostname") == m.Flake( Path("/path/to/flake"), "nixosConfigurations.hostname" Path("/path/to/flake"), 'nixosConfigurations."hostname"' ) # change directory to tmpdir with monkeypatch.context() as patch_context: patch_context.chdir(tmpdir) assert m.Flake.parse(".#attr") == m.Flake(Path("."), "nixosConfigurations.attr") assert m.Flake.parse("#attr") == m.Flake(Path("."), "nixosConfigurations.attr") assert m.Flake.parse(".") == m.Flake(Path("."), "nixosConfigurations.default") assert m.Flake.parse(".#attr") == m.Flake( Path("."), 'nixosConfigurations."attr"' ) assert m.Flake.parse("#attr") == m.Flake( Path("."), 'nixosConfigurations."attr"' ) assert m.Flake.parse(".") == m.Flake(Path("."), 'nixosConfigurations."default"') assert m.Flake.parse("path:/to/flake#attr") == m.Flake( "path:/to/flake", "nixosConfigurations.attr" "path:/to/flake", 'nixosConfigurations."attr"' ) assert m.Flake.parse("github:user/repo/branch") == m.Flake( "github:user/repo/branch", "nixosConfigurations.default" "github:user/repo/branch", 'nixosConfigurations."default"' ) git_root = tmpdir / "git_root" git_root.mkdir() (git_root / ".git").mkdir() assert m.Flake.parse(str(git_root)) == m.Flake( f"git+file://{git_root}", "nixosConfigurations.default" f"git+file://{git_root}", 'nixosConfigurations."default"' ) work_tree = tmpdir / "work_tree" work_tree.mkdir() (work_tree / ".git").write_text("gitdir: /path/to/git", "utf-8") assert m.Flake.parse(str(work_tree)) == m.Flake( "git+file:///path/to/git", "nixosConfigurations.default" "git+file:///path/to/git", 'nixosConfigurations."default"' ) Loading @@ -84,7 +88,7 @@ def test_flake_from_arg( # Flake string assert m.Flake.from_arg("/path/to/flake#attr", None) == m.Flake( Path("/path/to/flake"), "nixosConfigurations.attr" Path("/path/to/flake"), 'nixosConfigurations."attr"' ) # False Loading @@ -94,7 +98,7 @@ def test_flake_from_arg( with monkeypatch.context() as patch_context: patch_context.chdir(tmpdir) assert m.Flake.from_arg(True, None) == m.Flake( Path("."), "nixosConfigurations.hostname" Path("."), 'nixosConfigurations."hostname"' ) # None when we do not have /etc/nixos/flake.nix Loading Loading @@ -124,7 +128,7 @@ def test_flake_from_arg( ), ): assert m.Flake.from_arg(None, None) == m.Flake( "git+file:///etc/nixos", "nixosConfigurations.hostname" "git+file:///etc/nixos", 'nixosConfigurations."hostname"' ) with ( Loading @@ -145,7 +149,7 @@ def test_flake_from_arg( ), ): assert m.Flake.from_arg(None, None) == m.Flake( Path("/path/to"), "nixosConfigurations.hostname" Path("/path/to"), 'nixosConfigurations."hostname"' ) with ( Loading @@ -156,7 +160,7 @@ def test_flake_from_arg( ), ): assert m.Flake.from_arg("/path/to", m.Remote("user@host", [], None)) == m.Flake( Path("/path/to"), "nixosConfigurations.remote-hostname" Path("/path/to"), 'nixosConfigurations."remote-hostname"' ) Loading pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py +3 −3 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ def test_build_flake(mock_run: Mock, monkeypatch: MonkeyPatch, tmpdir: Path) -> "nix-command flakes", "build", "--print-out-paths", ".#nixosConfigurations.hostname.config.system.build.toplevel", '.#nixosConfigurations."hostname".config.system.build.toplevel', "--no-link", "--nix-flag", "foo", Loading Loading @@ -194,7 +194,7 @@ def test_build_remote_flake( "nix-command flakes", "eval", "--raw", ".#nixosConfigurations.hostname.config.system.build.toplevel.drvPath", '.#nixosConfigurations."hostname".config.system.build.toplevel.drvPath', "--flake", ], stdout=PIPE, Loading Loading @@ -304,7 +304,7 @@ def test_edit(mock_run: Mock, monkeypatch: MonkeyPatch, tmpdir: Path) -> None: "edit", "--commit-lock-file", "--", f"{tmpdir}#nixosConfigurations.attr", f'{tmpdir}#nixosConfigurations."attr"', ], check=False, ) Loading Loading
pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/models.py +1 −1 Original line number Diff line number Diff line Loading @@ -122,7 +122,7 @@ class Flake: m = cls._re.match(flake_str) assert m is not None, f"got no matches for {flake_str}" attr = m.group("attr") nixos_attr = f"nixosConfigurations.{attr or hostname_fn() or 'default'}" nixos_attr = f'nixosConfigurations."{attr or hostname_fn() or "default"}"' path_str = m.group("path") if ":" in path_str: return cls(path_str, nixos_attr) Loading
pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_main.py +7 −7 Original line number Diff line number Diff line Loading @@ -385,7 +385,7 @@ def test_execute_nix_build_image_flake(mock_run: Mock, tmp_path: Path) -> None: "nix", "eval", "--json", "/path/to/config#nixosConfigurations.hostname.config.system.build.images", '/path/to/config#nixosConfigurations."hostname".config.system.build.images', "--apply", "builtins.attrNames", ], Loading @@ -400,7 +400,7 @@ def test_execute_nix_build_image_flake(mock_run: Mock, tmp_path: Path) -> None: "nix-command flakes", "build", "--print-out-paths", "/path/to/config#nixosConfigurations.hostname.config.system.build.images.azure", '/path/to/config#nixosConfigurations."hostname".config.system.build.images.azure', ], check=True, stdout=PIPE, Loading @@ -411,7 +411,7 @@ def test_execute_nix_build_image_flake(mock_run: Mock, tmp_path: Path) -> None: "nix", "eval", "--json", "/path/to/config#nixosConfigurations.hostname.config.system.build.images.azure.passthru.filePath", '/path/to/config#nixosConfigurations."hostname".config.system.build.images.azure.passthru.filePath', ], check=True, stdout=PIPE, Loading Loading @@ -462,7 +462,7 @@ def test_execute_nix_switch_flake(mock_run: Mock, tmp_path: Path) -> None: "nix-command flakes", "build", "--print-out-paths", "/path/to/config#nixosConfigurations.hostname.config.system.build.toplevel", '/path/to/config#nixosConfigurations."hostname".config.system.build.toplevel', "-v", "--option", "narinfo-cache-negative-ttl", Loading Loading @@ -756,7 +756,7 @@ def test_execute_nix_switch_flake_target_host( "nix-command flakes", "build", "--print-out-paths", "/path/to/config#nixosConfigurations.hostname.config.system.build.toplevel", '/path/to/config#nixosConfigurations."hostname".config.system.build.toplevel', "--no-link", ], check=True, Loading Loading @@ -860,7 +860,7 @@ def test_execute_nix_switch_flake_build_host( "nix-command flakes", "eval", "--raw", "/path/to/config#nixosConfigurations.hostname.config.system.build.toplevel.drvPath", '/path/to/config#nixosConfigurations."hostname".config.system.build.toplevel.drvPath', ], check=True, stdout=PIPE, Loading Loading @@ -1063,7 +1063,7 @@ def test_execute_test_flake(mock_run: Mock, tmp_path: Path) -> None: "nix-command flakes", "build", "--print-out-paths", "github:user/repo#nixosConfigurations.hostname.config.system.build.toplevel", 'github:user/repo#nixosConfigurations."hostname".config.system.build.toplevel', ], check=True, stdout=PIPE, Loading
pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_models.py +19 −15 Original line number Diff line number Diff line Loading @@ -32,38 +32,42 @@ def test_build_attr_to_attr() -> None: def test_flake_parse(tmpdir: Path, monkeypatch: MonkeyPatch) -> None: assert m.Flake.parse("/path/to/flake#attr") == m.Flake( Path("/path/to/flake"), "nixosConfigurations.attr" Path("/path/to/flake"), 'nixosConfigurations."attr"' ) assert m.Flake.parse("/path/ to /flake", lambda: "hostname") == m.Flake( Path("/path/ to /flake"), "nixosConfigurations.hostname" Path("/path/ to /flake"), 'nixosConfigurations."hostname"' ) assert m.Flake.parse("/path/to/flake", lambda: "hostname") == m.Flake( Path("/path/to/flake"), "nixosConfigurations.hostname" Path("/path/to/flake"), 'nixosConfigurations."hostname"' ) # change directory to tmpdir with monkeypatch.context() as patch_context: patch_context.chdir(tmpdir) assert m.Flake.parse(".#attr") == m.Flake(Path("."), "nixosConfigurations.attr") assert m.Flake.parse("#attr") == m.Flake(Path("."), "nixosConfigurations.attr") assert m.Flake.parse(".") == m.Flake(Path("."), "nixosConfigurations.default") assert m.Flake.parse(".#attr") == m.Flake( Path("."), 'nixosConfigurations."attr"' ) assert m.Flake.parse("#attr") == m.Flake( Path("."), 'nixosConfigurations."attr"' ) assert m.Flake.parse(".") == m.Flake(Path("."), 'nixosConfigurations."default"') assert m.Flake.parse("path:/to/flake#attr") == m.Flake( "path:/to/flake", "nixosConfigurations.attr" "path:/to/flake", 'nixosConfigurations."attr"' ) assert m.Flake.parse("github:user/repo/branch") == m.Flake( "github:user/repo/branch", "nixosConfigurations.default" "github:user/repo/branch", 'nixosConfigurations."default"' ) git_root = tmpdir / "git_root" git_root.mkdir() (git_root / ".git").mkdir() assert m.Flake.parse(str(git_root)) == m.Flake( f"git+file://{git_root}", "nixosConfigurations.default" f"git+file://{git_root}", 'nixosConfigurations."default"' ) work_tree = tmpdir / "work_tree" work_tree.mkdir() (work_tree / ".git").write_text("gitdir: /path/to/git", "utf-8") assert m.Flake.parse(str(work_tree)) == m.Flake( "git+file:///path/to/git", "nixosConfigurations.default" "git+file:///path/to/git", 'nixosConfigurations."default"' ) Loading @@ -84,7 +88,7 @@ def test_flake_from_arg( # Flake string assert m.Flake.from_arg("/path/to/flake#attr", None) == m.Flake( Path("/path/to/flake"), "nixosConfigurations.attr" Path("/path/to/flake"), 'nixosConfigurations."attr"' ) # False Loading @@ -94,7 +98,7 @@ def test_flake_from_arg( with monkeypatch.context() as patch_context: patch_context.chdir(tmpdir) assert m.Flake.from_arg(True, None) == m.Flake( Path("."), "nixosConfigurations.hostname" Path("."), 'nixosConfigurations."hostname"' ) # None when we do not have /etc/nixos/flake.nix Loading Loading @@ -124,7 +128,7 @@ def test_flake_from_arg( ), ): assert m.Flake.from_arg(None, None) == m.Flake( "git+file:///etc/nixos", "nixosConfigurations.hostname" "git+file:///etc/nixos", 'nixosConfigurations."hostname"' ) with ( Loading @@ -145,7 +149,7 @@ def test_flake_from_arg( ), ): assert m.Flake.from_arg(None, None) == m.Flake( Path("/path/to"), "nixosConfigurations.hostname" Path("/path/to"), 'nixosConfigurations."hostname"' ) with ( Loading @@ -156,7 +160,7 @@ def test_flake_from_arg( ), ): assert m.Flake.from_arg("/path/to", m.Remote("user@host", [], None)) == m.Flake( Path("/path/to"), "nixosConfigurations.remote-hostname" Path("/path/to"), 'nixosConfigurations."remote-hostname"' ) Loading
pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py +3 −3 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ def test_build_flake(mock_run: Mock, monkeypatch: MonkeyPatch, tmpdir: Path) -> "nix-command flakes", "build", "--print-out-paths", ".#nixosConfigurations.hostname.config.system.build.toplevel", '.#nixosConfigurations."hostname".config.system.build.toplevel', "--no-link", "--nix-flag", "foo", Loading Loading @@ -194,7 +194,7 @@ def test_build_remote_flake( "nix-command flakes", "eval", "--raw", ".#nixosConfigurations.hostname.config.system.build.toplevel.drvPath", '.#nixosConfigurations."hostname".config.system.build.toplevel.drvPath', "--flake", ], stdout=PIPE, Loading Loading @@ -304,7 +304,7 @@ def test_edit(mock_run: Mock, monkeypatch: MonkeyPatch, tmpdir: Path) -> None: "edit", "--commit-lock-file", "--", f"{tmpdir}#nixosConfigurations.attr", f'{tmpdir}#nixosConfigurations."attr"', ], check=False, ) Loading