1
0
Fork 0

General: update nixos upgrade helper script

This commit is contained in:
Aires 2024-09-28 13:18:26 -04:00
parent 21a8933a96
commit abd2b8dfdf
4 changed files with 16 additions and 28 deletions

View file

@ -1,8 +1,6 @@
#!/usr/bin/env bash
# Wrapper script for nixos-rebuild
#set -e
# Configuration parameters
operation="switch" # The nixos-rebuild operation to use
hostname=$(hostname) # The name of the host to build
@ -24,14 +22,15 @@ function usage() {
}
function run_operation {
echo "Full operation: nixos-rebuild $1 --flake $flakeDir#$hostname $( [ "$buildHost" != "" ] && echo "--build-host $buildHost" ) $remainingArgs"
echo "Full operation: nixos-rebuild $1 --flake $flakeDir#$hostname $( [ "$buildHost" != "" ] && echo "--build-host $buildHost" ) $remainingArgs --use-remote-sudo"
nixos-rebuild $operation --flake .#$hostname $remainingArgs --use-remote-sudo
# Only request super-user permission if we're switching
if [[ "$1" =~ ^(switch|boot|test)$ ]]; then
sudo nixos-rebuild $operation --flake .#$hostname $remainingArgs
else
nixos-rebuild $operation --flake .#$hostname $remainingArgs
fi
#if [[ "$1" =~ ^(switch|boot|test)$ ]]; then
# nixos-rebuild $operation --flake .#$hostname $remainingArgs --use-remote-sudo
#else
# nixos-rebuild $operation --flake .#$hostname $remainingArgs
#fi
}
# Argument processing logic shamelessly stolen from https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
@ -85,11 +84,6 @@ if [ $commit = true ]; then
git push
fi
# If this is a remote build, run the build as non-sudo first
if [[ "$buildHost" != "" ]]; then
run_operation "build"
fi
run_operation $operation
exit 0

View file

@ -17,6 +17,9 @@
zellij # Terminal multiplexer
];
# Install the nos helper script
aux.system.nixos-upgrade-script.enable = true;
nixpkgs.overlays = [
(final: _prev: {
# Allow packages from the unstable repo by using 'pkgs.unstable'

View file

@ -23,17 +23,7 @@ in
type = lib.types.str;
default = "monthly";
};
nixos-upgrade-script = {
enable = lib.mkEnableOption "Installs the nos (nixos-upgrade-script) helper script.";
configDir = lib.mkOption {
type = lib.types.str;
description = "Path to your NixOS configuration files.";
};
user = lib.mkOption {
type = lib.types.str;
description = "The user to run the upgrade script as.";
};
};
nixos-upgrade-script.enable = lib.mkEnableOption "Installs the nos (nixos-upgrade-script) helper script.";
};
};
config = {

View file

@ -90,6 +90,7 @@ in
theme = "gentoo";
};
shellAliases = {
nos = lib.mkIf config.aux.system.nixos-upgrade-script.enable "nixos-upgrade-script";
z = "zellij";
update = "upgrade";
upgrade = "nh os boot --update --ask";