···88 ./paths.nix # paths
99 ./wayland.nix # wayland settings
1010 ./xdg.nix # move everything to nice placee
1111- ./zram.nix # zram optimisation and enabling
1111+ ./zswap.nix # zswap optimisation and enabling
1212 # keep-sorted end
1313 ];
1414}
-23
modules/nixos/environment/zram.nix
···11-{ lib, config, ... }:
22-let
33- inherit (lib) mkIf;
44-in
55-{
66- # compress half of the ram to use as swap basically, get more memory per memory
77- zramSwap = {
88- enable = true;
99- algorithm = "zstd";
1010-1111- # defaults to 50
1212- memoryPercent = 90;
1313- };
1414-1515- boot.kernel.sysctl = mkIf config.zramSwap.enable {
1616- # zram is relatively cheap, prefer swap
1717- "vm.swappiness" = 180;
1818- "vm.watermark_boost_factor" = 0;
1919- "vm.watermark_scale_factor" = 125;
2020- # zram is in memory, no need to readahead
2121- "vm.page-cluster" = 0;
2222- };
2323-}
+14
modules/nixos/environment/zswap.nix
···11+{ lib, config, ... }:
22+let
33+ inherit (lib) mkIf;
44+in
55+{
66+ # compress half of the ram to use as swap basically, get more memory per memory
77+ # <https://chrisdown.name/2026/03/24/zswap-vs-zram-when-to-use-what.html>
88+ boot.zswap = {
99+ enable = config.swapDevices != [ ];
1010+1111+ # defaults are good when its not a server
1212+ maxPoolPercent = mkIf config.garden.profiles.server.enable 15;
1313+ };
1414+}