* Refactoring: moved some options out of system/options.nix (almost

empty now), do more of bashrc.sh declaratively, and moved nsswitch
  generation to modules/config/nsswitch.nix.

svn path=/nixos/branches/modular-nixos/; revision=15754
This commit is contained in:
Eelco Dolstra 2009-05-27 23:14:38 +00:00
parent 0109b7e44f
commit 3c6ae39a0d
18 changed files with 363 additions and 349 deletions

View File

@ -23,11 +23,9 @@ in
config.environment.checkConfigurationOptions config.environment.checkConfigurationOptions
optionDeclarations config; optionDeclarations config;
nix = config.environment.nix; # The following are used by nixos-rebuild.
nixFallback = pkgs.nixUnstable; nixFallback = pkgs.nixUnstable;
manifests = config.installer.manifests;
manifests = config.installer.manifests; # exported here because nixos-rebuild uses it
tests = config.tests; tests = config.tests;
} }

View File

@ -1,15 +1,10 @@
# Initialise a bunch of environment variables. # Initialise a bunch of environment variables.
export PATH=/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin export PATH=/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin
export LD_LIBRARY_PATH=/var/run/opengl-driver/lib export LD_LIBRARY_PATH=/var/run/opengl-driver/lib
if test -n "@nssModulesPath@"; then
LD_LIBRARY_PATH=@nssModulesPath@:$LD_LIBRARY_PATH
fi
export MODULE_DIR=@modulesTree@/lib/modules export MODULE_DIR=@modulesTree@/lib/modules
export NIXPKGS_CONFIG=/nix/etc/config.nix export NIXPKGS_CONFIG=/nix/etc/config.nix
export NIXPKGS_ALL=/etc/nixos/nixpkgs export NIXPKGS_ALL=/etc/nixos/nixpkgs
export PAGER="less -R" export PAGER="less -R"
export TZ=@timeZone@
export TZDIR=@glibc@/share/zoneinfo
export FONTCONFIG_FILE=/etc/fonts/fonts.conf export FONTCONFIG_FILE=/etc/fonts/fonts.conf
export LANG=@defaultLocale@ export LANG=@defaultLocale@
export EDITOR=nano export EDITOR=nano
@ -18,6 +13,7 @@ export LOCATE_PATH=/var/cache/locatedb
@shellInit@ @shellInit@
export LOCALE_ARCHIVE=/var/run/current-system/sw/lib/locale/locale-archive export LOCALE_ARCHIVE=/var/run/current-system/sw/lib/locale/locale-archive
# Set up secure multi-user builds: non-root users build through the # Set up secure multi-user builds: non-root users build through the
# Nix daemon. # Nix daemon.
if test "$USER" != root; then if test "$USER" != root; then

View File

