Working zswap configuration (different from zram)

I reordered @uzi 's code so that writing to enabled is the last thing done:

  systemd.services.zswap = {
    description = "Enable zswap, set to zstd and Z3FOLD";
    enable = true;
    wantedBy = ["basic.target"];
    path = [ pkgs.bash ];
    serviceConfig = {
      ExecStart = ''${pkgs.bash}/bin/bash -c 'cd /sys/module/zswap/parameters && \
        echo zstd > compressor && echo z3fold > zpool && echo 20 > max_pool_percent && \
        echo 1 > enabled'
        '';
      Type = "oneshot";
    };
  };
1 Like