diff --git a/lib/options.nix b/lib/options.nix index 0eb64d8..a5ae624 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -10,7 +10,7 @@ enable-dm = true; # enable display manager (for server use) wol = "enp0s31f6"; # set to iface name to enable Wake-on-LAN - swapfile = 0; # * 1024; # swapfile size in MB, set to 0 to disable + swapfile = 8 * 1024; # swapfile size in MB, set to 0 to disable (only used for server, desktop will use swap partition instead) resume-dev = "/dev/disk/by-uuid/1721721a-bb5a-4166-a077-9500d30be2ac"; # set to swap partition to enable hibernation, e.g. /dev/disk/by-uuid/1721721a-bb5a-4166-a077-9500d30be2ac homelab = { diff --git a/modules/system/core/filesystem.nix b/modules/system/core/filesystem.nix index b8603b7..9902478 100644 --- a/modules/system/core/filesystem.nix +++ b/modules/system/core/filesystem.nix @@ -1,5 +1,5 @@ -{ swapfile, ... }: -{ +{ ... }: { + services.fstrim.enable = true; boot.supportedFilesystems = [ "ext4" "btrfs" @@ -7,17 +7,4 @@ "ntfs" "exfat" ]; - - swapDevices = - if swapfile == 0 then - [ ] - else - [ - { - device = "/swapfile"; - size = swapfile; - } - ]; - - services.fstrim.enable = true; } \ No newline at end of file diff --git a/modules/system/core/swapfile.nix b/modules/system/core/swapfile.nix new file mode 100644 index 0000000..39f0516 --- /dev/null +++ b/modules/system/core/swapfile.nix @@ -0,0 +1,6 @@ +{ swapfile, ... }: { + swapDevices = if swapfile == 0 then [] else [{ + device = "/swapfile"; + size = swapfile; + }]; +} \ No newline at end of file diff --git a/modules/system/server.nix b/modules/system/server.nix index 3670d62..a89a9c8 100644 --- a/modules/system/server.nix +++ b/modules/system/server.nix @@ -11,6 +11,7 @@ ./homelab/dns.nix ./homelab/git.nix ./homelab/ai.nix + ./core/swapfile.nix ./base.nix ];