From a6efbc9ea1879c212092ff2609ff16f8339867de Mon Sep 17 00:00:00 2001 From: cswimr Date: Tue, 14 Jan 2025 12:18:47 -0600 Subject: [PATCH] only run `nixos-generate-config` in `upd` when a flag is given this prevents the system from breaking on reboot when a docker container or other storage mount is provided in the hardware configuration but is not accessible anymore when booting --- config/xonsh/aliases.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/config/xonsh/aliases.py b/config/xonsh/aliases.py index f1b7409..1c41299 100644 --- a/config/xonsh/aliases.py +++ b/config/xonsh/aliases.py @@ -55,14 +55,16 @@ def _upd(args: list): "Visual Studio Code user settings": ".config/Code/User/settings.json.bak", "fontconfig": ".config/fontconfig/conf.d/10-hm-fonts.conf.bak" } - print(f"{c.BLUE}Updating {c.YELLOW}NixOS{c.BLUE} hardware configuration file for {c.YELLOW}{gethostname()}{c.BLUE}{c.END}") - run(["sudo", "nixos-generate-config", "--dir", ".",], cwd=path / "hosts") - print(f"{c.BLUE}Deleting redundant {c.YELLOW}NixOS{c.BLUE} configuration file{c.END}") - run(["sudo", "rm", "configuration.nix"], cwd=path / "hosts") - print(f"{c.BLUE}Moving {c.YELLOW}NixOS{c.BLUE} hardware configuration file{c.END}") - run(["sudo", "mv", "hardware-configuration.nix", "{hostname}.nix".format(hostname=gethostname())], cwd=path / "hosts") - print(f"{c.BLUE}Adding {c.YELLOW}NixOS{c.BLUE} hardware configuration file for {c.YELLOW}{gethostname()}{c.BLUE} to git{c.END}") - run(["git", "add", "hosts/{hostname}.nix".format(hostname=gethostname())], cwd=path) + if "--rewrite-hardware-configuration" in args: + args.remove("--rewrite-hardware-configuration") + print(f"{c.BLUE}Updating {c.YELLOW}NixOS{c.BLUE} hardware configuration file for {c.YELLOW}{gethostname()}{c.BLUE}{c.END}") + run(["sudo", "nixos-generate-config", "--dir", ".",], cwd=path / "hosts") + print(f"{c.BLUE}Deleting redundant {c.YELLOW}NixOS{c.BLUE} configuration file{c.END}") + run(["sudo", "rm", "configuration.nix"], cwd=path / "hosts") + print(f"{c.BLUE}Moving {c.YELLOW}NixOS{c.BLUE} hardware configuration file{c.END}") + run(["sudo", "mv", "hardware-configuration.nix", "{hostname}.nix".format(hostname=gethostname())], cwd=path / "hosts") + print(f"{c.BLUE}Adding {c.YELLOW}NixOS{c.BLUE} hardware configuration file for {c.YELLOW}{gethostname()}{c.BLUE} to git{c.END}") + run(["git", "add", "hosts/{hostname}.nix".format(hostname=gethostname())], cwd=path) for file_description, file_path in files_to_delete.items(): print(f"{c.BLUE}Deleting {c.YELLOW}{file_description}{c.BLUE} backup file{c.END}") run(["rm", file_path], exit_on_error=False, cwd="/home/cswimr")