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")