diff options
| author | Mark Nipper <nipsy@bitgnome.net> | 2026-09-14 09:31:32 -0700 |
|---|---|---|
| committer | Mark Nipper <nipsy@bitgnome.net> | 2026-09-14 09:31:32 -0700 |
| commit | cff0cd3b2c044158b8f5b74b7b16212bebc40d08 (patch) | |
| tree | a06c1a614552a6be2d4ca934c32312a72326e874 /scripts | |
| parent | 4950583b049c58f0f89d6ebf191fbef3401c96b0 (diff) | |
| download | nix-cff0cd3b2c044158b8f5b74b7b16212bebc40d08.tar nix-cff0cd3b2c044158b8f5b74b7b16212bebc40d08.tar.gz nix-cff0cd3b2c044158b8f5b74b7b16212bebc40d08.tar.bz2 nix-cff0cd3b2c044158b8f5b74b7b16212bebc40d08.tar.lz nix-cff0cd3b2c044158b8f5b74b7b16212bebc40d08.tar.xz nix-cff0cd3b2c044158b8f5b74b7b16212bebc40d08.tar.zst nix-cff0cd3b2c044158b8f5b74b7b16212bebc40d08.zip | |
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/pretty-rebuild | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/scripts/pretty-rebuild b/scripts/pretty-rebuild index 995eda2..1a7be63 100755 --- a/scripts/pretty-rebuild +++ b/scripts/pretty-rebuild @@ -1,14 +1,33 @@ #!/usr/bin/env nix-shell #!nix-shell -i zsh --packages nvd zsh -if [[ ${@} =~ "--flake" ]]; then - args=(${=@}) +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 && \ + if (( ${+opts[-u]} )); then nix flake update; fi && \ nixos-rebuild switch --show-trace ${=args} && \ echo && \ nixos-rebuild list-generations | cat && \ |
