uhhh, have a look. better commit messages in future, proooomise xoxo
This commit is contained in:
commit
d5354e0828
22 changed files with 1440 additions and 0 deletions
49
scripts/nixos-upgrade
Executable file
49
scripts/nixos-upgrade
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
#!/bin/sh
|
||||
set -euo pipefail
|
||||
|
||||
nixcfg=~/Projects/nixcfg
|
||||
|
||||
cd "$nixcfg"
|
||||
tmpdir="$(mktemp -d)"
|
||||
outdir="$tmpdir/out"
|
||||
trap "git rm -f --ignore-unmatch flake.lock" EXIT
|
||||
ln -s ./hosts/$(hostname)/flake.lock .
|
||||
git add flake.lock
|
||||
nix flake update
|
||||
nom build -o "$outdir" ".#nixosConfigurations.$(hostname).config.system.build.toplevel"
|
||||
nvd diff /run/current-system "$outdir"
|
||||
|
||||
if [ "$#" -gt 0 ] && [ "$1" = "-y" ]; then
|
||||
echo 'Skipping prompt'
|
||||
else
|
||||
echo
|
||||
while true; do
|
||||
read -p 'Do you want to process with upgrade [Y/n]' yn
|
||||
case "$yn" in
|
||||
[Yy]* )
|
||||
break
|
||||
;;
|
||||
[Nn]* )
|
||||
exit 1
|
||||
;;
|
||||
"")
|
||||
break
|
||||
;;
|
||||
* )
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
echo Upgrading...
|
||||
|
||||
# Do system upgrade
|
||||
sudo rsync -rl --delete --exclude=".*" . /etc/nixos
|
||||
sudo ln -s "/etc/nixos/hosts/$(hostname)/hardware-configuration.nix" /etc/nixos/hardware-configuration.nix
|
||||
sudo nixos-rebuild switch
|
||||
|
||||
if [ $(git status --porcelain ./hosts/$(hostname)/flake.lock | wc -l) -gt 0 ]; then
|
||||
git rm -f flake.lock
|
||||
git add ./hosts/$(hostname)/flake.lock
|
||||
git commit -m "System upgrade $(hostname)"
|
||||
fi
|
||||
14
scripts/show-upgrade
Executable file
14
scripts/show-upgrade
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
set -euo pipefail
|
||||
|
||||
nixcfg=~/Projects/nixcfg
|
||||
|
||||
tempdir=$(mktemp -d /tmp/tmp.nix-updateinfo.XXX)
|
||||
git clone --reference "$nixcfg" "$nixcfg" "$tempdir"
|
||||
cd $tempdir
|
||||
nix flake lock --update-input nixpkgs
|
||||
nix build ".#nixosConfigurations.$(hostname).config.system.build.toplevel"
|
||||
nvd diff /run/current-system ./result
|
||||
|
||||
cd ~-
|
||||
rm -rf "$tempdir"
|
||||
Loading…
Add table
Add a link
Reference in a new issue