From c3517a0f7f0c02cd634aa6147df97ea8cc08c816 Mon Sep 17 00:00:00 2001 From: GarandPLG Date: Sat, 14 Feb 2026 13:43:14 +0100 Subject: [PATCH] Add ZRAM module and enable it in core defaults --- modules/core/default.nix | 1 + modules/core/zram.nix | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 modules/core/zram.nix diff --git a/modules/core/default.nix b/modules/core/default.nix index 573e210..ce782b5 100644 --- a/modules/core/default.nix +++ b/modules/core/default.nix @@ -26,6 +26,7 @@ ./virtualbox.nix ./xdg.nix ./xserver.nix + ./zram.nix inputs.stylix.nixosModules.stylix ]; } diff --git a/modules/core/zram.nix b/modules/core/zram.nix new file mode 100644 index 0000000..837339c --- /dev/null +++ b/modules/core/zram.nix @@ -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 = {}; + }; +}