swappidyswapswap

This commit is contained in:
Schrottkatze 2022-09-26 19:30:27 +02:00
parent 84bc51c573
commit 36b479e90d
2 changed files with 27 additions and 1 deletions

View file

@ -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" ];
#};
}

View file

@ -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