test earlyoom

This commit is contained in:
2025-06-05 16:22:48 +02:00
parent e6807e867f
commit f5d9d5cb56
3 changed files with 21 additions and 0 deletions

View File

@@ -73,6 +73,10 @@
# enable kernel same-page merging for improved vm test performance
hardware.ksm.enable = true;
# enable Alt+SysRq+<key> shortcuts
# https://wiki.nixos.org/wiki/Linux_kernel#Enable_SysRq
# boot.kernel.sysctl."kernel.sysrq" = 1;
boot.initrd.systemd.enable = true; # systemd manages initfs boot, systemd-analyse can see what happened
# https://discourse.nixos.org/t/what-to-do-with-a-full-boot-partition/2049
# raise to 15 if auto upgrading

View File

@@ -45,6 +45,7 @@
imports = [
./hardware-configuration.nix
../../../profiles/sshd
../../../profiles/earlyoom.nix
../../../profiles/no-suspend.nix
#../../../profiles/oci/podman.nix
../../../profiles/oci/docker.nix

16
profiles/earlyoom.nix Normal file
View File

@@ -0,0 +1,16 @@
{
services.earlyoom = {
enable = true;
# all must be true for earlyoom to kill shit
freeMemThreshold = 2; # in percent
freeSwapThreshold = 20; # in percent
freeSwapKillThreshold = 5; # in percent, sigkill
extraArgs = [
# "-g" # Kill all processes that have same process group id
"--avoid"
"^(X|init|Xorg|ssh|plasma.*|gnome.*|konsole|lxterminal|ghostty|kwin)$"
"--prefer"
"^(electron|libreoffice|gimp|zen*|nix-env|nix-instantiate|gcc|rustc)$"
];
};
}