lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

nixos-rebuild-ng: quote hostname (#412341)

authored by

Thiago Kenji Okada and committed by
GitHub
94d09d10 63ead2d7

+30 -26
+1 -1
pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/models.py
··· 122 122 m = cls._re.match(flake_str) 123 123 assert m is not None, f"got no matches for {flake_str}" 124 124 attr = m.group("attr") 125 - nixos_attr = f"nixosConfigurations.{attr or hostname_fn() or 'default'}" 125 + nixos_attr = f'nixosConfigurations."{attr or hostname_fn() or "default"}"' 126 126 path_str = m.group("path") 127 127 if ":" in path_str: 128 128 return cls(path_str, nixos_attr)
+7 -7
pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_main.py
··· 385 385 "nix", 386 386 "eval", 387 387 "--json", 388 - "/path/to/config#nixosConfigurations.hostname.config.system.build.images", 388 + '/path/to/config#nixosConfigurations."hostname".config.system.build.images', 389 389 "--apply", 390 390 "builtins.attrNames", 391 391 ], ··· 400 400 "nix-command flakes", 401 401 "build", 402 402 "--print-out-paths", 403 - "/path/to/config#nixosConfigurations.hostname.config.system.build.images.azure", 403 + '/path/to/config#nixosConfigurations."hostname".config.system.build.images.azure', 404 404 ], 405 405 check=True, 406 406 stdout=PIPE, ··· 411 411 "nix", 412 412 "eval", 413 413 "--json", 414 - "/path/to/config#nixosConfigurations.hostname.config.system.build.images.azure.passthru.filePath", 414 + '/path/to/config#nixosConfigurations."hostname".config.system.build.images.azure.passthru.filePath', 415 415 ], 416 416 check=True, 417 417 stdout=PIPE, ··· 462 462 "nix-command flakes", 463 463 "build", 464 464 "--print-out-paths", 465 - "/path/to/config#nixosConfigurations.hostname.config.system.build.toplevel", 465 + '/path/to/config#nixosConfigurations."hostname".config.system.build.toplevel', 466 466 "-v", 467 467 "--option", 468 468 "narinfo-cache-negative-ttl", ··· 756 756 "nix-command flakes", 757 757 "build", 758 758 "--print-out-paths", 759 - "/path/to/config#nixosConfigurations.hostname.config.system.build.toplevel", 759 + '/path/to/config#nixosConfigurations."hostname".config.system.build.toplevel', 760 760 "--no-link", 761 761 ], 762 762 check=True, ··· 860 860 "nix-command flakes", 861 861 "eval", 862 862 "--raw", 863 - "/path/to/config#nixosConfigurations.hostname.config.system.build.toplevel.drvPath", 863 + '/path/to/config#nixosConfigurations."hostname".config.system.build.toplevel.drvPath', 864 864 ], 865 865 check=True, 866 866 stdout=PIPE, ··· 1063 1063 "nix-command flakes", 1064 1064 "build", 1065 1065 "--print-out-paths", 1066 - "github:user/repo#nixosConfigurations.hostname.config.system.build.toplevel", 1066 + 'github:user/repo#nixosConfigurations."hostname".config.system.build.toplevel', 1067 1067 ], 1068 1068 check=True, 1069 1069 stdout=PIPE,
+19 -15
pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_models.py
··· 32 32 33 33 def test_flake_parse(tmpdir: Path, monkeypatch: MonkeyPatch) -> None: 34 34 assert m.Flake.parse("/path/to/flake#attr") == m.Flake( 35 - Path("/path/to/flake"), "nixosConfigurations.attr" 35 + Path("/path/to/flake"), 'nixosConfigurations."attr"' 36 36 ) 37 37 assert m.Flake.parse("/path/ to /flake", lambda: "hostname") == m.Flake( 38 - Path("/path/ to /flake"), "nixosConfigurations.hostname" 38 + Path("/path/ to /flake"), 'nixosConfigurations."hostname"' 39 39 ) 40 40 assert m.Flake.parse("/path/to/flake", lambda: "hostname") == m.Flake( 41 - Path("/path/to/flake"), "nixosConfigurations.hostname" 41 + Path("/path/to/flake"), 'nixosConfigurations."hostname"' 42 42 ) 43 43 # change directory to tmpdir 44 44 with monkeypatch.context() as patch_context: 45 45 patch_context.chdir(tmpdir) 46 - assert m.Flake.parse(".#attr") == m.Flake(Path("."), "nixosConfigurations.attr") 47 - assert m.Flake.parse("#attr") == m.Flake(Path("."), "nixosConfigurations.attr") 48 - assert m.Flake.parse(".") == m.Flake(Path("."), "nixosConfigurations.default") 46 + assert m.Flake.parse(".#attr") == m.Flake( 47 + Path("."), 'nixosConfigurations."attr"' 48 + ) 49 + assert m.Flake.parse("#attr") == m.Flake( 50 + Path("."), 'nixosConfigurations."attr"' 51 + ) 52 + assert m.Flake.parse(".") == m.Flake(Path("."), 'nixosConfigurations."default"') 49 53 assert m.Flake.parse("path:/to/flake#attr") == m.Flake( 50 - "path:/to/flake", "nixosConfigurations.attr" 54 + "path:/to/flake", 'nixosConfigurations."attr"' 51 55 ) 52 56 assert m.Flake.parse("github:user/repo/branch") == m.Flake( 53 - "github:user/repo/branch", "nixosConfigurations.default" 57 + "github:user/repo/branch", 'nixosConfigurations."default"' 54 58 ) 55 59 git_root = tmpdir / "git_root" 56 60 git_root.mkdir() 57 61 (git_root / ".git").mkdir() 58 62 assert m.Flake.parse(str(git_root)) == m.Flake( 59 - f"git+file://{git_root}", "nixosConfigurations.default" 63 + f"git+file://{git_root}", 'nixosConfigurations."default"' 60 64 ) 61 65 62 66 work_tree = tmpdir / "work_tree" 63 67 work_tree.mkdir() 64 68 (work_tree / ".git").write_text("gitdir: /path/to/git", "utf-8") 65 69 assert m.Flake.parse(str(work_tree)) == m.Flake( 66 - "git+file:///path/to/git", "nixosConfigurations.default" 70 + "git+file:///path/to/git", 'nixosConfigurations."default"' 67 71 ) 68 72 69 73 ··· 84 88 85 89 # Flake string 86 90 assert m.Flake.from_arg("/path/to/flake#attr", None) == m.Flake( 87 - Path("/path/to/flake"), "nixosConfigurations.attr" 91 + Path("/path/to/flake"), 'nixosConfigurations."attr"' 88 92 ) 89 93 90 94 # False ··· 94 98 with monkeypatch.context() as patch_context: 95 99 patch_context.chdir(tmpdir) 96 100 assert m.Flake.from_arg(True, None) == m.Flake( 97 - Path("."), "nixosConfigurations.hostname" 101 + Path("."), 'nixosConfigurations."hostname"' 98 102 ) 99 103 100 104 # None when we do not have /etc/nixos/flake.nix ··· 124 128 ), 125 129 ): 126 130 assert m.Flake.from_arg(None, None) == m.Flake( 127 - "git+file:///etc/nixos", "nixosConfigurations.hostname" 131 + "git+file:///etc/nixos", 'nixosConfigurations."hostname"' 128 132 ) 129 133 130 134 with ( ··· 145 149 ), 146 150 ): 147 151 assert m.Flake.from_arg(None, None) == m.Flake( 148 - Path("/path/to"), "nixosConfigurations.hostname" 152 + Path("/path/to"), 'nixosConfigurations."hostname"' 149 153 ) 150 154 151 155 with ( ··· 156 160 ), 157 161 ): 158 162 assert m.Flake.from_arg("/path/to", m.Remote("user@host", [], None)) == m.Flake( 159 - Path("/path/to"), "nixosConfigurations.remote-hostname" 163 + Path("/path/to"), 'nixosConfigurations."remote-hostname"' 160 164 ) 161 165 162 166
+3 -3
pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py
··· 68 68 "nix-command flakes", 69 69 "build", 70 70 "--print-out-paths", 71 - ".#nixosConfigurations.hostname.config.system.build.toplevel", 71 + '.#nixosConfigurations."hostname".config.system.build.toplevel', 72 72 "--no-link", 73 73 "--nix-flag", 74 74 "foo", ··· 194 194 "nix-command flakes", 195 195 "eval", 196 196 "--raw", 197 - ".#nixosConfigurations.hostname.config.system.build.toplevel.drvPath", 197 + '.#nixosConfigurations."hostname".config.system.build.toplevel.drvPath', 198 198 "--flake", 199 199 ], 200 200 stdout=PIPE, ··· 304 304 "edit", 305 305 "--commit-lock-file", 306 306 "--", 307 - f"{tmpdir}#nixosConfigurations.attr", 307 + f'{tmpdir}#nixosConfigurations."attr"', 308 308 ], 309 309 check=False, 310 310 )