aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/pretty-rebuild
blob: 733f4b62727d64c11c795b6c89885f4f991ae707 (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
#!/usr/bin/env nix-shell
#!nix-shell -i zsh --packages nvd zsh

if [[ ${@} =~ "--flake" ]]; then
	args=(${=@})
else
	args=("--flake .#$(hostname -s)" ${=@})
fi

while read branch file; do
	ssh king curl -L --output-dir /dev/shm -o ${file}.tar.gz https://api.github.com/repos/NixOS/nixpkgs/tarball/${branch}
	scp king:/dev/shm/${file}.tar.gz /dev/shm
	ssh king rm /dev/shm/${file}.tar.gz
done <<EOF
release-25.11 stable
nixos-unstable unstable
master master
EOF

cd /etc/nixos && \
	nix flake update && \
	nixos-rebuild switch --upgrade --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