diff options
| author | adikro <adikro@disroot.org> | 2025-12-20 15:25:38 +0100 |
|---|---|---|
| committer | adikro <adikro@disroot.org> | 2025-12-20 15:25:38 +0100 |
| commit | c1d9af57156f3c95590d9a12c394ee064df9696e (patch) | |
| tree | 7e515761590c510c30329ef8548c7d84a8e95aaa /sys/core/memory.nix | |
| parent | 791bc419b6dac7c70951981ef6b34cdf85828470 (diff) | |
added disko config for laptop, added storage and memory modules
Diffstat (limited to 'sys/core/memory.nix')
| -rw-r--r-- | sys/core/memory.nix | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/sys/core/memory.nix b/sys/core/memory.nix new file mode 100644 index 0000000..cdf71e8 --- /dev/null +++ b/sys/core/memory.nix @@ -0,0 +1,46 @@ +{ config, lib, ... }: +let + cfg = config.sys.core.memory; +in +{ + options.sys.core.memory = { + enable = lib.mkEnableOption "memory management"; + + zram = { + enable = lib.mkEnableOption "enables zram compression"; + percent = lib.mkOption { + type = lib.types.int; + default = 25; + description = "Percentage of total RAM to use for zram"; + }; + }; + + swapfile = { + enable = lib.mkEnableOption "enables a swapfile"; + size = lib.mkOption { + type = lib.types.int; + default = 8192; + description = "Size of the swapfile in gigabytes"; + }; + }; + }; + + config = lib.mkIf cfg.enable (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; + } ]; + }) + ]); +} |
