diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bf0824e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.log \ No newline at end of file diff --git a/hosts/comfy-station/configuration.nix b/hosts/comfy-station/configuration.nix index 20da595..309f44f 100644 --- a/hosts/comfy-station/configuration.nix +++ b/hosts/comfy-station/configuration.nix @@ -11,6 +11,7 @@ # Include the results of the hardware scan. ./hardware-configuration.nix inputs.home-manager.nixosModules.home-manager + ../../modules/bin/nix-scripts.nix ../../modules/hardware/bluetooth.nix ../../modules/hardware/printing.nix ../../modules/hardware/sound.nix diff --git a/modules/bin/nix-scripts.nix b/modules/bin/nix-scripts.nix new file mode 100644 index 0000000..61672fd --- /dev/null +++ b/modules/bin/nix-scripts.nix @@ -0,0 +1,25 @@ +{ + config, + pkgs, + ... +}: let + rebuild = + pkgs.writeShellScriptBin ".nixos-rebuild" + '' + set -e + pushd ~/.nixos/ + ${pkgs.alejandra}/bin/alejandra . &>/dev/null + ${pkgs.git}/bin/git diff -U0 *.nix + echo "NixOS Rebuilding..." + sudo nixos-rebuild switch --flake . &>nixos-switch.log || ( + ${pkgs.coreutils-full}/bin/cat nixos-switch.log | ${pkgs.gnugrep}/bin/grep --color error && false) + gen=$(nixos-rebuild list-generations | ${pkgs.gnugrep}/bin/grep current) + ${pkgs.git}/bin/git commit -am "$gen" + popd + ''; +in { + environment.systemPackages = [ + pkgs.bash + rebuild + ]; +}