about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2024-09-30 06:23:45 +0200
committerPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2024-09-30 06:23:45 +0200
commit0c733ee356748d8a35b6170357a6da2631b1b449 (patch)
tree040e0f87ee134cca481116793c5260842ea6b20b
parent117e2a672807ab747af98add7a5d32b4864876cc (diff)
downloaddots-0c733ee356748d8a35b6170357a6da2631b1b449.tar.gz
dots-0c733ee356748d8a35b6170357a6da2631b1b449.zip
t14: 42 current 2024-09-30 06:23:38 24.05.20240928.fbca5e7 6.6.52 *
-rwxr-xr-xrebuild.sh14
1 files changed, 8 insertions, 6 deletions
diff --git a/rebuild.sh b/rebuild.sh
index 97f4926..b6d05a0 100755
--- a/rebuild.sh
+++ b/rebuild.sh
@@ -12,7 +12,8 @@
 DIR=$HOME/nixos
 OPT=$1
 
-FORCE=[ $1 = "-f" ]
+FORCE=false
+[ "$1" = "-f" ] && FORCE=true
 
 # A rebuild script that commits on a successful build
 set -e pipefail
@@ -21,8 +22,10 @@ set -e pipefail
 pushd $DIR
 
 # Early return if no changes were detected (thanks @singiamtel!)
-if git diff --quiet '*'; then
-    if ! $FORCE; then
+if $FORCE; then
+	echo Forcing rebuild
+else
+    if git diff --quiet '*'; then
         echo "No changes detected, exiting."
         popd
         exit 0
@@ -46,9 +49,8 @@ cat nixos-switch.log | grep --color error && exit 1
 current=$(nixos-rebuild list-generations | grep current)
 
 # Commit all changes witih the generation metadata
-if ! $FORCE; then
-    git commit -am "$(hostname): $current"
-fi
+$FORCE
+git commit -am "$(hostname): $current"
 
 # Back to where you were
 popd