5a4d076d84
Note: not the actual initial commit. I swear I will stop repeatedly force pushing to this single commit eventually ok.
32 lines
633 B
Nix
32 lines
633 B
Nix
{ config, lib, ... }:
|
|
|
|
let
|
|
cfg = config.my.zram;
|
|
in {
|
|
options.my.zram = {
|
|
enable = lib.mkEnableOption null // {
|
|
default = !config.my.fs.swapPartition;
|
|
};
|
|
writebackDevice = lib.mkOption {
|
|
default = null;
|
|
type = with lib.types; nullOr path;
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
zramSwap = {
|
|
enable = true;
|
|
algorithm = "zstd";
|
|
memoryPercent = 90;
|
|
inherit (cfg) writebackDevice;
|
|
};
|
|
|
|
boot.kernel.sysctl = {
|
|
"vm.swappiness" = 180;
|
|
"vm.watermark_boost_factor" = 0;
|
|
"vm.watermark_scale_factor" = 125;
|
|
"vm.page-cluster" = 1;
|
|
};
|
|
};
|
|
}
|