General: update nixos upgrade helper script
This commit is contained in:
parent
21a8933a96
commit
abd2b8dfdf
|
@ -1,8 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Wrapper script for nixos-rebuild
|
# Wrapper script for nixos-rebuild
|
||||||
|
|
||||||
#set -e
|
|
||||||
|
|
||||||
# Configuration parameters
|
# Configuration parameters
|
||||||
operation="switch" # The nixos-rebuild operation to use
|
operation="switch" # The nixos-rebuild operation to use
|
||||||
hostname=$(hostname) # The name of the host to build
|
hostname=$(hostname) # The name of the host to build
|
||||||
|
@ -24,14 +22,15 @@ function usage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_operation {
|
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
|
# Only request super-user permission if we're switching
|
||||||
if [[ "$1" =~ ^(switch|boot|test)$ ]]; then
|
#if [[ "$1" =~ ^(switch|boot|test)$ ]]; then
|
||||||
sudo nixos-rebuild $operation --flake .#$hostname $remainingArgs
|
# nixos-rebuild $operation --flake .#$hostname $remainingArgs --use-remote-sudo
|
||||||
else
|
#else
|
||||||
nixos-rebuild $operation --flake .#$hostname $remainingArgs
|
# nixos-rebuild $operation --flake .#$hostname $remainingArgs
|
||||||
fi
|
#fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Argument processing logic shamelessly stolen from https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
|
# 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
|
git push
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If this is a remote build, run the build as non-sudo first
|
|
||||||
if [[ "$buildHost" != "" ]]; then
|
|
||||||
run_operation "build"
|
|
||||||
fi
|
|
||||||
|
|
||||||
run_operation $operation
|
run_operation $operation
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
zellij # Terminal multiplexer
|
zellij # Terminal multiplexer
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Install the nos helper script
|
||||||
|
aux.system.nixos-upgrade-script.enable = true;
|
||||||
|
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [
|
||||||
(final: _prev: {
|
(final: _prev: {
|
||||||
# Allow packages from the unstable repo by using 'pkgs.unstable'
|
# Allow packages from the unstable repo by using 'pkgs.unstable'
|
||||||
|
|
|
@ -23,17 +23,7 @@ in
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "monthly";
|
default = "monthly";
|
||||||
};
|
};
|
||||||
nixos-upgrade-script = {
|
nixos-upgrade-script.enable = lib.mkEnableOption "Installs the nos (nixos-upgrade-script) helper 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.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
|
|
|
@ -90,6 +90,7 @@ in
|
||||||
theme = "gentoo";
|
theme = "gentoo";
|
||||||
};
|
};
|
||||||
shellAliases = {
|
shellAliases = {
|
||||||
|
nos = lib.mkIf config.aux.system.nixos-upgrade-script.enable "nixos-upgrade-script";
|
||||||
z = "zellij";
|
z = "zellij";
|
||||||
update = "upgrade";
|
update = "upgrade";
|
||||||
upgrade = "nh os boot --update --ask";
|
upgrade = "nh os boot --update --ask";
|
||||||
|
|
Loading…
Reference in a new issue