1
0

Auto reboot after kernel changed

This commit is contained in:
dump_stack() 2019-04-12 17:24:45 +00:00 committed by Mikhail Klementev
parent 736208b9c1
commit 4ff347fe63

View File

@ -50,6 +50,18 @@ in {
}; };
}; };
systemd.services.nixos-upgrade.serviceConfig.ExecStartPost = pkgs.writeScript "post-upgrade-check" ''
#!${pkgs.stdenv.shell}
current=$(readlink -f /run/current-system/kernel)
booted=$(readlink -f /run/booted-system/kernel)
if [ "$current" != "$booted" ]; then
echo "kernel changed, reboot" | systemd-cat --identifier "post-upgrade-check";
reboot
else
echo "same kernel, do not reboot" | systemd-cat --identifier "post-upgrade-check";
fi
'';
system.stateVersion = "18.09"; system.stateVersion = "18.09";
system.autoUpgrade.enable = true; system.autoUpgrade.enable = true;
} }