From 96d2ce96c4b26f400d03a355c33da0b693de9a7a Mon Sep 17 00:00:00 2001 From: Soispha Date: Sun, 28 May 2023 18:01:02 +0200 Subject: Feat(hm/pkgs/scrs/update-sys): Add a way to specify to mode --- .../packages/scripts/small_functions/update-sys | 28 +++++++++++++++++----- 1 file 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 ] [--help] + $NAME [--branch ] [--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!"; -- cgit 1.4.1