nixpkgs/modules/tasks/swap.nix
Eelco Dolstra dbadf6e9c2 * Use mountall to mount all filesystems and activate all swap devices
during boot.  Mountall ensures that these are done in the right
  order.  It's informed by udev about devices becoming available.  It
  emits some Upstart events upon reaching certain states, in
  particular ‘local-filesystems’ after all local filesystems have been
  mounted successfully, ‘remote-filesystems’ after all network
  filesystems have been mounted, and ‘filesystem’ (sic) when all
  filesystems have been mounted.

  Currently, if a filesystem fails to mount or doesn't exist, then the
  mingettys won't start and the boot will appear to hang.  This is
  because mountall doesn't emit an event for failing filesystems and
  waits indefinitely for the filesystems to become available.

* The ‘filesystems’ and ‘swap’ Upstart jobs are gone.  (Support for
  encrypted swap devices is temporarily gone.)
  
* Generate a proper /etc/fstab from the ‘fileSystems’ and
  ‘swapDevices’ options.

svn path=/nixos/branches/boot-order/; revision=22148
2010-06-04 14:22:11 +00:00

75 lines
1.7 KiB
Nix

{ config, pkgs, ... }:
with pkgs.lib;
{
###### interface
options = {
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.
'';
type = types.list types.optionSet;
options = {config, options, ...}: {
options = {
device = mkOption {
example = "/dev/sda3";
type = types.string;
description = "Path of the device.";
};
label = mkOption {
example = "swap";
type = types.string;
description = ''
Label of the device. Can be used instead of <varname>device</varname>.
'';
};
cipher = mkOption {
default = false;
example = true;
type = types.bool;
description = ''
Encrypt the swap device to protect swapped data. This option
does not work with labels.
'';
};
};
config = {
device =
if options.label.isDefined then
"/dev/disk/by-label/${config.label}"
else
mkNotdef;
};
};
};
};
}