From 1a766a34471508d6ad3e1a26fee5b8de64733a71 Mon Sep 17 00:00:00 2001 From: Sacha Korban Date: Fri, 29 Aug 2025 18:27:03 +1000 Subject: [PATCH] fix: check if phases are non-default when running --- pkgs/clan-cli/clan_lib/machines/install.py | 42 +++++++++++----------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/pkgs/clan-cli/clan_lib/machines/install.py b/pkgs/clan-cli/clan_lib/machines/install.py index b67014bb0..b2b571e8a 100644 --- a/pkgs/clan-cli/clan_lib/machines/install.py +++ b/pkgs/clan-cli/clan_lib/machines/install.py @@ -214,26 +214,28 @@ def run_machine_install(opts: InstallOptions, target_host: Remote) -> None: cmd, ) - notify_install_step("nixos-anywhere") - run( - [*cmd, "--phases", "kexec"], - RunOpts(log=Log.BOTH, prefix=machine.name, needs_user_terminal=True), - ) - notify_install_step("formatting") - run( - [*cmd, "--phases", "disko"], - RunOpts(log=Log.BOTH, prefix=machine.name, needs_user_terminal=True), - ) - notify_install_step("installing") - run( - [*cmd, "--phases", "install"], - RunOpts(log=Log.BOTH, prefix=machine.name, needs_user_terminal=True), - ) - notify_install_step("rebooting") - run( - [*cmd, "--phases", "reboot"], - RunOpts(log=Log.BOTH, prefix=machine.name, needs_user_terminal=True), - ) + install_steps = { + "kexec": "nixos-anywhere", + "disko": "formatting", + "install": "installing", + "reboot": "rebooting", + } + + def run_phase(phase: str) -> None: + notification = install_steps.get(phase, "nixos-anywhere") + notify_install_step(notification) + run( + [*cmd, "--phases", phase], + RunOpts(log=Log.BOTH, prefix=machine.name, needs_user_terminal=True), + ) + + if opts.phases: + phases = [phase.strip() for phase in opts.phases.split(",")] + for phase in phases: + run_phase(phase) + else: + for phase in ["kexec", "disko", "install", "reboot"]: + run_phase(phase) if opts.persist_state: inventory_store = InventoryStore(machine.flake)