Make rebuild a bit cleaner with sudo

This commit is contained in:
Lillian Violet 2024-03-01 16:27:48 +01:00
parent ace01f3391
commit f8cf7b589b

View file

@ -11,17 +11,20 @@ writeShellApplication
text = '' text = ''
# A rebuild script for NixOS # A rebuild script for NixOS
set -e rebuild_function (){
pushd /tmp > /dev/null set -e
rm -rf ./rebuild pushd /tmp > /dev/null
systemd-inhibit --what=idle git clone https://git.lillianviolet.dev/Lillian-Violet/NixOS-Config.git ./rebuild rm -rf ./rebuild
pushd ./rebuild > /dev/null git clone https://git.lillianviolet.dev/Lillian-Violet/NixOS-Config.git ./rebuild
echo "NixOS Rebuilding..." pushd ./rebuild > /dev/null
systemd-inhibit --what=idle sudo nixos-rebuild switch --flake .# echo "NixOS Rebuilding..."
popd > /dev/null sudo nixos-rebuild switch --flake .#
echo "Cleaning up repository in '/tmp/rebuild'..." popd > /dev/null
systemd-inhibit --what=idle rm -rf ./rebuild echo "Cleaning up repository in '/tmp/rebuild'..."
popd > /dev/null rm -rf ./rebuild
echo "NixOS Rebuilt OK!" popd > /dev/null
echo "NixOS Rebuilt OK!"
}
sudo systemd-inhibit --who="NixOS Updater" --why="Updating system configuration" sudo -u lillian rebuild_function
''; '';
} }