mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-11 15:15:36 +00:00
fd9604b319
svn path=/nixos/trunk/; revision=34488
77 lines
1.8 KiB
Nix
77 lines
1.8 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.uniq types.string;
|
||
description = "Path of the device.";
|
||
};
|
||
|
||
label = mkOption {
|
||
example = "swap";
|
||
type = types.uniq types.string;
|
||
description = ''
|
||
Label of the device. Can be used instead of <varname>device</varname>.
|
||
'';
|
||
};
|
||
|
||
size = mkOption {
|
||
default = null;
|
||
example = 2048;
|
||
type = types.nullOr types.int;
|
||
description = ''
|
||
If this option is set, ‘device’ is interpreted as the
|
||
path of a swapfile that will be created automatically
|
||
with the indicated size (in megabytes) if it doesn't
|
||
exist.
|
||
'';
|
||
};
|
||
|
||
};
|
||
|
||
config = {
|
||
device =
|
||
if options.label.isDefined then
|
||
"/dev/disk/by-label/${config.label}"
|
||
else
|
||
mkNotdef;
|
||
};
|
||
|
||
};
|
||
|
||
};
|
||
|
||
};
|
||
|
||
}
|