Browse Source

Auto reboot after kernel changed

master
dump_stack() 1 year ago
parent
commit
4ff347fe63
1 changed files with 12 additions and 0 deletions
  1. 12
    0
      configuration.nix

+ 12
- 0
configuration.nix 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.autoUpgrade.enable = true;
}

Loading…
Cancel
Save