From dd88db29ed76a434460fa544473eeaa867e9a6cd Mon Sep 17 00:00:00 2001 From: phaer Date: Thu, 10 Jul 2025 14:25:51 +0200 Subject: [PATCH] modules/systemd-oomd: add After=systemd-sysusers.service Before this change, systemd-oomd startup was flaky at least with either systemd-sysusers or userborn enabled. It would restart several times until users were provisioned, so that it finally succeeded. An alternative would be to use a DynamicUser which was my first approach, before I discovered that upstream added the after statement in Dec 2024[1]. DynamicUsers could have further implications (sandboxing, etc), so we follow upstream here. It's not clear to me we why Upstreams "After=systemd-sysusers.service" doesn't show up on nixos-unstable systems (systemd v257.6). Userborn is covered, as its unit is aliased to systemd-sysusers.service. The following test succeeded after this change on x86_64-linux: nix-build -A nixosTests.systemd-oomd [1]: https://github.com/systemd/systemd/commit/36dd4296806b5541eb67cd13c535eb0fe3213121 --- nixos/modules/system/boot/systemd/oomd.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nixos/modules/system/boot/systemd/oomd.nix b/nixos/modules/system/boot/systemd/oomd.nix index d7df8903367b..421190e80ed6 100644 --- a/nixos/modules/system/boot/systemd/oomd.nix +++ b/nixos/modules/system/boot/systemd/oomd.nix @@ -45,6 +45,8 @@ in "systemd-oomd.service" "systemd-oomd.socket" ]; + # TODO: Added upstream in upcoming systemd release. Good to drop once we use v258 or later + systemd.services.systemd-oomd.after = [ "systemd-sysusers.service" ]; systemd.services.systemd-oomd.wantedBy = [ "multi-user.target" ]; environment.etc."systemd/oomd.conf".text = lib.generators.toINI { } {