nixpkgs/home/packages/custom/update-system/default.nix
Daniel Siepmann c0d988fc89
Fix none working update script
Nix adds errexit and failpipe.
Using head will end in 141 SIGPIPE, see: https://unix.stackexchange.com/a/580119/185477

I apply the workaround / fix as suggested on StackExchange.

That way the script runs and can execute the cleanup and diff.
2023-03-07 15:46:46 +01:00

20 lines
495 B
Nix

{ writeShellApplication }:
writeShellApplication {
name = "custom-update-system";
text = ''
nix-channel --update
home-manager switch
oldVersion=$( (home-manager generations; true) | head -n 2 | tail -n 1 | cut -d' ' -f 7)
newVersion=$( (home-manager generations; true) | head -n 1 | cut -d' ' -f 7)
nvd diff "$oldVersion" "$newVersion"
home-manager expire-generations '-12 days'
nix-env --delete-generations +3
nix store gc
nix store optimise
'';
}