Convert "swap"
svn path=/nixos/branches/fix-style/; revision=14402
This commit is contained in:
parent
d964466c1a
commit
ed8bfc1c78
@ -422,6 +422,8 @@ in
|
|||||||
|
|
||||||
(import ../upstart-jobs/filesystems.nix) # Mount file systems.
|
(import ../upstart-jobs/filesystems.nix) # Mount file systems.
|
||||||
|
|
||||||
|
(import ../upstart-jobs/swap.nix)
|
||||||
|
|
||||||
|
|
||||||
# security
|
# security
|
||||||
(import ../system/sudo.nix)
|
(import ../system/sudo.nix)
|
||||||
|
@ -71,12 +71,6 @@ let
|
|||||||
jobs = map makeJob
|
jobs = map makeJob
|
||||||
([
|
([
|
||||||
|
|
||||||
# Swapping.
|
|
||||||
(import ../upstart-jobs/swap.nix {
|
|
||||||
inherit (pkgs) utillinux lib;
|
|
||||||
swapDevices = config.swapDevices;
|
|
||||||
})
|
|
||||||
|
|
||||||
# Network interfaces.
|
# Network interfaces.
|
||||||
(import ../upstart-jobs/network-interfaces.nix {
|
(import ../upstart-jobs/network-interfaces.nix {
|
||||||
inherit modprobe config;
|
inherit modprobe config;
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
{lib, utillinux, swapDevices}:
|
{pkgs, config, ...}:
|
||||||
|
|
||||||
|
###### implementation
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
inherit (pkgs) utillinux lib;
|
||||||
|
|
||||||
|
swapDevices = config.swapDevices;
|
||||||
|
|
||||||
devicesByPath =
|
devicesByPath =
|
||||||
map (x: x.device) (lib.filter (x: x ? device) swapDevices);
|
map (x: x.device) (lib.filter (x: x ? device) swapDevices);
|
||||||
|
|
||||||
@ -10,35 +16,39 @@ let
|
|||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
name = "swap";
|
services = {
|
||||||
|
extraJobs = [{
|
||||||
|
name = "swap";
|
||||||
|
|
||||||
job = "
|
job = "
|
||||||
start on startup
|
start on startup
|
||||||
start on new-devices
|
start on new-devices
|
||||||
|
|
||||||
script
|
script
|
||||||
for device in ${toString devicesByPath}; do
|
for device in ${toString devicesByPath}; do
|
||||||
${utillinux}/sbin/swapon \"$device\" || true
|
${utillinux}/sbin/swapon \"$device\" || true
|
||||||
done
|
done
|
||||||
|
|
||||||
for label in ${toString devicesByLabel}; do
|
for label in ${toString devicesByLabel}; do
|
||||||
${utillinux}/sbin/swapon -L \"$label\" || true
|
${utillinux}/sbin/swapon -L \"$label\" || true
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove swap devices not listed in swapDevices.
|
# Remove swap devices not listed in swapDevices.
|
||||||
# !!! disabled because it doesn't work with labels
|
# !!! disabled because it doesn't work with labels
|
||||||
#for used in $(cat /proc/swaps | grep '^/' | sed 's/ .*//'); do
|
#for used in $(cat /proc/swaps | grep '^/' | sed 's/ .*//'); do
|
||||||
# found=
|
# found=
|
||||||
# for device in $ {toString swapDevices}; do
|
# for device in $ {toString swapDevices}; do
|
||||||
# if test \"$used\" = \"$device\"; then found=1; fi
|
# if test \"$used\" = \"$device\"; then found=1; fi
|
||||||
# done
|
# done
|
||||||
# if test -z \"$found\"; then
|
# if test -z \"$found\"; then
|
||||||
# ${utillinux}/sbin/swapoff \"$used\" || true
|
# ${utillinux}/sbin/swapoff \"$used\" || true
|
||||||
# fi
|
# fi
|
||||||
#done
|
#done
|
||||||
|
|
||||||
end script
|
|
||||||
";
|
|
||||||
|
|
||||||
|
end script
|
||||||
|
";
|
||||||
|
}];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user