summaryrefslogtreecommitdiff
path: root/modules/nixos/traits/zram.nix
blob: d0c6a36172f982aab7bcb6dd7fe988ca70492c27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{ config, lib, ... }:
let
  cfg = config.traits.zram;
in
{
  options.traits.zram = {
    enable = lib.mkEnableOption "zram setup & configuration";
  };

  config = lib.mkIf cfg.enable {
    # https://github.com/pop-os/default-settings/pull/163
    # https://wiki.archlinux.org/title/Zram#Multiple_zram_devices
    boot.kernel.sysctl = {
      "vm.swappiness" = 180;
      "vm.watermark_boost_factor" = 0;
      "vm.watermark_scale_factor" = 125;
      "vm.page-cluster" = 0;
    };

    zramSwap.enable = true;
  };
}