Simplified rebuild and made it only need one password entry

This commit is contained in:
Lillian Violet 2024-03-02 17:37:35 +01:00
parent 42a5093c25
commit 23e99a1c40
4 changed files with 31 additions and 16 deletions

View file

@ -18,6 +18,7 @@
environment.systemPackages = with pkgs; [
# Custom tools
rebuild
rebuild-no-inhibit
install-nix
# System tools

View file

@ -4,6 +4,7 @@ pkgs: {
dvd = pkgs.callPackage ./dvd {};
dvt = pkgs.callPackage ./dvt {};
servo = pkgs.callPackage ./servo {};
rebuild-no-inhibit = pkgs.callPackage ./rebuild-no-inhibit {};
rebuild = pkgs.callPackage ./rebuild {};
install-nix = pkgs.callPackage ./install-nix {};
}

View file

@ -0,0 +1,28 @@
{
lib,
stdenv,
writeShellApplication,
}:
writeShellApplication
{
name = "rebuild-no-inhibit";
runtimeInputs = [];
text = ''
# A rebuild script for NixOS
set -e
pushd /tmp > /dev/null
rm -rf ./rebuild
git clone https://git.lillianviolet.dev/Lillian-Violet/NixOS-Config.git ./rebuild
pushd ./rebuild > /dev/null
echo "NixOS Rebuilding..."
sudo nixos-rebuild switch --flake .#
popd > /dev/null
echo "Cleaning up repository in '/tmp/rebuild'..."
rm -rf ./rebuild
popd > /dev/null
echo "NixOS Rebuilt OK!"
'';
}

View file

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