From 1674b6a844761d4e5bd4a58b63f9bc92d1978ea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Sun, 8 Feb 2026 13:02:58 +0100 Subject: [PATCH] system: enable zram swap for all hosts Provides compressed swap in RAM to prevent OOM kills during nixos-rebuild on low-memory VMs (2GB). Removes duplicate zram configs from jelly01 and nix-cache01. Co-Authored-By: Claude Opus 4.5 --- hosts/jelly01/configuration.nix | 4 ---- hosts/nix-cache01/default.nix | 1 - hosts/nix-cache01/zram.nix | 6 ------ system/default.nix | 1 + system/zram.nix | 8 ++++++++ 5 files changed, 9 insertions(+), 11 deletions(-) delete mode 100644 hosts/nix-cache01/zram.nix create mode 100644 system/zram.nix diff --git a/hosts/jelly01/configuration.nix b/hosts/jelly01/configuration.nix index 048ae1c..2e69519 100644 --- a/hosts/jelly01/configuration.nix +++ b/hosts/jelly01/configuration.nix @@ -64,9 +64,5 @@ vault.enable = true; homelab.deploy.enable = true; - zramSwap = { - enable = true; - }; - system.stateVersion = "23.11"; # Did you read the comment? } diff --git a/hosts/nix-cache01/default.nix b/hosts/nix-cache01/default.nix index 435b31e..e5795a5 100644 --- a/hosts/nix-cache01/default.nix +++ b/hosts/nix-cache01/default.nix @@ -4,6 +4,5 @@ ./configuration.nix ../../services/nix-cache ../../services/actions-runner - ./zram.nix ]; } diff --git a/hosts/nix-cache01/zram.nix b/hosts/nix-cache01/zram.nix deleted file mode 100644 index 1b0509c..0000000 --- a/hosts/nix-cache01/zram.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ ... }: -{ - zramSwap = { - enable = true; - }; -} diff --git a/system/default.nix b/system/default.nix index a04e2bb..9ba5d06 100644 --- a/system/default.nix +++ b/system/default.nix @@ -12,5 +12,6 @@ ./pki/root-ca.nix ./sshd.nix ./vault-secrets.nix + ./zram.nix ]; } diff --git a/system/zram.nix b/system/zram.nix new file mode 100644 index 0000000..bb90208 --- /dev/null +++ b/system/zram.nix @@ -0,0 +1,8 @@ +# Compressed swap in RAM +# +# Provides overflow memory during Nix builds and upgrades. +# Prevents OOM kills on low-memory hosts (2GB VMs). +{ ... }: +{ + zramSwap.enable = true; +}