@ -38,7 +38,6 @@ let
shellInit = config.environment.shellInit; shellInit = config.environment.shellInit;
nixEnvVars = config.nix.envVars; nixEnvVars = config.nix.envVars;
modulesTree = config.system.modulesTree; modulesTree = config.system.modulesTree;
nssModulesPath = config.system.nssModules.path;
wrapperDir = config.security.wrapperDir; wrapperDir = config.security.wrapperDir;
systemPath = config.system.path; systemPath = config.system.path;
binsh = config.system.build.binsh; binsh = config.system.build.binsh;
@ -121,9 +120,7 @@ let
{ # Script executed when the shell starts as a non-login shell (system-wide version). { # Script executed when the shell starts as a non-login shell (system-wide version).
source = pkgs.substituteAll { source = pkgs.substituteAll {
src = ./bashrc.sh; src = ./bashrc.sh;
inherit systemPath wrapperDir modulesTree nssModulesPath; inherit systemPath wrapperDir modulesTree;
inherit (pkgs) glibc;
timeZone = config.time.timeZone;
defaultLocale = config.i18n.defaultLocale; defaultLocale = config.i18n.defaultLocale;
inherit nixEnvVars shellInit; inherit nixEnvVars shellInit;
}; };

View File

@ -34,7 +34,7 @@ generate_index(){
local path="$1" local path="$1"
cd "$path" cd "$path"
echo -n "$path: " 1>&2 echo -n "$path: " 1>&2
{ echo "[ # This file have been generated by $(basename $prog)"; { echo "[ # This file has been generated by $(basename $prog)";
for file in : $(find ./ -wholename '*.impl[./]*' -or -wholename './module-list.nix' -or -type f -name '*.nix' -print | sort); do for file in : $(find ./ -wholename '*.impl[./]*' -or -wholename './module-list.nix' -or -type f -name '*.nix' -print | sort); do
[ "$file" = ':' ] && continue; [ "$file" = ':' ] && continue;
echo -n . 1>&2 echo -n . 1>&2

View File

@ -0,0 +1,56 @@
# Configuration for the Name Service Switch (/etc/nsswitch.conf).
{config, pkgs, ...}:
let
options = {
# NSS modules. Hacky!
system.nssModules = pkgs.lib.mkOption {
internal = true;
default = [];
description = "
Search path for NSS (Name Service Switch) modules. This allows
several DNS resolution methods to be specified via
<filename>/etc/nsswitch.conf</filename>.
";
merge = pkgs.lib.mergeListOption;
apply = list:
let
list2 =
list
# !!! this should be in the LDAP module
++ pkgs.lib.optional config.users.ldap.enable pkgs.nss_ldap;
in {
list = list2;
path = pkgs.lib.makeLibraryPath list2;
};
};
};
in
{
require = [options];
environment.etc =
[ # Name Service Switch configuration file. Required by the C library.
# !!! Factor out the mdns stuff. The avahi module should define
# an option used by this module.
{ source =
if config.services.avahi.nssmdns
then ./nsswitch-mdns.conf
else ./nsswitch.conf;
target = "nsswitch.conf";
}
];
environment.shellInit =
if config.system.nssModules.path != "" then
''
LD_LIBRARY_PATH=${config.system.nssModules.path}:$LD_LIBRARY_PATH
''
else "";
}

View File

@ -0,0 +1,25 @@
{pkgs, config, ...}:
let
options = {
time.timeZone = pkgs.lib.mkOption {
default = "CET";
example = "America/New_York";
description = "The time zone used when displaying times and dates.";
};
};
in
{
require = [options];
environment.shellInit =
''
export TZ=${config.time.timeZone}
export TZDIR=${pkgs.glibc}/share/zoneinfo
'';
}

View File

@ -77,6 +77,15 @@ let
"; ";
}; };
copyKernels = mkOption {
default = false;
description = "
Whether the Grub menu builder should copy kernels and initial
ramdisks to /boot. This is necessary when /nix is on a
different file system than /boot.
";
};
}; };
}; };
in in

View File

