summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/nixos/archetypes/server.nix2
-rw-r--r--modules/nixos/traits/default.nix1
-rw-r--r--modules/nixos/traits/zram.nix24
-rw-r--r--systems/atlas/default.nix2
-rw-r--r--systems/glados/boot.nix7
-rw-r--r--systems/glados/default.nix8
6 files changed, 28 insertions, 16 deletions
diff --git a/modules/nixos/archetypes/server.nix b/modules/nixos/archetypes/server.nix
index 08b2d65..e42e3d4 100644
--- a/modules/nixos/archetypes/server.nix
+++ b/modules/nixos/archetypes/server.nix
@@ -40,6 +40,8 @@ in {
users = {
hostUser.enable = true;
};
+
+ zram.enable = true;
};
_module.args.unstable = inputs.nixpkgs.legacyPackages.${pkgs.stdenv.hostPlatform.system};
diff --git a/modules/nixos/traits/default.nix b/modules/nixos/traits/default.nix
index d2a50e7..7b1d6fa 100644
--- a/modules/nixos/traits/default.nix
+++ b/modules/nixos/traits/default.nix
@@ -14,5 +14,6 @@
./tailscale.nix
./user-setup.nix
./users.nix
+ ./zram.nix
];
}
diff --git a/modules/nixos/traits/zram.nix b/modules/nixos/traits/zram.nix
new file mode 100644
index 0000000..337137a
--- /dev/null
+++ b/modules/nixos/traits/zram.nix
@@ -0,0 +1,24 @@
+{
+ config,
+ lib,
+ ...
+}: let
+ cfg = config.traits.zram;
+in {
+ options.traits.zram = {
+ enable = lib.mkEnableOption "zram setup & configuration";
+ };
+
+ config = lib.mkIf cfg.enable {
+ # https://github.com/pop-os/default-settings/pull/163
+ # https://wiki.archlinux.org/title/Zram#Multiple_zram_devices
+ boot.kernel.sysctl = {
+ "vm.swappiness" = 180;
+ "vm.watermark_boost_factor" = 0;
+ "vm.watermark_scale_factor" = 125;
+ "vm.page-cluster" = 0;
+ };
+
+ zramSwap.enable = true;
+ };
+}
diff --git a/systems/atlas/default.nix b/systems/atlas/default.nix
index 1e448c6..7c1bc3d 100644
--- a/systems/atlas/default.nix
+++ b/systems/atlas/default.nix
@@ -23,6 +23,4 @@
services.logrotate.checkConfig = false;
system.stateVersion = "23.05";
-
- zramSwap.enable = true;
}
diff --git a/systems/glados/boot.nix b/systems/glados/boot.nix
index a7ac843..9fc716c 100644
--- a/systems/glados/boot.nix
+++ b/systems/glados/boot.nix
@@ -17,13 +17,6 @@
kernelParams = ["amd_pstate=active"];
- kernel.sysctl = {
- "vm.swappiness" = 100;
- "vm.vfs_cache_pressure" = 500;
- "vm.dirty_background_ratio" = 1;
- "vm.dirty_ratio" = 50;
- };
-
loader.systemd-boot.enable = lib.mkForce false;
lanzaboote = {
diff --git a/systems/glados/default.nix b/systems/glados/default.nix
index 4f8af01..101bf2a 100644
--- a/systems/glados/default.nix
+++ b/systems/glados/default.nix
@@ -21,6 +21,7 @@
traits = {
containers.enable = true;
tailscale.enable = true;
+ zram.enable = true;
};
security.tpm2 = {
@@ -48,11 +49,4 @@
};
system.stateVersion = "23.11";
-
- zramSwap = {
- enable = true;
- algorithm = "zstd";
- swapDevices = 1;
- memoryPercent = 50;
- };
}