Add nixos update command

This commit is contained in:
Daniel Siepmann 2022-11-11 14:08:34 +01:00
parent 7d1c0c66b0
commit 3919c7abb6
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
2 changed files with 20 additions and 0 deletions

View file

@ -14,6 +14,7 @@ with pkgs; [
# TODO: Create one `./packages/custom/default.nix which includes all other?
(callPackage ./packages/custom/dmenu-scripts { })
(callPackage ./packages/custom/update-system { })
(callPackage ./packages/custom/update-nixos-system { })
(callPackage ./packages/custom/update-ubuntu-system { })
(callPackage ./packages/custom/push-etckeeper { })
(callPackage ./packages/custom/backup { })

View file

@ -0,0 +1,19 @@
{ writeShellApplication }:
writeShellApplication {
name = "custom-update-nixos-system";
# Including this doesn't work
text = ''
sudo nixos-rebuild switch --upgrade-all
# shellcheck disable=SC2010
oldVersion=$(ls -vr /nix/var/nix/profiles/ | grep system | head -n 2 | tail -n 1)
nvd diff "/nix/var/nix/profiles/$oldVersion" "/nix/var/nix/profiles/system"
sudo nix-env -p /nix/var/nix/profiles/system --delete-generations +5
nix store gc
nix store optimise
'';
}