Add ZRAM module and enable it in core defaults

This commit is contained in:
2026-02-14 13:43:14 +01:00
parent 380b774ee3
commit c3517a0f7f
2 changed files with 33 additions and 0 deletions

View File

@@ -26,6 +26,7 @@
./virtualbox.nix ./virtualbox.nix
./xdg.nix ./xdg.nix
./xserver.nix ./xserver.nix
./zram.nix
inputs.stylix.nixosModules.stylix inputs.stylix.nixosModules.stylix
]; ];
} }

32
modules/core/zram.nix Normal file
View File

@@ -0,0 +1,32 @@
{pkgs, ...}: {
zramSwap = {
enable = true;
priority = 5;
memoryMax = 16 * 1024 * 1024 * 1024;
algorithm = "zstd";
swapDevices = 1;
memoryPercent = 50;
};
boot = {
kernelParams = [
"zswap.enabled=1" # enables zswap
"zswap.compressor=zstd" # compression algorithm
"zswap.max_pool_percent=20" # maximum percentage of RAM that zswap is allowed to use
"zswap.shrinker_enabled=1" # whether to shrink the pool proactively on high memory pressure
];
tmp = {
useZram = true;
zramSettings = {
compression-algorithm = "zstd";
zram-size = "ram * 0.5";
fs-type = "ext4";
options = "X-mount.mode=1777,discard";
};
};
};
services.zram-generator = {
enable = true;
package = pkgs.zram-generator;
settings = {};
};
}