]> Git — Sourcephile - julm/julm-nix.git/blob - nixos/profiles/zswap.nix
+user/correctness(nvim): fix vim.lsp.buf.references() duplicates
[julm/julm-nix.git] / nixos / profiles / zswap.nix
1 # Documentation: https://www.kernel.org/doc/html/latest/admin-guide/mm/zswap.html
2 # Explanation: https://chrisdown.name/2026/03/24/zswap-vs-zram-when-to-use-what.html
3 {
4 config,
5 lib,
6 ...
7 }:
8 let
9 cfg = config.zswap;
10 in
11 {
12 options.zswap = {
13 enable = lib.mkEnableOption "zswap compressed swap cache" // {
14 default = true;
15 };
16
17 max_pool_percent = lib.mkOption {
18 type = lib.types.int;
19 default = 50;
20 description = "Maximum percentage of RAM to use for the zswap pool.";
21 };
22 };
23
24 config = lib.mkIf cfg.enable {
25 boot = {
26 kernelParams = [
27 "zswap.enabled=1"
28 "zswap.compressor=zstd"
29 "zswap.max_pool_percent=${toString cfg.max_pool_percent}"
30 "zswap.shrinker_enabled=1"
31 "zswap.zpool=zsmalloc"
32 ];
33 initrd.kernelModules = [
34 "zsmalloc"
35 "zstd"
36 ];
37 };
38
39 };
40 }