aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xscripts/pretty-rebuild29
1 files changed, 27 insertions, 2 deletions
diff --git a/scripts/pretty-rebuild b/scripts/pretty-rebuild
index 0814cca..1a7be63 100755
--- a/scripts/pretty-rebuild
+++ b/scripts/pretty-rebuild
@@ -1,9 +1,34 @@
#!/usr/bin/env nix-shell
#!nix-shell -i zsh --packages nvd zsh
+zmodload zsh/zutil
+zparseopts -D -E -A opts -- -flake:- h u x
+
+if (( ${+opts[-x]} )); then
+ set -x
+fi
+
+if (( ${+opts[-h]} )); then
+ <<EOF >&2
+usage: ${0:t} [ --flake name ] [ -h ] [ -u ] [ -x ]
+
+ --flake build the system from the specified flake
+ -h this message
+ -u update flake.lock before rebuilding
+ -x enable shell debugging
+EOF
+ exit 1
+fi
+
+if (( ${+opts[-flake]} )); then
+ args=("--flake ${opts[-flake]}" ${=@})
+else
+ args=("--flake .#$(hostname -s)" ${=@})
+fi
+
cd /etc/nixos && \
- nix flake update && \
- nixos-rebuild switch --upgrade --show-trace && \
+ if (( ${+opts[-u]} )); then nix flake update; fi && \
+ nixos-rebuild switch --show-trace ${=args} && \
echo && \
nixos-rebuild list-generations | cat && \
echo && \