about summary refs log tree commit diff stats
path: root/home-manager/packages
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xhome-manager/packages/scripts/small_functions/update-sys28
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!";