···34343535- [ebusd](https://ebusd.eu), a daemon for handling communication with eBUS devices connected to a 2-wire bus system (“energy bus” used by numerous heating systems). Available as [services.ebusd](#opt-services.ebusd.enable).
36363737+- [systemd-sysupdate](https://www.freedesktop.org/software/systemd/man/systemd-sysupdate.html), atomically updates the host OS, container images, portable service images or other sources. Available as [systemd.sysupdate](opt-systemd.sysupdate).
37383839## Backward Incompatibilities {#sec-release-23.11-incompatibilities}
3940
···11+{ config, lib, pkgs, utils, ... }:
22+33+let
44+ cfg = config.systemd.sysupdate;
55+66+ format = pkgs.formats.ini { };
77+88+ listOfDefinitions = lib.mapAttrsToList
99+ (name: format.generate "${name}.conf")
1010+ (lib.filterAttrs (k: _: !(lib.hasPrefix "_" k)) cfg.transfers);
1111+1212+ definitionsDirectory = pkgs.runCommand "sysupdate.d" { } ''
1313+ mkdir -p $out
1414+ ${(lib.concatStringsSep "\n"
1515+ (map (pkg: "cp ${pkg} $out/${pkg.name}") listOfDefinitions)
1616+ )}
1717+ '';
1818+in
1919+{
2020+ options.systemd.sysupdate = {
2121+2222+ enable = lib.mkEnableOption (lib.mdDoc "systemd-sysupdate") // {
2323+ description = lib.mdDoc ''
2424+ Atomically update the host OS, container images, portable service
2525+ images or other sources.
2626+2727+ If enabled, updates are triggered in regular intervals via a
2828+ `systemd.timer` unit.
2929+3030+ Please see
3131+ <https://www.freedesktop.org/software/systemd/man/systemd-sysupdate.html>
3232+ for more details.
3333+ '';
3434+ };
3535+3636+ timerConfig = utils.systemdUtils.unitOptions.timerOptions.options.timerConfig // {
3737+ default = { };
3838+ description = lib.mdDoc ''
3939+ The timer configuration for performing the update.
4040+4141+ By default, the upstream configuration is used:
4242+ <https://github.com/systemd/systemd/blob/main/units/systemd-sysupdate.timer>
4343+ '';
4444+ };
4545+4646+ reboot = {
4747+ enable = lib.mkEnableOption (lib.mdDoc "automatically rebooting after an update") // {
4848+ description = lib.mdDoc ''
4949+ Whether to automatically reboot after an update.
5050+5151+ If set to `true`, the system will automatically reboot via a
5252+ `systemd.timer` unit but only after a new version was installed.
5353+5454+ This uses a unit completely separate from the one performing the
5555+ update because it is typically advisable to download updates
5656+ regularly while the system is up, but delay reboots until the
5757+ appropriate time (i.e. typically at night).
5858+5959+ Set this to `false` if you do not want to reboot after an update. This
6060+ is useful when you update a container image or another source where
6161+ rebooting is not necessary in order to finalize the update.
6262+ '';
6363+ };
6464+6565+ timerConfig = utils.systemdUtils.unitOptions.timerOptions.options.timerConfig // {
6666+ default = { };
6767+ description = lib.mdDoc ''
6868+ The timer configuration for rebooting after an update.
6969+7070+ By default, the upstream configuration is used:
7171+ <https://github.com/systemd/systemd/blob/main/units/systemd-sysupdate-reboot.timer>
7272+ '';
7373+ };
7474+ };
7575+7676+ transfers = lib.mkOption {
7777+ type = with lib.types; attrsOf format.type;
7878+ default = { };
7979+ example = {
8080+ "10-uki.conf" = {
8181+ Transfer = {
8282+ ProtectVersion = "%A";
8383+ };
8484+8585+ Source = {
8686+ Type = "url-file";
8787+ Path = "https://download.example.com/";
8888+ MatchPattern = "nixos_@v.efi.xz";
8989+ };
9090+9191+ Target = {
9292+ Type = "regular-file";
9393+ Path = "/EFI/Linux";
9494+ PathRelativeTo = "boot";
9595+ MatchPattern = ''
9696+ nixos_@v+@l-@d.efi"; \
9797+ nixos_@v+@l.efi \
9898+ nixos_@v.efi
9999+ '';
100100+ Mode = "0444";
101101+ TriesLeft = 3;
102102+ TriesDone = 0;
103103+ InstancesMax = 2;
104104+ };
105105+ };
106106+ };
107107+ description = lib.mdDoc ''
108108+ Specify transfers as a set of the names of the transfer files as the
109109+ key and the configuration as its value. The configuration can use all
110110+ upstream options. See
111111+ <https://www.freedesktop.org/software/systemd/man/sysupdate.d.html>
112112+ for all available options.
113113+ '';
114114+ };
115115+116116+ };
117117+118118+ config = lib.mkIf cfg.enable {
119119+120120+ systemd.additionalUpstreamSystemUnits = [
121121+ "systemd-sysupdate.service"
122122+ "systemd-sysupdate.timer"
123123+ "systemd-sysupdate-reboot.service"
124124+ "systemd-sysupdate-reboot.timer"
125125+ ];
126126+127127+ systemd.timers = {
128128+ "systemd-sysupdate" = {
129129+ wantedBy = [ "timers.target" ];
130130+ timerConfig = cfg.timerConfig;
131131+ };
132132+ "systemd-sysupdate-reboot" = lib.mkIf cfg.reboot.enable {
133133+ wantedBy = [ "timers.target" ];
134134+ timerConfig = cfg.reboot.timerConfig;
135135+ };
136136+ };
137137+138138+ environment.etc."sysupdate.d".source = definitionsDirectory;
139139+ };
140140+141141+ meta.maintainers = with lib.maintainers; [ nikstur ];
142142+}