systemd: add sysupdated (#424101)

Changed files
+28 -6
nixos
modules
system
boot
systemd
tests
pkgs
os-specific
linux
systemd
+22 -3
nixos/modules/system/boot/systemd/sysupdate.nix
···
format = pkgs.formats.ini { listToValue = toString; };
-
definitionsDirectory = utils.systemdUtils.lib.definitions "sysupdate.d" format cfg.transfers;
+
# TODO: Switch back to using utils.systemdUtils.lib.definitions once
+
# https://github.com/systemd/systemd/pull/38187 is resolved. Also ensure
+
# utils.systemdUtils.lib.definitions is capable of setting a custom file
+
# suffix.
+
sysupdateTransfers = lib.mapAttrs' (name: value: {
+
name = "sysupdate.d/${name}.transfer";
+
value.source = format.generate "${name}.transfer" value;
+
}) cfg.transfers;
in
{
options.systemd.sysupdate = {
···
};
config = lib.mkIf cfg.enable {
+
assertions = [
+
{
+
assertion = config.systemd.package.withSysupdate;
+
message = "Cannot enable systemd-sysupdate with systemd package not built with sysupdate support";
+
}
+
];
systemd.additionalUpstreamSystemUnits = [
"systemd-sysupdate.service"
"systemd-sysupdate.timer"
"systemd-sysupdate-reboot.service"
"systemd-sysupdate-reboot.timer"
+
"systemd-sysupdated.service"
];
+
systemd.services.systemd-sysupdated.aliases = [ "dbus-org.freedesktop.sysupdate1.service" ];
+
systemd.timers = {
"systemd-sysupdate" = {
wantedBy = [ "timers.target" ];
···
};
};
-
environment.etc."sysupdate.d".source = definitionsDirectory;
+
environment.etc = sysupdateTransfers;
};
-
meta.maintainers = with lib.maintainers; [ nikstur ];
+
meta.maintainers = with lib.maintainers; [
+
nikstur
+
jmbaur
+
];
}
+4 -3
nixos/tests/systemd-sysupdate.nix
···
# Tests downloading a signed update artifact from a server to a target machine.
# This test does not rely on the `systemd.timer` units provided by the
-
# `systemd-sysupdate` module but triggers the `systemd-sysupdate` service
-
# manually to make the test more robust.
+
# `systemd-sysupdate` module but triggers the `updatectl` tool directly to
+
# demonstrate how to initiate updates manually.
{ lib, pkgs, ... }:
···
testScript = ''
server.wait_for_unit("nginx.service")
-
target.succeed("systemctl start systemd-sysupdate")
+
print(target.succeed("updatectl list"))
+
target.succeed("updatectl update")
assert "nixos" in target.wait_until_succeeds("cat /nixos_1.txt", timeout=5)
'';
}
+2
pkgs/os-specific/linux/systemd/default.nix
···
(lib.mesonEnable "libiptc" withIptables)
(lib.mesonEnable "repart" withRepart)
(lib.mesonEnable "sysupdate" withSysupdate)
+
(lib.mesonEnable "sysupdated" withSysupdate)
(lib.mesonEnable "seccomp" withLibseccomp)
(lib.mesonEnable "selinux" withSelinux)
(lib.mesonEnable "tpm2" withTpm2Tss)
···
withMachined
withNetworkd
withPortabled
+
withSysupdate
withTimedated
withTpm2Tss
withUtmp