#!/usr/bin/env bash set -e pushd ~/nixos/ git add . alejandra . &>/dev/null \ || (alejandra . ; echo "formatting failed!" && exit 1) echo "Updating flake" nix flake update echo "Checking for changes" git restore --staged . if git diff --quiet ; then echo "No changes, exiting." popd exit 0 fi git add . echo "New changes, Rebuilding..." sudo nixos-rebuild switch --upgrade --flake . current=$(nixos-rebuild list-generations | grep current) echo "Pushing new changes" git commit -am "$current" git push popd