nixos-rebuild-ng: fix eval flags for nix.build_remote_flake

This commit is contained in:
Thiago Kenji Okada
2024-12-27 23:21:27 +00:00
parent a376797b7b
commit f25fb0d388
4 changed files with 24 additions and 24 deletions
@@ -43,19 +43,19 @@ def get_parser() -> tuple[argparse.ArgumentParser, dict[str, argparse.ArgumentPa
common_build_flags.add_argument("--print-build-logs", "-L", action="store_true")
common_build_flags.add_argument("--show-trace", action="store_true")
flake_build_flags = argparse.ArgumentParser(add_help=False)
flake_build_flags.add_argument("--accept-flake-config", action="store_true")
flake_build_flags.add_argument("--refresh", action="store_true")
flake_build_flags.add_argument("--impure", action="store_true")
flake_build_flags.add_argument("--offline", action="store_true")
flake_build_flags.add_argument("--no-net", action="store_true")
flake_build_flags.add_argument("--recreate-lock-file", action="store_true")
flake_build_flags.add_argument("--no-update-lock-file", action="store_true")
flake_build_flags.add_argument("--no-write-lock-file", action="store_true")
flake_build_flags.add_argument("--no-registries", action="store_true")
flake_build_flags.add_argument("--commit-lock-file", action="store_true")
flake_build_flags.add_argument("--update-input")
flake_build_flags.add_argument("--override-input", nargs=2)
flake_common_flags = argparse.ArgumentParser(add_help=False)
flake_common_flags.add_argument("--accept-flake-config", action="store_true")
flake_common_flags.add_argument("--refresh", action="store_true")
flake_common_flags.add_argument("--impure", action="store_true")
flake_common_flags.add_argument("--offline", action="store_true")
flake_common_flags.add_argument("--no-net", action="store_true")
flake_common_flags.add_argument("--recreate-lock-file", action="store_true")
flake_common_flags.add_argument("--no-update-lock-file", action="store_true")
flake_common_flags.add_argument("--no-write-lock-file", action="store_true")
flake_common_flags.add_argument("--no-registries", action="store_true")
flake_common_flags.add_argument("--commit-lock-file", action="store_true")
flake_common_flags.add_argument("--update-input")
flake_common_flags.add_argument("--override-input", nargs=2)
classic_build_flags = argparse.ArgumentParser(add_help=False)
classic_build_flags.add_argument("--no-build-output", "-Q", action="store_true")
@@ -74,7 +74,7 @@ def get_parser() -> tuple[argparse.ArgumentParser, dict[str, argparse.ArgumentPa
sub_parsers = {
"common_flags": common_flags,
"common_build_flags": common_build_flags,
"flake_build_flags": flake_build_flags,
"flake_common_flags": flake_common_flags,
"classic_build_flags": classic_build_flags,
"copy_flags": copy_flags,
}
@@ -327,7 +327,8 @@ def execute(argv: list[str]) -> None:
common_flags = vars(args_groups["common_flags"])
common_build_flags = common_flags | vars(args_groups["common_build_flags"])
build_flags = common_build_flags | vars(args_groups["classic_build_flags"])
flake_build_flags = common_build_flags | vars(args_groups["flake_build_flags"])
flake_common_flags = common_flags | vars(args_groups["flake_common_flags"])
flake_build_flags = common_build_flags | flake_common_flags
copy_flags = common_flags | vars(args_groups["copy_flags"])
if args.upgrade or args.upgrade_all:
@@ -410,9 +411,9 @@ def execute(argv: list[str]) -> None:
attr,
flake,
build_host,
eval_flags=flake_common_flags,
flake_build_flags=flake_build_flags,
copy_flags=copy_flags,
build_flags=build_flags,
)
case (_, False, None, Flake(_)):
path_to_config = nix.build_flake(
@@ -128,9 +128,9 @@ def build_remote_flake(
attr: str,
flake: Flake,
build_host: Remote,
flake_build_flags: Args | None = None,
eval_flags: Args | None = None,
copy_flags: Args | None = None,
build_flags: Args | None = None,
flake_build_flags: Args | None = None,
) -> Path:
r = run_wrapper(
[
@@ -139,7 +139,7 @@ def build_remote_flake(
"eval",
"--raw",
flake.to_attr(attr, "drvPath"),
*dict_to_flags(flake_build_flags),
*dict_to_flags(eval_flags),
],
stdout=PIPE,
)
@@ -152,7 +152,7 @@ def build_remote_flake(
"build",
f"{drv}^*",
"--print-out-paths",
*dict_to_flags(build_flags),
*dict_to_flags(flake_build_flags),
],
remote=build_host,
stdout=PIPE,
@@ -349,7 +349,6 @@ def test_execute_nix_switch_flake_build_host(
"eval",
"--raw",
"/path/to/config#nixosConfigurations.hostname.config.system.build.toplevel.drvPath",
"--no-link",
],
check=True,
stdout=PIPE,
@@ -372,7 +371,7 @@ def test_execute_nix_switch_flake_build_host(
"build",
f"'{config_path}^*'",
"--print-out-paths",
"--no-out-link",
"--no-link",
],
check=True,
stdout=PIPE,
@@ -174,9 +174,9 @@ def test_build_remote_flake(mock_run: Any, monkeypatch: Any) -> None:
"config.system.build.toplevel",
flake,
build_host,
flake_build_flags={"flake": True},
eval_flags={"flake": True},
copy_flags={"copy": True},
build_flags={"build": True},
flake_build_flags={"build": True},
) == Path("/path/to/file")
mock_run.assert_has_calls(
[