{ pkgs, lib, config, ... }: { zramSwap = { enable = true; algorithm = lib.mkDefault "zstd"; memoryPercent = lib.mkDefault 50; swapDevices = lib.mkDefault 1; }; boot.kernel.sysctl = { # Increase cache pressure, which increases the tendency of the kernel to # reclaim memory used for caching of directory and inode objects. You will use # less memory over a longer period of time. The performance hit is negated by # the downside of swapping sooner. "vm.vfs_cache_pressure" = lib.mkDefault 500; # Increasing how aggressively the kernel will swap memory pages since we are # using ZRAM first. "vm.swappiness" = lib.mkDefault 100; # Background processes will start writing right away when it hits the 1% limit "vm.dirty_background_ratio" = lib.mkDefault 1; # The system won’t force synchronous I/O until it gets to 50% dirty_ratio. "vm.dirty_ratio" = lib.mkDefault 50; }; }