Automatic system upgrades: Difference between revisions

From NixOS Wiki
imported>Onny
Init page
 
Klinger (talk | contribs)
m Added a sentence about garbage collection
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
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.
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. For automatic upgrades an automatic [[Garbage Collection|garbage collection]] is important to prevent full /boot and / partitions.


== Configuration ==
== Configuration ==
Line 12: Line 12:
     "--update-input"
     "--update-input"
     "nixpkgs"
     "nixpkgs"
     "-L" # print build logs
     "--print-build-logs"
   ];
   ];
   dates = "02:00";
   dates = "02:00";
Line 18: Line 18:
};
};
</nowiki>}}
</nowiki>}}
To see the status of the timer run
<syntaxhighlight lang="bash">
# systemctl status nixos-upgrade.timer
</syntaxhighlight>
The upgrade log can be printed with this command
<syntaxhighlight lang="bash">
# systemctl status nixos-upgrade.service
</syntaxhighlight>
[[Category:NixOS]]

Latest revision as of 18:24, 18 June 2024

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. For automatic upgrades an automatic garbage collection is important to prevent full /boot and / partitions.

Configuration

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

/etc/nixos/configuration.nix
system.autoUpgrade = {
  enable = true;
  flake = inputs.self.outPath;
  flags = [
    "--update-input"
    "nixpkgs"
    "--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