From 23e99a1c40c95b8ef68eac1f18e9b82cea298def Mon Sep 17 00:00:00 2001 From: Lillian-Violet Date: Sat, 2 Mar 2024 17:37:35 +0100 Subject: [PATCH] Simplified rebuild and made it only need one password entry --- nixos/shared/packages/default.nix | 1 + pkgs/default.nix | 1 + pkgs/rebuild-no-inhibit/default.nix | 28 ++++++++++++++++++++++++++++ pkgs/rebuild/default.nix | 17 +---------------- 4 files changed, 31 insertions(+), 16 deletions(-) create mode 100644 pkgs/rebuild-no-inhibit/default.nix diff --git a/nixos/shared/packages/default.nix b/nixos/shared/packages/default.nix index ff0ab96..e6c3641 100644 --- a/nixos/shared/packages/default.nix +++ b/nixos/shared/packages/default.nix @@ -18,6 +18,7 @@ environment.systemPackages = with pkgs; [ # Custom tools rebuild + rebuild-no-inhibit install-nix # System tools diff --git a/pkgs/default.nix b/pkgs/default.nix index fce0284..b1ee834 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -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 {}; } diff --git a/pkgs/rebuild-no-inhibit/default.nix b/pkgs/rebuild-no-inhibit/default.nix new file mode 100644 index 0000000..627bd05 --- /dev/null +++ b/pkgs/rebuild-no-inhibit/default.nix @@ -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!" + ''; +} diff --git a/pkgs/rebuild/default.nix b/pkgs/rebuild/default.nix index f4830e8..ee5131a 100644 --- a/pkgs/rebuild/default.nix +++ b/pkgs/rebuild/default.nix @@ -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" ''; }