From 6aaa5993e4c1cfb205ed555d958702f9bba1770d Mon Sep 17 00:00:00 2001 From: adikro Date: Wed, 24 Dec 2025 16:21:00 +0100 Subject: a bunch of changes, renames sys to os and refactored some of the logic --- os/core/memory.nix | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 os/core/memory.nix (limited to 'os/core/memory.nix') diff --git a/os/core/memory.nix b/os/core/memory.nix new file mode 100644 index 0000000..956cc73 --- /dev/null +++ b/os/core/memory.nix @@ -0,0 +1,41 @@ +{ config, lib, ... }: +let + cfg = config.sys.core.memory; +in +{ + options.sys.core.memory = { + zram = { + enable = lib.mkEnableOption "enables zram compression"; + percent = lib.mkOption { + type = lib.types.int; + default = 25; + }; + }; + + swapfile = { + enable = lib.mkEnableOption "enables a swapfile"; + size = lib.mkOption { + type = lib.types.int; + default = 8; + }; + }; + }; + config = lib.mkMerge [ + (lib.mkIf cfg.zram.enable { + zramSwap = { + enable = true; + algorithm = "zstd"; + memoryPercent = cfg.zram.percent; + priority = 100; + }; + }) + + (lib.mkIf cfg.swapfile.enable { + swapDevices = [ { + device = "/.swapvol/swapfile"; + size = cfg.swapfile.size * 1024; + priority = 0; + } ]; + }) + ]; +} -- cgit v1.3