feat(memory): enable zram compressed-RAM swap by default (#76 slice)
All checks were successful
Check / eval (push) Successful in 4m1s
All checks were successful
Check / eval (push) Successful in 4m1s
First slice of BACKLOG #76 (hibernation + zram, split): zramSwap on by default in modules/nixos/oom.nix — the memory-pressure layer before earlyoom. zstd @ 50% RAM (nixpkgs defaults, explicit for reproducibility), priority 100 so day-to-day paging fills zram first and any disk swapfile stays reserved for #76's hibernate image (hibernation can't resume from volatile zram). Follows the earlyoom mkDefault precedent — no toggle. Adds checks.zram-swap runNixOSTest importing oom.nix, asserting the device is an active swap, uses [zstd], and carries priority 100. Verified: V2 checks.zram-swap PASS (/dev/zram0 in /proc/swaps, zstd, prio 100); V1 full distro toplevel builds; V0 flake check --no-build green. #76 remainder (disk swapfile default + resume + installer) still open. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
25
flake.nix
25
flake.nix
@@ -659,6 +659,31 @@
|
||||
'';
|
||||
};
|
||||
|
||||
# zram compressed-RAM swap (oom.nix, BACKLOG #76 slice): enabled
|
||||
# by default as the memory-pressure layer *before* earlyoom. Prove
|
||||
# the device comes up as an active swap, uses zstd, and carries the
|
||||
# high priority that keeps day-to-day paging off any disk swapfile
|
||||
# (which #76 reserves for the hibernate image). Imports oom.nix
|
||||
# directly so the check tracks the module, not a hand-copy.
|
||||
zram-swap = pkgs.testers.runNixOSTest {
|
||||
name = "nomarchy-zram-swap";
|
||||
nodes.machine = { ... }: {
|
||||
imports = [ ./modules/nixos/oom.nix ];
|
||||
virtualisation.memorySize = 1024;
|
||||
};
|
||||
testScript = ''
|
||||
# zram-generator brings the device up as swap shortly after boot.
|
||||
machine.wait_until_succeeds("grep -q /dev/zram0 /proc/swaps", timeout=60)
|
||||
# Configured compression algorithm is the selected one ([zstd]).
|
||||
machine.succeed("grep -q '\\[zstd\\]' /sys/block/zram0/comp_algorithm")
|
||||
# High priority (100) so the kernel fills zram before any disk
|
||||
# swap — the ordering #76's hibernate image depends on.
|
||||
machine.succeed(
|
||||
"awk '$1==\"/dev/zram0\" && $5==100 {ok=1} END{exit !ok}' /proc/swaps"
|
||||
)
|
||||
'';
|
||||
};
|
||||
|
||||
# Snapshot GUI canary: btrfs-assistant crashes in libbtrfsutil's
|
||||
# UNPRIVILEGED subvolume iteration (btrfs-progs 6.17.1, fixed
|
||||
# upstream after 6.17.1) but runs fine as root — which is how the
|
||||
|
||||
Reference in New Issue
Block a user