diff --git a/checks/installation/flake-module.nix b/checks/installation/flake-module.nix index a189b12ce..f1284c94f 100644 --- a/checks/installation/flake-module.nix +++ b/checks/installation/flake-module.nix @@ -232,6 +232,7 @@ "-i", ssh_conn.ssh_key, "--option", "store", os.environ['CLAN_TEST_STORE'], "--update-hardware-config", "nixos-facter", + "--no-persist-state", ] subprocess.run(clan_cmd, check=True) @@ -275,7 +276,7 @@ "${self.checks.x86_64-linux.clan-core-for-checks}", "${closureInfo}" ) - + # Set up SSH connection ssh_conn = setup_ssh_connection( target, diff --git a/pkgs/clan-cli/clan_cli/machines/install.py b/pkgs/clan-cli/clan_cli/machines/install.py index fade32d7a..4f5e4c7a1 100644 --- a/pkgs/clan-cli/clan_cli/machines/install.py +++ b/pkgs/clan-cli/clan_cli/machines/install.py @@ -91,6 +91,7 @@ def install_command(args: argparse.Namespace) -> None: no_reboot=args.no_reboot, build_on=args.build_on if args.build_on is not None else None, update_hardware_config=HardwareConfig(args.update_hardware_config), + persist_state=not args.no_persist_state, ), target_host=remote, ) @@ -137,6 +138,12 @@ def register_install_parser(parser: argparse.ArgumentParser) -> None: help="update the hardware configuration", choices=[x.value for x in HardwareConfig], ) + parser.add_argument( + "--no-persist-state", + action="store_true", + help="Disable persisting the result of the installation after it is done", + default=False, + ) parser.add_argument( "--phases", diff --git a/pkgs/clan-cli/clan_lib/machines/install.py b/pkgs/clan-cli/clan_lib/machines/install.py index 066399d67..bbfd0ef19 100644 --- a/pkgs/clan-cli/clan_lib/machines/install.py +++ b/pkgs/clan-cli/clan_lib/machines/install.py @@ -56,6 +56,7 @@ class InstallOptions: phases: str | None = None build_on: BuildOn | None = None update_hardware_config: HardwareConfig = HardwareConfig.NONE + persist_state: bool = True @API.register @@ -227,16 +228,16 @@ def run_machine_install(opts: InstallOptions, target_host: Remote) -> None: RunOpts(log=Log.BOTH, prefix=machine.name, needs_user_terminal=True), ) - inventory_store = InventoryStore(machine.flake) - inventory = inventory_store.read() + if opts.persist_state: + inventory_store = InventoryStore(machine.flake) + inventory = inventory_store.read() - set_value_by_path( - inventory, - f"machine.{machine.name}.installedAt", - # Cut of the milliseconds - int(time()), - ) - - inventory_store.write( - inventory, f"Installed {machine.name} at {target_host.target}" - ) + set_value_by_path( + inventory, + f"machine.{machine.name}.installedAt", + # Cut of the milliseconds + int(time()), + ) + inventory_store.write( + inventory, f"Installed {machine.name} at {target_host.target}" + )