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

I swear I will stop repeatedly force pushing to this single commit eventually
ok.
2024-08-27 11:10:58 -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;
};
};
}