nix/update.sh

27 lines
438 B
Bash

#!/usr/bin/env bash
set -e
pushd ~/nixos/
alejandra . &>/dev/null \
|| (alejandra . ; echo "formatting failed!" && exit 1)
git add .
echo "Rebuilding"
sudo nixos-rebuild switch --upgrade --flake .
current=$(nixos-rebuild list-generations | grep current)
if git diff --quiet '*.nix'; then
popd
notify-send -e "Nixos updated with no config changes" --icon=software-update-avaiable
fi
git commit -am "$current"
git push
popd