]> Git — Sourcephile - sourcephile-nix.git/blob - nixos/profiles/systems/zramSwap.nix
wireguard: setup intranet
[sourcephile-nix.git] / nixos / profiles / systems / zramSwap.nix
1 { pkgs, lib, config, ... }:
2 {
3 zramSwap = {
4 enable = true;
5 algorithm = lib.mkDefault "zstd";
6 memoryPercent = lib.mkDefault 50;
7 swapDevices = lib.mkDefault 1;
8 };
9
10 boot.kernel.sysctl = {
11 # Increase cache pressure, which increases the tendency of the kernel to
12 # reclaim memory used for caching of directory and inode objects. You will use
13 # less memory over a longer period of time. The performance hit is negated by
14 # the downside of swapping sooner.
15 "vm.vfs_cache_pressure" = lib.mkDefault 500;
16
17 # Increasing how aggressively the kernel will swap memory pages since we are
18 # using ZRAM first.
19 "vm.swappiness" = lib.mkDefault 100;
20
21 # Background processes will start writing right away when it hits the 1% limit
22 "vm.dirty_background_ratio" = lib.mkDefault 1;
23
24 # The system won’t force synchronous I/O until it gets to 50% dirty_ratio.
25 "vm.dirty_ratio" = lib.mkDefault 50;
26 };
27 }