diff options
| author | adi <adikro@disroot.org> | 2026-07-29 17:09:58 +0200 |
|---|---|---|
| committer | adi <adikro@disroot.org> | 2026-07-29 17:09:58 +0200 |
| commit | 39a2b09c27bb74c9e59d1772764f901e3c8fb9e4 (patch) | |
| tree | 0ba58e6fbf086a85d875df1c10f6d23bc3bbc7da /modules/memory.nix | |
| parent | 8a820cacee1ff07ae7397d053b26e66f7086a4a4 (diff) | |
revamped flake.nix, removed homelab specific modulesstaging
Diffstat (limited to 'modules/memory.nix')
| -rw-r--r-- | modules/memory.nix | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/modules/memory.nix b/modules/memory.nix new file mode 100644 index 0000000..b20ec8a --- /dev/null +++ b/modules/memory.nix @@ -0,0 +1,41 @@ +{ config, lib, ... }: +let + cfg = config.os.core.memory; +in +{ + options.os.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; + } ]; + }) + ]; +} |
