diff --git a/potatobook-g/configuration.nix b/potatobook-g/configuration.nix index c27b4e7..f1ef505 100644 --- a/potatobook-g/configuration.nix +++ b/potatobook-g/configuration.nix @@ -100,6 +100,29 @@ # i rly should put that important big comment back here system.stateVersion = "22.11"; # Did you read the comment? + + systemd.services = { + create-swapfile = { + serviceConfig.Type = "oneshot"; + wantedBy = [ "swap-swapfile.swap" ]; + script = '' + swapfile="/swap/swapfile" + if [[ -f "$swapfile" ]]; then + echo "Swap file $swapfile already exists, taking no action" + else + echo "Setting up swap file $swapfile" + ${pkgs.coreutils}/bin/truncate -s 0 "$swapfile" + ${pkgs.e2fsprogs}/bin/chattr +C "$swapfile" + fi + ''; + }; + }; + + #fileSystems."/swap" = { + # device = "/dev/disk/by-uuid/f6d243ec-6be9-4551-8cbb-aefb7b691a62"; + # fsType = "btrfs"; + # options = [ "subvol=swap" "noatime" ]; + #}; } diff --git a/potatobook-g/hardware-configuration.nix b/potatobook-g/hardware-configuration.nix index 130ce65..078db27 100644 --- a/potatobook-g/hardware-configuration.nix +++ b/potatobook-g/hardware-configuration.nix @@ -36,7 +36,10 @@ fsType = "vfat"; }; - swapDevices = [ ]; + swapDevices = [{ + device = "/swap/swapfile"; + size = (1024 * 12); # 12GB + }]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's