summary refs log tree commit diff
path: root/modules/oom.nix
blob: b05052a6bbe203b2c4e077beabec99435aefe2d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# module for controlling out-of-memory states for desktop linux machines,
# to avoid hanging the full system including the shell, in favor of
# sending out oom signals before it comes to that with the earlyoom service.
{ ... }:

{
  services = {
    # TODO: i believe systemd-oomd could also be used to prevent system hanging,
    # and i should investigate it, to avoid running 2 userspace oom killers.
    # earlyoom is known for the small amount of configuration needed to prevent the
    # system from hanging for half an hour, and we can keep it simple for now.
    earlyoom = {
      enable = true;

      freeMemThreshold = 10;
      freeMemKillThreshold = 5;

      # requires systembus-notify.
      # i wish libnotify would support sending out
      # notifications to all users through the system
      # session bus natively...
      # see: https://gitlab.gnome.org/GNOME/libnotify/-/issues/9
      enableNotifications = true;
    };

    systembus-notify.enable = true;
  };
}