diff options
author | Soispha <soispha@vhack.eu> | 2023-05-28 18:01:02 +0200 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2023-05-28 18:01:02 +0200 |
commit | 96d2ce96c4b26f400d03a355c33da0b693de9a7a (patch) | |
tree | 2ab3f48dd5e8d2c96abdf5eec990b78cddf70025 /home-manager/packages/scripts/small_functions | |
parent | chore(version): v1.5.2 (diff) | |
download | nixos-config-96d2ce96c4b26f400d03a355c33da0b693de9a7a.tar.gz nixos-config-96d2ce96c4b26f400d03a355c33da0b693de9a7a.zip |
Feat(hm/pkgs/scrs/update-sys): Add a way to specify to mode
Diffstat (limited to '')
-rwxr-xr-x | home-manager/packages/scripts/small_functions/update-sys | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/home-manager/packages/scripts/small_functions/update-sys b/home-manager/packages/scripts/small_functions/update-sys index bc953c96..69f822b3 100755 --- a/home-manager/packages/scripts/small_functions/update-sys +++ b/home-manager/packages/scripts/small_functions/update-sys @@ -5,18 +5,21 @@ help() { cat << EOF -This is a Nixos System flake update manager. +This is a NixOS System flake update manager. Usage: - $name [--branch <branchname>] [--help] + $NAME [--branch <branchname>] [--help] Options: - --branch | -b [branchname] select a branch to update from. - --help | -h output this help. + --branch | -b BRANCHNAME + select a branch to update from. + --mode | -m MODE + select a mode to update with + --help | -h + output this help. EOF exit "$1"; } -name="update-sys"; tmp=$(mktmp); BRANCH=""; @@ -34,6 +37,15 @@ while [ "$#" -gt 0 ];do fi shift 2; ;; + "--mode" | "-m") + if [ -n "$2" ];then + MODE="$2"; + else + error "$1 requires an argument"; + help 1; + fi + shift 2; + ;; *) error "the option $1 does not exist!"; help 1; @@ -54,7 +66,11 @@ git pull --rebase; git remote show origin | grep 'HEAD' | cut -d':' -f2 | sed -e 's/^ *//g' -e 's/ *$//g' > $tmp & msg2 "Updating system..."; -nixos-rebuild switch; +if [ -n "$MODE" ]; then + nixos-rebuild "$MODE"; +else + nixos-rebuild switch; +fi git switch "$(cat $tmp)" > /dev/null 2>&1 && msg2 "Switched to branch '$(cat $tmp)'"; msg "Finished Update!"; |