dotfiles/modules/os/core/zram.nix
eriedaberrie 5a4d076d84 Initial commit
Note: not the actual initial commit.

I swear I will stop repeatedly force pushing to this single commit eventually
ok.
2024-09-21 23:21:42 -07:00

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;
};
};
}