network-interfaces module: optionSet -> submodule

This commit is contained in:
Eric Sagnes 2016-09-11 19:45:24 +09:00
parent 12a1de8305
commit 062928c3ad

View File

@ -97,21 +97,22 @@ let
addrOpts = v:
assert v == 4 || v == 6;
{
address = mkOption {
type = types.str;
description = ''
IPv${toString v} address of the interface. Leave empty to configure the
interface using DHCP.
'';
};
{ options = {
address = mkOption {
type = types.str;
description = ''
IPv${toString v} address of the interface. Leave empty to configure the
interface using DHCP.
'';
};
prefixLength = mkOption {
type = types.addCheck types.int (n: n >= 0 && n <= (if v == 4 then 32 else 128));
description = ''
Subnet mask of the interface, specified as the number of
bits in the prefix (<literal>${if v == 4 then "24" else "64"}</literal>).
'';
prefixLength = mkOption {
type = types.addCheck types.int (n: n >= 0 && n <= (if v == 4 then 32 else 128));
description = ''
Subnet mask of the interface, specified as the number of
bits in the prefix (<literal>${if v == 4 then "24" else "64"}</literal>).
'';
};
};
};
@ -141,8 +142,7 @@ let
{ address = "10.0.0.1"; prefixLength = 16; }
{ address = "192.168.1.1"; prefixLength = 24; }
];
type = types.listOf types.optionSet;
options = addrOpts 4;
type = with types; listOf (submodule (addrOpts 4));
description = ''
List of IPv4 addresses that will be statically assigned to the interface.
'';
@ -154,8 +154,7 @@ let
{ address = "fdfd:b3f0:482::1"; prefixLength = 48; }
{ address = "2001:1470:fffd:2098::e006"; prefixLength = 64; }
];
type = types.listOf types.optionSet;
options = addrOpts 6;
type = with types; listOf (submodule (addrOpts 6));
description = ''
List of IPv6 addresses that will be statically assigned to the interface.
'';
@ -415,8 +414,7 @@ in
<option>networking.useDHCP</option> is true, then every
interface not listed here will be configured using DHCP.
'';
type = types.loaOf types.optionSet;
options = [ interfaceOpts ];
type = with types; loaOf (submodule interfaceOpts);
};
networking.vswitches = mkOption {
@ -434,53 +432,55 @@ in
interface.
'';
type = types.attrsOf types.optionSet;
type = with types; attrsOf (submodule {
options = {
options = {
interfaces = mkOption {
example = [ "eth0" "eth1" ];
type = types.listOf types.str;
description =
"The physical network interfaces connected by the vSwitch.";
};
controllers = mkOption {
type = types.listOf types.str;
default = [];
example = [ "ptcp:6653:[::1]" ];
description = ''
Specify the controller targets. For the allowed options see <literal>man 8 ovs-vsctl</literal>.
'';
};
openFlowRules = mkOption {
type = types.lines;
default = "";
example = ''
actions=normal
'';
description = ''
OpenFlow rules to insert into the Open vSwitch. All <literal>openFlowRules</literal> are
loaded with <literal>ovs-ofctl</literal> within one atomic operation.
'';
};
extraOvsctlCmds = mkOption {
type = types.lines;
default = "";
example = ''
set-fail-mode <switch_name> secure
set Bridge <switch_name> stp_enable=true
'';
description = ''
Commands to manipulate the Open vSwitch database. Every line executed with <literal>ovs-vsctl</literal>.
All commands are bundled together with the operations for adding the interfaces
into one atomic operation.
'';
};
interfaces = mkOption {
example = [ "eth0" "eth1" ];
type = types.listOf types.str;
description =
"The physical network interfaces connected by the vSwitch.";
};
controllers = mkOption {
type = types.listOf types.str;
default = [];
example = [ "ptcp:6653:[::1]" ];
description = ''
Specify the controller targets. For the allowed options see <literal>man 8 ovs-vsctl</literal>.
'';
};
openFlowRules = mkOption {
type = types.lines;
default = "";
example = ''
actions=normal
'';
description = ''
OpenFlow rules to insert into the Open vSwitch. All <literal>openFlowRules</literal> are
loaded with <literal>ovs-ofctl</literal> within one atomic operation.
'';
};
extraOvsctlCmds = mkOption {
type = types.lines;
default = "";
example = ''
set-fail-mode <switch_name> secure
set Bridge <switch_name> stp_enable=true
'';
description = ''
Commands to manipulate the Open vSwitch database. Every line executed with <literal>ovs-vsctl</literal>.
All commands are bundled together with the operations for adding the interfaces
into one atomic operation.
'';
};
};
});
};
@ -499,25 +499,27 @@ in
bridge's network interface.
'';
type = types.attrsOf types.optionSet;
type = with types; attrsOf (submodule {
options = {
options = {
interfaces = mkOption {
example = [ "eth0" "eth1" ];
type = types.listOf types.str;
description =
"The physical network interfaces connected by the bridge.";
};
rstp = mkOption {
example = true;
default = false;
type = types.bool;
description = "Whether the bridge interface should enable rstp.";
};
interfaces = mkOption {
example = [ "eth0" "eth1" ];
type = types.listOf types.str;
description =
"The physical network interfaces connected by the bridge.";
};
rstp = mkOption {
example = true;
default = false;
type = types.bool;
description = "Whether the bridge interface should enable rstp.";
};
};
});
};
@ -538,65 +540,66 @@ in
name specifying the name of the bond's network interface
'';
type = types.attrsOf types.optionSet;
type = with types; attrsOf (submodule {
options = {
options = {
interfaces = mkOption {
example = [ "enp4s0f0" "enp4s0f1" "wlan0" ];
type = types.listOf types.str;
description = "The interfaces to bond together";
};
lacp_rate = mkOption {
default = null;
example = "fast";
type = types.nullOr types.str;
description = ''
Option specifying the rate in which we'll ask our link partner
to transmit LACPDU packets in 802.3ad mode.
'';
};
miimon = mkOption {
default = null;
example = 100;
type = types.nullOr types.int;
description = ''
Miimon is the number of millisecond in between each round of polling
by the device driver for failed links. By default polling is not
enabled and the driver is trusted to properly detect and handle
failure scenarios.
'';
};
mode = mkOption {
default = null;
example = "active-backup";
type = types.nullOr types.str;
description = ''
The mode which the bond will be running. The default mode for
the bonding driver is balance-rr, optimizing for throughput.
More information about valid modes can be found at
https://www.kernel.org/doc/Documentation/networking/bonding.txt
'';
};
xmit_hash_policy = mkOption {
default = null;
example = "layer2+3";
type = types.nullOr types.str;
description = ''
Selects the transmit hash policy to use for slave selection in
balance-xor, 802.3ad, and tlb modes.
'';
};
interfaces = mkOption {
example = [ "enp4s0f0" "enp4s0f1" "wlan0" ];
type = types.listOf types.str;
description = "The interfaces to bond together";
};
lacp_rate = mkOption {
default = null;
example = "fast";
type = types.nullOr types.str;
description = ''
Option specifying the rate in which we'll ask our link partner
to transmit LACPDU packets in 802.3ad mode.
'';
};
miimon = mkOption {
default = null;
example = 100;
type = types.nullOr types.int;
description = ''
Miimon is the number of millisecond in between each round of polling
by the device driver for failed links. By default polling is not
enabled and the driver is trusted to properly detect and handle
failure scenarios.
'';
};
mode = mkOption {
default = null;
example = "active-backup";
type = types.nullOr types.str;
description = ''
The mode which the bond will be running. The default mode for
the bonding driver is balance-rr, optimizing for throughput.
More information about valid modes can be found at
https://www.kernel.org/doc/Documentation/networking/bonding.txt
'';
};
xmit_hash_policy = mkOption {
default = null;
example = "layer2+3";
type = types.nullOr types.str;
description = ''
Selects the transmit hash policy to use for slave selection in
balance-xor, 802.3ad, and tlb modes.
'';
};
};
});
};
networking.macvlans = mkOption {
type = types.attrsOf types.optionSet;
default = { };
example = literalExample {
wan = {
@ -608,26 +611,28 @@ in
This option allows you to define macvlan interfaces which should
be automatically created.
'';
options = {
type = with types; attrsOf (submodule {
options = {
interface = mkOption {
example = "enp4s0";
type = types.str;
description = "The interface the macvlan will transmit packets through.";
};
mode = mkOption {
default = null;
type = types.nullOr types.str;
example = "vepa";
description = "The mode of the macvlan device.";
};
interface = mkOption {
example = "enp4s0";
type = types.str;
description = "The interface the macvlan will transmit packets through.";
};
mode = mkOption {
default = null;
type = types.nullOr types.str;
example = "vepa";
description = "The mode of the macvlan device.";
};
};
});
};
networking.sits = mkOption {
type = types.attrsOf types.optionSet;
default = { };
example = literalExample {
hurricane = {
@ -644,46 +649,49 @@ in
description = ''
This option allows you to define 6-to-4 interfaces which should be automatically created.
'';
options = {
type = with types; attrsOf (submodule {
options = {
remote = mkOption {
type = types.nullOr types.str;
default = null;
example = "10.0.0.1";
description = ''
The address of the remote endpoint to forward traffic over.
'';
};
local = mkOption {
type = types.nullOr types.str;
default = null;
example = "10.0.0.22";
description = ''
The address of the local endpoint which the remote
side should send packets to.
'';
};
ttl = mkOption {
type = types.nullOr types.int;
default = null;
example = 255;
description = ''
The time-to-live of the connection to the remote tunnel endpoint.
'';
};
dev = mkOption {
type = types.nullOr types.str;
default = null;
example = "enp4s0f0";
description = ''
The underlying network device on which the tunnel resides.
'';
};
remote = mkOption {
type = types.nullOr types.str;
default = null;
example = "10.0.0.1";
description = ''
The address of the remote endpoint to forward traffic over.
'';
};
local = mkOption {
type = types.nullOr types.str;
default = null;
example = "10.0.0.22";
description = ''
The address of the local endpoint which the remote
side should send packets to.
'';
};
ttl = mkOption {
type = types.nullOr types.int;
default = null;
example = 255;
description = ''
The time-to-live of the connection to the remote tunnel endpoint.
'';
};
dev = mkOption {
type = types.nullOr types.str;
default = null;
example = "enp4s0f0";
description = ''
The underlying network device on which the tunnel resides.
'';
};
};
});
};
networking.vlans = mkOption {
@ -706,23 +714,26 @@ in
specifying the name of the vlan interface.
'';
type = types.attrsOf types.optionSet;
type = with types; attrsOf (submodule {
options = {
options = {
id = mkOption {
example = 1;
type = types.int;
description = "The vlan identifier";
};
interface = mkOption {
example = "enp4s0";
type = types.str;
description = "The interface the vlan will transmit packets through.";
};
id = mkOption {
example = 1;
type = types.int;
description = "The vlan identifier";
};
interface = mkOption {
example = "enp4s0";
type = types.str;
description = "The interface the vlan will transmit packets through.";
};
});
};
};
networking.wlanInterfaces = mkOption {
@ -760,73 +771,76 @@ in
would have to be created explicitly.
'';
type = types.attrsOf types.optionSet;
type = with types; attrsOf (submodule {
options = {
options = {
device = mkOption {
type = types.string;
example = "wlp6s0";
description = "The name of the underlying hardware WLAN device as assigned by <literal>udev</literal>.";
};
type = mkOption {
type = types.string;
default = "managed";
example = "ibss";
description = ''
The type of the WLAN interface. The type has to be either <literal>managed</literal>,
<literal>ibss</literal>, <literal>monitor</literal>, <literal>mesh</literal> or <literal>wds</literal>.
Also, the type has to be supported by the underlying hardware of the device.
'';
};
meshID = mkOption {
type = types.nullOr types.string;
default = null;
description = "MeshID of interface with type <literal>mesh</literal>.";
};
flags = mkOption {
type = types.nullOr types.string;
default = null;
example = "control";
description = ''
Flags for interface of type <literal>monitor</literal>. The valid flags are:
none: no special flags
fcsfail: show frames with FCS errors
control: show control frames
otherbss: show frames from other BSSes
cook: use cooked mode
active: use active mode (ACK incoming unicast packets)
'';
};
fourAddr = mkOption {
type = types.nullOr types.bool;
default = null;
description = "Whether to enable <literal>4-address mode</literal> with type <literal>managed</literal>.";
};
mac = mkOption {
type = types.nullOr types.str;
default = null;
example = "02:00:00:00:00:01";
description = ''
MAC address to use for the device. If <literal>null</literal>, then the MAC of the
underlying hardware WLAN device is used.
INFO: Locally administered MAC addresses are of the form:
<itemizedlist>
<listitem><para>x2:xx:xx:xx:xx:xx</para></listitem>
<listitem><para>x6:xx:xx:xx:xx:xx</para></listitem>
<listitem><para>xA:xx:xx:xx:xx:xx</para></listitem>
<listitem><para>xE:xx:xx:xx:xx:xx</para></listitem>
</itemizedlist>
'';
};
device = mkOption {
type = types.string;
example = "wlp6s0";
description = "The name of the underlying hardware WLAN device as assigned by <literal>udev</literal>.";
};
type = mkOption {
type = types.string;
default = "managed";
example = "ibss";
description = ''
The type of the WLAN interface. The type has to be either <literal>managed</literal>,
<literal>ibss</literal>, <literal>monitor</literal>, <literal>mesh</literal> or <literal>wds</literal>.
Also, the type has to be supported by the underlying hardware of the device.
'';
};
});
meshID = mkOption {
type = types.nullOr types.string;
default = null;
description = "MeshID of interface with type <literal>mesh</literal>.";
};
flags = mkOption {
type = types.nullOr types.string;
default = null;
example = "control";
description = ''
Flags for interface of type <literal>monitor</literal>. The valid flags are:
none: no special flags
fcsfail: show frames with FCS errors
control: show control frames
otherbss: show frames from other BSSes
cook: use cooked mode
active: use active mode (ACK incoming unicast packets)
'';
};
fourAddr = mkOption {
type = types.nullOr types.bool;
default = null;
description = "Whether to enable <literal>4-address mode</literal> with type <literal>managed</literal>.";
};
mac = mkOption {
type = types.nullOr types.str;
default = null;
example = "02:00:00:00:00:01";
description = ''
MAC address to use for the device. If <literal>null</literal>, then the MAC of the
underlying hardware WLAN device is used.
INFO: Locally administered MAC addresses are of the form:
<itemizedlist>
<listitem><para>x2:xx:xx:xx:xx:xx</para></listitem>
<listitem><para>x6:xx:xx:xx:xx:xx</para></listitem>
<listitem><para>xA:xx:xx:xx:xx:xx</para></listitem>
<listitem><para>xE:xx:xx:xx:xx:xx</para></listitem>
</itemizedlist>
'';
};
};
};
networking.useDHCP = mkOption {