modules/nixos/common: use preSwitchChecks for update diff

This commit is contained in:
zowoq 2025-01-03 13:45:07 +10:00
parent 8528527e06
commit 16c333cfde
3 changed files with 9 additions and 6 deletions

View file

@ -18,6 +18,15 @@
inputs.srvos.nixosModules.server
];
srvos.update-diff.enable = false;
system.preSwitchChecks.update-diff = ''
if [[ -e /run/current-system && -e "''${1-}" ]]; then
echo "--- diff to current-system"
${pkgs.nvd}/bin/nvd --nix-bin-dir=${config.nix.package}/bin diff /run/current-system "''${1-}"
echo "---"
fi
'';
# Hard-link duplicated files
nix.settings.auto-optimise-store = true;
nix.optimise.automatic = false;

View file

@ -20,11 +20,6 @@ nix-env --profile /nix/var/nix/profiles/system --set "$p"
booted="$(readlink /run/booted-system/{initrd,kernel,kernel-modules} && cat /run/booted-system/kernel-params)"
built="$(readlink "$p"/{initrd,kernel,kernel-modules} && cat "$p"/kernel-params)"
if [[ $booted != "$built" ]]; then
if [[ -e /run/current-system ]]; then
echo "--- diff to current-system"
nvd diff /run/current-system "$p"
echo "---"
fi
/nix/var/nix/profiles/system/bin/switch-to-configuration boot
# don't use kexec if system is virtualized, reboots are fast enough
if ! systemd-detect-virt -q; then

View file

@ -16,7 +16,6 @@
pkgs.coreutils
pkgs.curl
pkgs.kexec-tools
pkgs.nvd
];
script = builtins.readFile ./update.bash;
};