sudo nvim /etc/nixos/configuration.nix sudo nixos-rebuild switch &>nixos-switch.log || ( cat nixos-switch.log | grep --color error && false) gen=$(nixos-rebuild list-generations | grep current) sudo cp /etc/nixos/configuration.nix ./nixos/configuration.nix git add . git commit -m "$gen" if grep -q "error" nixos-switch.log; then echo "There was an error in your Nix Config, please fix it before you push to git" else git push fi