From fd41badbc601da93782d5005e734aa3c13b210fd Mon Sep 17 00:00:00 2001 From: Qubasa Date: Sun, 12 May 2024 23:38:37 +0200 Subject: [PATCH] Add --no-reboot flag to clan machine install --- docs/site/getting-started/configure.md | 4 ++-- pkgs/clan-cli/clan_cli/machines/install.py | 23 ++++++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/docs/site/getting-started/configure.md b/docs/site/getting-started/configure.md index 5e550f24..f0d2ea89 100644 --- a/docs/site/getting-started/configure.md +++ b/docs/site/getting-started/configure.md @@ -84,7 +84,7 @@ Adding or configuring a new machine requires two simple steps: === "**buildClan**" - ```nix title="clan-core.lib.buildClan" hl_lines="17 22" + ```nix title="clan-core.lib.buildClan" hl_lines="18 23" buildClan { # ... machines = { @@ -117,7 +117,7 @@ Adding or configuring a new machine requires two simple steps: === "**flakeParts**" - ```nix title="clan-core.flakeModules.default" hl_lines="17 22" + ```nix title="clan-core.flakeModules.default" hl_lines="18 23" clan = { # ... machines = { diff --git a/pkgs/clan-cli/clan_cli/machines/install.py b/pkgs/clan-cli/clan_cli/machines/install.py index 0415d0dd..fe9c962a 100644 --- a/pkgs/clan-cli/clan_cli/machines/install.py +++ b/pkgs/clan-cli/clan_cli/machines/install.py @@ -25,6 +25,7 @@ def install_nixos( kexec: str | None = None, debug: bool = False, password: str | None = None, + no_reboot: bool = False, ) -> None: secret_facts_module = importlib.import_module(machine.secret_facts_module) log.info(f"installing {machine.name}") @@ -53,11 +54,13 @@ def install_nixos( "nixos-anywhere", "--flake", f"{machine.flake}#{machine.name}", - "--no-reboot", "--extra-files", str(tmpdir), ] + if no_reboot: + cmd.append("--no-reboot") + if password: cmd += [ "--env-password", @@ -90,6 +93,7 @@ class InstallOptions: kexec: str | None confirm: bool debug: bool + no_reboot: bool json_ssh_deploy: dict[str, str] | None @@ -121,6 +125,7 @@ def install_command(args: argparse.Namespace) -> None: kexec=args.kexec, confirm=not args.yes, debug=args.debug, + no_reboot=args.no_reboot, json_ssh_deploy=json_ssh_deploy, ) machine = Machine(opts.machine, flake=opts.flake) @@ -131,7 +136,13 @@ def install_command(args: argparse.Namespace) -> None: if ask != "y": return - install_nixos(machine, kexec=opts.kexec, debug=opts.debug, password=password) + install_nixos( + machine, + kexec=opts.kexec, + debug=opts.debug, + password=password, + no_reboot=opts.no_reboot, + ) def find_reachable_host_from_deploy_json(deploy_json: dict[str, str]) -> str: @@ -161,15 +172,15 @@ def register_install_parser(parser: argparse.ArgumentParser) -> None: help="use another kexec tarball to bootstrap NixOS", ) parser.add_argument( - "--yes", + "--no-reboot", action="store_true", - help="do not ask for confirmation", + help="do not reboot after installation", default=False, ) parser.add_argument( - "--debug", + "--yes", action="store_true", - help="print debug information", + help="do not ask for confirmation", default=False, ) parser.add_argument(