summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMel <mel@rnrd.eu>2026-01-16 18:11:12 +0100
committerMel <mel@rnrd.eu>2026-01-16 18:11:12 +0100
commitb20db589f6ba02a48a8a1cf2ab2e08d71e81c7c5 (patch)
treeea5eaa6c526fa8c7824547c751c9e370eff2697c
parent20e85ed56ef0d73f523c1c9bbe7bf2fe1659c2db (diff)
downloadminerals-b20db589f6ba02a48a8a1cf2ab2e08d71e81c7c5.tar.zst
minerals-b20db589f6ba02a48a8a1cf2ab2e08d71e81c7c5.zip
Enable earlyoom to prevent system hanging
Signed-off-by: Mel <mel@rnrd.eu>
-rw-r--r--modules/common.nix1
-rw-r--r--modules/oom.nix28
2 files changed, 29 insertions, 0 deletions
diff --git a/modules/common.nix b/modules/common.nix
index e36d4e9..00b87bb 100644
--- a/modules/common.nix
+++ b/modules/common.nix
@@ -13,6 +13,7 @@
./vim.nix
./tmux.nix
./nix-ld.nix
+ ./oom.nix
];
services.envfs.enable = true;
diff --git a/modules/oom.nix b/modules/oom.nix
new file mode 100644
index 0000000..b05052a
--- /dev/null
+++ b/modules/oom.nix
@@ -0,0 +1,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;
+ };
+}