diff --git a/base.nix b/base.nix index 3709042..aaeb957 100644 --- a/base.nix +++ b/base.nix @@ -73,6 +73,10 @@ # enable kernel same-page merging for improved vm test performance hardware.ksm.enable = true; + # enable Alt+SysRq+ 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 diff --git a/hosts/nixos/sopp/configuration.nix b/hosts/nixos/sopp/configuration.nix index 87b36c7..0ce8550 100644 --- a/hosts/nixos/sopp/configuration.nix +++ b/hosts/nixos/sopp/configuration.nix @@ -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 diff --git a/profiles/earlyoom.nix b/profiles/earlyoom.nix new file mode 100644 index 0000000..1035c7b --- /dev/null +++ b/profiles/earlyoom.nix @@ -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)$" + ]; + }; +}