Commit dd88db29 authored by phaer's avatar phaer
Browse files

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
parent 28c73b6e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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 { } {