mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-15 14:26:33 +01:00
3b9a7c747e
svn path=/nixos/trunk/; revision=7455
30 lines
674 B
Nix
30 lines
674 B
Nix
{utillinux, swapDevices}:
|
|
|
|
{
|
|
name = "swap";
|
|
|
|
job = "
|
|
start on startup
|
|
start on new-devices
|
|
|
|
script
|
|
for device in ${toString swapDevices}; do
|
|
# !!! Check whether we are already swapping to $device.
|
|
${utillinux}/sbin/swapon \"$device\" || true
|
|
done
|
|
|
|
# Remove swap devices not listed in swapDevices.
|
|
for used in $(cat /proc/swaps | grep '^/' | sed 's/ .*//'); do
|
|
found=
|
|
for device in ${toString swapDevices}; do
|
|
if test \"$used\" = \"$device\"; then found=1; fi
|
|
done
|
|
if test -z \"$found\"; then
|
|
${utillinux}/sbin/swapoff \"$used\" || true
|
|
fi
|
|
done
|
|
|
|
end script
|
|
";
|
|
|
|
}
|