@ -1,10 +1,13 @@
[ # This file have been generated by gen-module-list.sh [ # This file have been generated by gen-module-list.sh
./config/fonts.nix ./config/fonts.nix
./config/i18n.nix ./config/i18n.nix
./config/nsswitch.nix
./config/system-path.nix
./config/timezone.nix
./config/unix-odbc-drivers.nix ./config/unix-odbc-drivers.nix
./config/users-groups.nix ./config/users-groups.nix
./config/system-path.nix
./installer/grub/grub.nix ./installer/grub/grub.nix
./legacy.nix
./security/setuid-wrappers.nix ./security/setuid-wrappers.nix
./security/sudo.nix ./security/sudo.nix
./services/audio/alsa.nix ./services/audio/alsa.nix
@ -59,27 +62,27 @@
##### ./services/web-servers/apache-httpd/per-server-options.nix ##### ./services/web-servers/apache-httpd/per-server-options.nix
# error: while evaluating the attribute `<let-body>' at `(string):2:8': # error: while evaluating the attribute `<let-body>' at `(string):2:8':
# while evaluating the function at `(string):3:22': # while evaluating the function at `(string):3:22':
# while evaluating the function at `/trace/nixos/modules/services/web-servers/apache-httpd/per-server-options.nix:6:2': # while evaluating the function at `/home/eelco/Dev/modular-nixos/modules/services/web-servers/apache-httpd/per-server-options.nix:6:2':
# the argument named `forMainServer' required by the function is missing # the argument named `forMainServer' required by the function is missing
##### ./services/web-servers/apache-httpd/subversion.nix ##### ./services/web-servers/apache-httpd/subversion.nix
# error: while evaluating the attribute `<let-body>' at `(string):2:8': # error: while evaluating the attribute `<let-body>' at `(string):2:8':
# while evaluating the function at `(string):3:22': # while evaluating the function at `(string):3:22':
# while evaluating the function at `/trace/nixos/modules/services/web-servers/apache-httpd/subversion.nix:1:2': # while evaluating the function at `/home/eelco/Dev/modular-nixos/modules/services/web-servers/apache-httpd/subversion.nix:1:2':
# the argument named `serverInfo' required by the function is missing # the argument named `serverInfo' required by the function is missing
##### ./services/web-servers/apache-httpd/tomcat-connector.nix ##### ./services/web-servers/apache-httpd/tomcat-connector.nix
# error: while evaluating the attribute `<let-body>' at `(string):2:8': # error: while evaluating the attribute `<let-body>' at `(string):2:8':
# while evaluating the function at `(string):3:22': # while evaluating the function at `(string):3:22':
# while evaluating the function at `/trace/nixos/modules/services/web-servers/apache-httpd/tomcat-connector.nix:1:2': # while evaluating the function at `/home/eelco/Dev/modular-nixos/modules/services/web-servers/apache-httpd/tomcat-connector.nix:1:2':
# the argument named `serverInfo' required by the function is missing # the argument named `serverInfo' required by the function is missing
##### ./services/web-servers/apache-httpd/twiki.nix ##### ./services/web-servers/apache-httpd/twiki.nix
# error: while evaluating the attribute `<let-body>' at `(string):2:8': # error: while evaluating the attribute `<let-body>' at `(string):2:8':
# while evaluating the function at `(string):3:22': # while evaluating the function at `(string):3:22':
# while evaluating the function at `/trace/nixos/modules/services/web-servers/apache-httpd/twiki.nix:1:2': # while evaluating the function at `/home/eelco/Dev/modular-nixos/modules/services/web-servers/apache-httpd/twiki.nix:1:2':
# the argument named `serverInfo' required by the function is missing # the argument named `serverInfo' required by the function is missing
##### ./services/web-servers/apache-httpd/zabbix.nix ##### ./services/web-servers/apache-httpd/zabbix.nix
# error: while evaluating the attribute `<let-body>' at `(string):2:8': # error: while evaluating the attribute `<let-body>' at `(string):2:8':
# while evaluating the function at `(string):3:22': # while evaluating the function at `(string):3:22':
# while evaluating the function at `/trace/nixos/modules/services/web-servers/apache-httpd/zabbix.nix:1:2': # while evaluating the function at `/home/eelco/Dev/modular-nixos/modules/services/web-servers/apache-httpd/zabbix.nix:1:2':
# the argument named `serverInfo' required by the function is missing # the argument named `serverInfo' required by the function is missing
./services/web-servers/jboss.nix ./services/web-servers/jboss.nix
./services/web-servers/tomcat.nix ./services/web-servers/tomcat.nix
@ -87,9 +90,9 @@
./services/x11/xserver/default.nix ./services/x11/xserver/default.nix
./services/x11/xserver/desktop-managers/default.nix ./services/x11/xserver/desktop-managers/default.nix
./services/x11/xserver/desktop-managers/gnome.nix ./services/x11/xserver/desktop-managers/gnome.nix
./services/x11/xserver/desktop-managers/kde4.nix
./services/x11/xserver/desktop-managers/kde-environment.nix ./services/x11/xserver/desktop-managers/kde-environment.nix
./services/x11/xserver/desktop-managers/kde.nix ./services/x11/xserver/desktop-managers/kde.nix
./services/x11/xserver/desktop-managers/kde4.nix
./services/x11/xserver/desktop-managers/none.nix ./services/x11/xserver/desktop-managers/none.nix
./services/x11/xserver/desktop-managers/xterm.nix ./services/x11/xserver/desktop-managers/xterm.nix
./services/x11/xserver/display-managers/default.nix ./services/x11/xserver/display-managers/default.nix
@ -114,9 +117,8 @@
##### ./system/upstart/make-job.nix ##### ./system/upstart/make-job.nix
# error: while evaluating the attribute `<let-body>' at `(string):2:8': # error: while evaluating the attribute `<let-body>' at `(string):2:8':
# while evaluating the function at `(string):3:22': # while evaluating the function at `(string):3:22':
# while evaluating the function at `/trace/nixos/modules/system/upstart/make-job.nix:1:2': # while evaluating the function at `/home/eelco/Dev/modular-nixos/modules/system/upstart/make-job.nix:1:2':
# the argument named `runCommand' required by the function is missing # the argument named `runCommand' required by the function is missing
./system/upstart/tools.nix ./system/upstart/tools.nix
./system/upstart/upstart.nix ./system/upstart/upstart.nix
./legacy.nix
] ]

