summaryrefslogtreecommitdiff
path: root/modules/nixos/traits/zram.nix
blob: 337137aa82e86e3f9c5767e0e8754590a48ba0f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
  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;
  };
}