Duplicate of Nix build ate my RAM ðŸ˜.
More cores means more RAM used, and nix by default uses all cores (0). I’m not sure why exactly my laptop is more responsive at oom compared to the desktop, and I guess that’s some bad interaction between linux oom, swap, and nvidia drivers.
{
services.earlyoom = {
enable = true;
enableNotifications = true;
# kill as soon as swap is used
freeSwapThreshold = 100;
freeSwapKillThreshold = 100;
};
# https://discourse.nixos.org/t/nix-build-ate-my-ram/35752
systemd = {
slices.nix-daemon.sliceConfig = {
ManagedOOMMemoryPressure = "kill";
ManagedOOMMemoryPressureLimit = "50%";
};
services.nix-daemon.serviceConfig = {
Slice = "nix-daemon.slice";
OOMScoreAdjust = 1000;
};
};
nix.settings.cores = 16;
}