From c372a3fbe950d549489952180dec28c0814d8a0a Mon Sep 17 00:00:00 2001 From: Ali Rizvi Date: Sun, 31 Aug 2025 15:23:19 -0400 Subject: [PATCH] nixos/systemd-oomd: add `After=swap.target` to fix swap detection issues This should be removed after systemd 258 releases, as it is a temporary drop-in fix to circumvent the issue of systemd-oomd failing to detect a valid swap (noticeable in cases of users using `zram` as swap). I've taken the liberty to clarify which `After=` override should be dropped when, based on the systemd version on Nixpkgs. --- nixos/modules/system/boot/systemd/oomd.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nixos/modules/system/boot/systemd/oomd.nix b/nixos/modules/system/boot/systemd/oomd.nix index 421190e80ed6..252758c6bcf6 100644 --- a/nixos/modules/system/boot/systemd/oomd.nix +++ b/nixos/modules/system/boot/systemd/oomd.nix @@ -45,8 +45,11 @@ 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.after = [ + "swap.target" # TODO: drop after systemd v258 + "systemd-sysusers.service" # TODO: drop after systemd v257.8 + ]; systemd.services.systemd-oomd.wantedBy = [ "multi-user.target" ]; environment.etc."systemd/oomd.conf".text = lib.generators.toINI { } {