View File

@ -5,6 +5,19 @@ let
inherit (pkgs.lib) mkOption mkIf; inherit (pkgs.lib) mkOption mkIf;
options = { options = {
boot.hardwareScan = mkOption {
default = true;
description = "
Whether to try to load kernel modules for all detected hardware.
Usually this does a good job of providing you with the modules
you need, but sometimes it can crash the system or cause other
nasty effects. If the hardware scan is turned on, it can be
disabled at boot time by adding the <literal>safemode</literal>
parameter to the kernel command line.
";
};
services = { services = {
udev = { udev = {

View File

@ -136,22 +136,6 @@ mkIf cfg.enable {
environment = { environment = {
extraPackages = [avahi]; extraPackages = [avahi];
# Name Service Switch configuration file. Required by the C library.
# !!! This should be done in some other way, e.g., this module
# should define an option used by the hypothetical module that
# generates nsswitch.conf.
etc = mkIf cfg.nssmdns (mkThenElse {
thenPart = [{
source = ../../../etc/nsswitch-mdns.conf;
target = "nsswitch.conf";
}];
elsePart = [{
source = ../../../etc/nsswitch.conf;
target = "nsswitch.conf";
}];
});
}; };
users = { users = {

View File

@ -11,6 +11,16 @@ let
options = { options = {
boot.isLiveCD = mkOption {
default = false;
description = "
If set to true, the root device will be mounted read-only and
a ramdisk will be mounted on top of it using unionfs to
provide a writable root. This is used for the NixOS
Live-CD/DVD.
";
};
boot.resumeDevice = mkOption { boot.resumeDevice = mkOption {
default = ""; default = "";
example = "0:0"; example = "0:0";

View File

@ -1,10 +1,22 @@
{pkgs, config, ...}: {pkgs, config, ...}:
let let
options = {
boot.localCommands = pkgs.lib.mkOption {
default = "";
example = "text=anything; echo You can put $text here.";
description = "
Shell commands to be executed just before Upstart is started.
";
};
};
inherit (pkgs) substituteAll writeText coreutils utillinux udev upstart; inherit (pkgs) substituteAll writeText coreutils utillinux udev upstart;
kernel = config.boot.kernelPackages.kernel; kernel = config.boot.kernelPackages.kernel;
activateConfiguration = config.system.activationScripts.script; activateConfiguration = config.system.activationScripts.script;
inherit (config.boot) isLiveCD;
# Path for Upstart jobs. Should be quite minimal. # Path for Upstart jobs. Should be quite minimal.
upstartPath = [ upstartPath = [
@ -20,7 +32,7 @@ let
bootStage2 = substituteAll { bootStage2 = substituteAll {
src = ./stage-2-init.sh; src = ./stage-2-init.sh;
isExecutable = true; isExecutable = true;
inherit kernel upstart isLiveCD activateConfiguration upstartPath; inherit kernel upstart activateConfiguration upstartPath;
path = [ path = [
coreutils coreutils
utillinux utillinux
@ -32,16 +44,7 @@ let
in in
{ {
require = [ require = [options];
# config.boot.localCommands
# config.boot.kernelPackages
# config.system.activationScripts
# ../system/activate-configuration.nix
# config.system.build
# ../system/system-options.nix
];
system = { system = {
build = { build = {

View File

@ -52,14 +52,6 @@ in
###### implementation ###### implementation
let let
# should be moved to the corresponding jobs.
nix = config.environment.nix;
nixEnvVars = config.nix.envVars;
kernelPackages = config.boot.kernelPackages;
nssModulesPath = config.system.nssModules.path;
modprobe = config.system.sbin.modprobe;
mount = config.system.sbin.mount;
makeJob = import ./make-job.nix { makeJob = import ./make-job.nix {
inherit (pkgs) runCommand; inherit (pkgs) runCommand;
}; };

View File

@ -6,58 +6,8 @@ in
{ {
time = {
timeZone = mkOption {
default = "CET";
example = "America/New_York";
description = "The time zone used when displaying times and dates.";
};
};
boot = { boot = {
isLiveCD = mkOption {
default = false;
description = "
If set to true, the root device will be mounted read-only and
a ramdisk will be mounted on top of it using unionfs to
provide a writable root. This is used for the NixOS
Live-CD/DVD.
";
};
hardwareScan = mkOption {
default = true;
description = "
Whether to try to load kernel modules for all detected hardware.
Usually this does a good job of providing you with the modules
you need, but sometimes it can crash the system or cause other
nasty effects. If the hardware scan is turned on, it can be
disabled at boot time by adding the <literal>safemode</literal>
parameter to the kernel command line.
";
};
copyKernels = mkOption {
default = false;
description = "
Whether the Grub menu builder should copy kernels and initial
ramdisks to /boot. This is necessary when /nix is on a
different file system than /boot.
";
};
localCommands = mkOption {
default = "";
example = "text=anything; echo You can put $text here.";
description = "
Shell commands to be executed just before Upstart is started.
";
};
extraTTYs = mkOption { extraTTYs = mkOption {
default = []; default = [];
example = [8 9]; example = [8 9];
@ -73,53 +23,6 @@ in
}; };
system = {
# NSS modules. Hacky!
nssModules = mkOption {
internal = true;
default = [];
description = "
Search path for NSS (Name Service Switch) modules. This allows
several DNS resolution methods to be specified via
<filename>/etc/nsswitch.conf</filename>.
";
merge = pkgs.lib.mergeListOption;
apply = list:
let
list2 =
list
++ pkgs.lib.optional config.users.ldap.enable pkgs.nss_ldap;
in {
list = list2;
path = pkgs.lib.makeLibraryPath list2;
};
};
sbin = {
# !!! The mount option should not stay in /system/option.nix
mount = mkOption {
internal = true;
default = pkgs.utillinuxng.override {
buildMountOnly = true;
mountHelpers = pkgs.buildEnv {
name = "mount-helpers";
paths = [
pkgs.ntfs3g
pkgs.mount_cifs
pkgs.nfsUtils
];
pathsToLink = "/sbin";
} + "/sbin";
};
description = "
A patched `mount' command that looks in a directory in the Nix
store instead of in /sbin for mount helpers (like mount.ntfs-3g or
mount.cifs).
";
};
};
};
networking = { networking = {
@ -239,61 +142,6 @@ in
}; };
fileSystems = mkOption {
default = null;
example = [
{ mountPoint = "/";
device = "/dev/hda1";
}
{ mountPoint = "/data";
device = "/dev/hda2";
fsType = "ext3";
options = "data=journal";
}
{ mountPoint = "/bigdisk";
label = "bigdisk";
}
];
description = "
The file systems to be mounted. It must include an entry for
the root directory (<literal>mountPoint = \"/\"</literal>). Each
entry in the list is an attribute set with the following fields:
<literal>mountPoint</literal>, <literal>device</literal>,
<literal>fsType</literal> (a file system type recognised by
<command>mount</command>; defaults to
<literal>\"auto\"</literal>), and <literal>options</literal>
(the mount options passed to <command>mount</command> using the
<option>-o</option> flag; defaults to <literal>\"defaults\"</literal>).
Instead of specifying <literal>device</literal>, you can also
specify a volume label (<literal>label</literal>) for file
systems that support it, such as ext2/ext3 (see <command>mke2fs
-L</command>).
<literal>autocreate</literal> forces <literal>mountPoint</literal> to be created with
<command>mkdir -p</command> .
";
};
swapDevices = mkOption {
default = [];
example = [
{ device = "/dev/hda7"; }
{ device = "/var/swapfile"; }
{ label = "bigswap"; }
];
description = "
The swap devices and swap files. These must have been
initialised using <command>mkswap</command>. Each element
should be an attribute set specifying either the path of the
swap device or file (<literal>device</literal>) or the label
of the swap device (<literal>label</literal>, see
<command>mkswap -L</command>). Using a label is
recommended.
";
};
nesting = { nesting = {
children = mkOption { children = mkOption {
default = []; default = [];
@ -304,14 +152,5 @@ in
}; };
passthru = mkOption {
default = {};
description = "
Additional parameters. Ignored. When you want to be sure that
/etc/nixos/nixos -A config.passthru.* is that same thing the
system rebuild will use.
";
};
require = import ../modules/module-list.nix; require = import ../modules/module-list.nix;
} }

View File

@ -1,11 +1,75 @@
{pkgs, config, ...}: {pkgs, config, ...}:
let
###### interface
options = {
fileSystems = pkgs.lib.mkOption {
default = null;
example = [
{ mountPoint = "/";
device = "/dev/hda1";
}
{ mountPoint = "/data";
device = "/dev/hda2";
fsType = "ext3";
options = "data=journal";
}
{ mountPoint = "/bigdisk";
label = "bigdisk";
}
];
description = "
The file systems to be mounted. It must include an entry for
the root directory (<literal>mountPoint = \"/\"</literal>). Each
entry in the list is an attribute set with the following fields:
<literal>mountPoint</literal>, <literal>device</literal>,
<literal>fsType</literal> (a file system type recognised by
<command>mount</command>; defaults to
<literal>\"auto\"</literal>), and <literal>options</literal>
(the mount options passed to <command>mount</command> using the
<option>-o</option> flag; defaults to <literal>\"defaults\"</literal>).
Instead of specifying <literal>device</literal>, you can also
specify a volume label (<literal>label</literal>) for file
systems that support it, such as ext2/ext3 (see <command>mke2fs
-L</command>).
<literal>autocreate</literal> forces <literal>mountPoint</literal> to be created with
<command>mkdir -p</command> .
";
};
system.sbin.mount = pkgs.lib.mkOption {
internal = true;
default = pkgs.utillinuxng.override {
buildMountOnly = true;
mountHelpers = pkgs.buildEnv {
name = "mount-helpers";
paths = [
pkgs.ntfs3g
pkgs.mount_cifs
pkgs.nfsUtils
];
pathsToLink = "/sbin";
} + "/sbin";
};
description = "
A patched `mount' command that looks in a directory in the Nix
store instead of in /sbin for mount helpers (like mount.ntfs-3g or
mount.cifs).
";
};
};
###### implementation ###### implementation
let
inherit (pkgs) e2fsprogs; inherit (pkgs) e2fsprogs;
mountPoints = map (fs: fs.mountPoint) fileSystems;
fileSystems = config.fileSystems; fileSystems = config.fileSystems;
mountPoints = map (fs: fs.mountPoint) fileSystems;
devices = map (fs: if fs ? device then fs.device else "LABEL=" + fs.label) fileSystems; devices = map (fs: if fs ? device then fs.device else "LABEL=" + fs.label) fileSystems;
fsTypes = map (fs: if fs ? fsType then fs.fsType else "auto") fileSystems; fsTypes = map (fs: if fs ? fsType then fs.fsType else "auto") fileSystems;
optionss = map (fs: if fs ? options then fs.options else "defaults") fileSystems; optionss = map (fs: if fs ? options then fs.options else "defaults") fileSystems;
@ -117,6 +181,7 @@ let
in in
{ {
require = [options];
services = { services = {
extraJobs = [{ extraJobs = [{
name = "filesystems"; name = "filesystems";

View File

@ -1,9 +1,34 @@
{pkgs, config, ...}: {pkgs, config, ...}:
###### implementation
let let
###### interface
options = {
swapDevices = pkgs.lib.mkOption {
default = [];
example = [
{ device = "/dev/hda7"; }
{ device = "/var/swapfile"; }
{ label = "bigswap"; }
];
description = "
The swap devices and swap files. These must have been
initialised using <command>mkswap</command>. Each element
should be an attribute set specifying either the path of the
swap device or file (<literal>device</literal>) or the label
of the swap device (<literal>label</literal>, see
<command>mkswap -L</command>). Using a label is
recommended.
";
};
};
###### implementation
inherit (pkgs) utillinux lib; inherit (pkgs) utillinux lib;
swapDevices = config.swapDevices; swapDevices = config.swapDevices;
@ -18,21 +43,22 @@ in
{ {
services = { require = [options];
extraJobs = [{
services.extraJobs = [{
name = "swap"; 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.
@ -40,15 +66,14 @@ in
#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
"; '';
}]; }];
};
} }