blob: 1a7be636df34fe98ad673c2836edd0d95b5d60de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#!/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 && \
if (( ${+opts[-u]} )); then nix flake update; fi && \
nixos-rebuild switch --show-trace ${=args} && \
echo && \
nixos-rebuild list-generations | cat && \
echo && \
res=$(find /nix/var/nix/profiles -iname system-\* -type l -exec ls -ltr \{\} + | awk '{print $9}' | tail -2)
if [[ ${?} -eq 0 && $(echo -E "${res}" | wc -l) -eq 2 ]]; then
nvd diff $(echo -E "${res}" | xargs)
fi
|