Automatic system upgrades

From NixOS Wiki
Revision as of 14:06, 30 July 2025 by Bittner (talk | contribs) (Remove deprecated flags from code sample)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Automatic system upgrades can be used to upgrade a system regularly at a specific time. This can help to reduce the time period of applying important security patches to your running software but might also introduce some breakage in case an automatic upgrade fails.

Configuration

To enable unattended automatic system updates on a flake-enabled host, add following part to your configuration:

Breeze-text-x-plain.png
/etc/nixos/configuration.nix
system.autoUpgrade = {
  enable = true;
  flake = inputs.self.outPath;
  flags = [
    "-L" # print build logs
  ];
  dates = "02:00";
  randomizedDelaySec = "45min";
};


To see the status of the timer run

# systemctl status nixos-upgrade.timer

The upgrade log can be printed with this command

# systemctl status nixos-upgrade.service