@@ -97,21 +97,22 @@ let
9797
9898 addrOpts = v:
9999 assert v == 4 || v == 6;
100− {
101− address = mkOption {
102− type = types.str;
103− description = ''
104− IPv${toString v} address of the interface. Leave empty to configure the
105− interface using DHCP.
106− '';
107− };
100+ { options = {
101+ address = mkOption {
102+ type = types.str;
103+ description = ''
104+ IPv${toString v} address of the interface. Leave empty to configure the
105+ interface using DHCP.
106+ '';
107+ };
108108
109− prefixLength = mkOption {
110− type = types.addCheck types.int (n: n >= 0 && n <= (if v == 4 then 32 else 128));
111− description = ''
112− Subnet mask of the interface, specified as the number of
113− bits in the prefix (<literal>${if v == 4 then "24" else "64"}</literal>).
114− '';
109+ prefixLength = mkOption {
110+ type = types.addCheck types.int (n: n >= 0 && n <= (if v == 4 then 32 else 128));
111+ description = ''
112+ Subnet mask of the interface, specified as the number of
113+ bits in the prefix (<literal>${if v == 4 then "24" else "64"}</literal>).
114+ '';
115+ };
115116 };
116117 };
117118
@@ -141,8 +142,7 @@ let
141142 { address = "10.0.0.1"; prefixLength = 16; }
142143 { address = "192.168.1.1"; prefixLength = 24; }
143144 ];
144− type = types.listOf types.optionSet;
145− options = addrOpts 4;
145+ type = with types; listOf (submodule (addrOpts 4));
146146 description = ''
147147 List of IPv4 addresses that will be statically assigned to the interface.
148148 '';
@@ -154,8 +154,7 @@ let
154154 { address = "fdfd:b3f0:482::1"; prefixLength = 48; }
155155 { address = "2001:1470:fffd:2098::e006"; prefixLength = 64; }
156156 ];
157− type = types.listOf types.optionSet;
158− options = addrOpts 6;
157+ type = with types; listOf (submodule (addrOpts 6));
159158 description = ''
160159 List of IPv6 addresses that will be statically assigned to the interface.
161160 '';
@@ -415,8 +414,7 @@ in
415414 <option>networking.useDHCP</option> is true, then every
416415 interface not listed here will be configured using DHCP.
417416 '';
418− type = types.loaOf types.optionSet;
419− options = [ interfaceOpts ];
417+ type = with types; loaOf (submodule interfaceOpts);
420418 };
421419
422420 networking.vswitches = mkOption {
@@ -434,53 +432,55 @@ in
434432 interface.
435433 '';
436434
437− type = types.attrsOf types.optionSet;
435+ type = with types; attrsOf (submodule {
438436
439− options = {
437+ options = {
440438
441− interfaces = mkOption {
442− example = [ "eth0" "eth1" ];
443− type = types.listOf types.str;
444− description =
445− "The physical network interfaces connected by the vSwitch.";
446− };
439+ interfaces = mkOption {
440+ example = [ "eth0" "eth1" ];
441+ type = types.listOf types.str;
442+ description =
443+ "The physical network interfaces connected by the vSwitch.";
444+ };
447445
448− controllers = mkOption {
449− type = types.listOf types.str;
450− default = [];
451− example = [ "ptcp:6653:[::1]" ];
452− description = ''
453− Specify the controller targets. For the allowed options see <literal>man 8 ovs-vsctl</literal>.
454− '';
455− };
446+ controllers = mkOption {
447+ type = types.listOf types.str;
448+ default = [];
449+ example = [ "ptcp:6653:[::1]" ];
450+ description = ''
451+ Specify the controller targets. For the allowed options see <literal>man 8 ovs-vsctl</literal>.
452+ '';
453+ };
456454
457− openFlowRules = mkOption {
458− type = types.lines;
459− default = "";
460− example = ''
461− actions=normal
462− '';
463− description = ''
464− OpenFlow rules to insert into the Open vSwitch. All <literal>openFlowRules</literal> are
465− loaded with <literal>ovs-ofctl</literal> within one atomic operation.
466− '';
467− };
455+ openFlowRules = mkOption {
456+ type = types.lines;
457+ default = "";
458+ example = ''
459+ actions=normal
460+ '';
461+ description = ''
462+ OpenFlow rules to insert into the Open vSwitch. All <literal>openFlowRules</literal> are
463+ loaded with <literal>ovs-ofctl</literal> within one atomic operation.
464+ '';
465+ };
466+
467+ extraOvsctlCmds = mkOption {
468+ type = types.lines;
469+ default = "";
470+ example = ''
471+ set-fail-mode <switch_name> secure
472+ set Bridge <switch_name> stp_enable=true
473+ '';
474+ description = ''
475+ Commands to manipulate the Open vSwitch database. Every line executed with <literal>ovs-vsctl</literal>.
476+ All commands are bundled together with the operations for adding the interfaces
477+ into one atomic operation.
478+ '';
479+ };
468480
469− extraOvsctlCmds = mkOption {
470− type = types.lines;
471− default = "";
472− example = ''
473− set-fail-mode <switch_name> secure
474− set Bridge <switch_name> stp_enable=true
475− '';
476− description = ''
477− Commands to manipulate the Open vSwitch database. Every line executed with <literal>ovs-vsctl</literal>.
478− All commands are bundled together with the operations for adding the interfaces
479− into one atomic operation.
480− '';
481481 };
482482
483− };
483+ });
484484
485485 };
486486
@@ -499,25 +499,27 @@ in
499499 bridge's network interface.
500500 '';
501501
502− type = types.attrsOf types.optionSet;
502+ type = with types; attrsOf (submodule {
503503
504− options = {
504+ options = {
505505
506− interfaces = mkOption {
507− example = [ "eth0" "eth1" ];
508− type = types.listOf types.str;
509− description =
510− "The physical network interfaces connected by the bridge.";
511− };
506+ interfaces = mkOption {
507+ example = [ "eth0" "eth1" ];
508+ type = types.listOf types.str;
509+ description =
510+ "The physical network interfaces connected by the bridge.";
511+ };
512+
513+ rstp = mkOption {
514+ example = true;
515+ default = false;
516+ type = types.bool;
517+ description = "Whether the bridge interface should enable rstp.";
518+ };
512519
513− rstp = mkOption {
514− example = true;
515− default = false;
516− type = types.bool;
517− description = "Whether the bridge interface should enable rstp.";
518520 };
519521
520− };
522+ });
521523
522524 };
523525
@@ -538,65 +540,66 @@ in
538540 name specifying the name of the bond's network interface
539541 '';
540542
541− type = types.attrsOf types.optionSet;
543+ type = with types; attrsOf (submodule {
542544
543− options = {
545+ options = {
544546
545− interfaces = mkOption {
546− example = [ "enp4s0f0" "enp4s0f1" "wlan0" ];
547− type = types.listOf types.str;
548− description = "The interfaces to bond together";
549− };
547+ interfaces = mkOption {
548+ example = [ "enp4s0f0" "enp4s0f1" "wlan0" ];
549+ type = types.listOf types.str;
550+ description = "The interfaces to bond together";
551+ };
550552
551− lacp_rate = mkOption {
552− default = null;
553− example = "fast";
554− type = types.nullOr types.str;
555− description = ''
556− Option specifying the rate in which we'll ask our link partner
557− to transmit LACPDU packets in 802.3ad mode.
558− '';
559− };
560−
561− miimon = mkOption {
562− default = null;
563− example = 100;
564− type = types.nullOr types.int;
565− description = ''
566− Miimon is the number of millisecond in between each round of polling
567− by the device driver for failed links. By default polling is not
568− enabled and the driver is trusted to properly detect and handle
569− failure scenarios.
570− '';
571− };
572−
573− mode = mkOption {
574− default = null;
575− example = "active-backup";
576− type = types.nullOr types.str;
577− description = ''
578− The mode which the bond will be running. The default mode for
579− the bonding driver is balance-rr, optimizing for throughput.
580− More information about valid modes can be found at
581− https://www.kernel.org/doc/Documentation/networking/bonding.txt
582− '';
583− };
553+ lacp_rate = mkOption {
554+ default = null;
555+ example = "fast";
556+ type = types.nullOr types.str;
557+ description = ''
558+ Option specifying the rate in which we'll ask our link partner
559+ to transmit LACPDU packets in 802.3ad mode.
560+ '';
561+ };
562+
563+ miimon = mkOption {
564+ default = null;
565+ example = 100;
566+ type = types.nullOr types.int;
567+ description = ''
568+ Miimon is the number of millisecond in between each round of polling
569+ by the device driver for failed links. By default polling is not
570+ enabled and the driver is trusted to properly detect and handle
571+ failure scenarios.
572+ '';
573+ };
574+
575+ mode = mkOption {
576+ default = null;
577+ example = "active-backup";
578+ type = types.nullOr types.str;
579+ description = ''
580+ The mode which the bond will be running. The default mode for
581+ the bonding driver is balance-rr, optimizing for throughput.
582+ More information about valid modes can be found at
583+ https://www.kernel.org/doc/Documentation/networking/bonding.txt
584+ '';
585+ };
586+
587+ xmit_hash_policy = mkOption {
588+ default = null;
589+ example = "layer2+3";
590+ type = types.nullOr types.str;
591+ description = ''
592+ Selects the transmit hash policy to use for slave selection in
593+ balance-xor, 802.3ad, and tlb modes.
594+ '';
595+ };
584596
585− xmit_hash_policy = mkOption {
586− default = null;
587− example = "layer2+3";
588− type = types.nullOr types.str;
589− description = ''
590− Selects the transmit hash policy to use for slave selection in
591− balance-xor, 802.3ad, and tlb modes.
592− '';
593597 };
594598
595− };
599+ });
596600 };
597601
598602 networking.macvlans = mkOption {
599− type = types.attrsOf types.optionSet;
600603 default = { };
601604 example = literalExample {
602605 wan = {
@@ -608,26 +611,28 @@ in
608611 This option allows you to define macvlan interfaces which should
609612 be automatically created.
610613 '';
611− options = {
614+ type = with types; attrsOf (submodule {
615+ options = {
616+
617+ interface = mkOption {
618+ example = "enp4s0";
619+ type = types.str;
620+ description = "The interface the macvlan will transmit packets through.";
621+ };
622+
623+ mode = mkOption {
624+ default = null;
625+ type = types.nullOr types.str;
626+ example = "vepa";
627+ description = "The mode of the macvlan device.";
628+ };
612629
613− interface = mkOption {
614− example = "enp4s0";
615− type = types.str;
616− description = "The interface the macvlan will transmit packets through.";
617630 };
618631
619− mode = mkOption {
620− default = null;
621− type = types.nullOr types.str;
622− example = "vepa";
623− description = "The mode of the macvlan device.";
624− };
625−
626− };
632+ });
627633 };
628634
629635 networking.sits = mkOption {
630− type = types.attrsOf types.optionSet;
631636 default = { };
632637 example = literalExample {
633638 hurricane = {
@@ -644,46 +649,49 @@ in
644649 description = ''
645650 This option allows you to define 6-to-4 interfaces which should be automatically created.
646651 '';
647− options = {
648−
649− remote = mkOption {
650− type = types.nullOr types.str;
651− default = null;
652− example = "10.0.0.1";
653− description = ''
654− The address of the remote endpoint to forward traffic over.
655− '';
656− };
657−
658− local = mkOption {
659− type = types.nullOr types.str;
660− default = null;
661− example = "10.0.0.22";
662− description = ''
663− The address of the local endpoint which the remote
664− side should send packets to.
665− '';
666− };
667−
668− ttl = mkOption {
669− type = types.nullOr types.int;
670− default = null;
671− example = 255;
672− description = ''
673− The time-to-live of the connection to the remote tunnel endpoint.
674− '';
675− };
652+ type = with types; attrsOf (submodule {
653+ options = {
654+
655+ remote = mkOption {
656+ type = types.nullOr types.str;
657+ default = null;
658+ example = "10.0.0.1";
659+ description = ''
660+ The address of the remote endpoint to forward traffic over.
661+ '';
662+ };
663+
664+ local = mkOption {
665+ type = types.nullOr types.str;
666+ default = null;
667+ example = "10.0.0.22";
668+ description = ''
669+ The address of the local endpoint which the remote
670+ side should send packets to.
671+ '';
672+ };
673+
674+ ttl = mkOption {
675+ type = types.nullOr types.int;
676+ default = null;
677+ example = 255;
678+ description = ''
679+ The time-to-live of the connection to the remote tunnel endpoint.
680+ '';
681+ };
682+
683+ dev = mkOption {
684+ type = types.nullOr types.str;
685+ default = null;
686+ example = "enp4s0f0";
687+ description = ''
688+ The underlying network device on which the tunnel resides.
689+ '';
690+ };
676691
677− dev = mkOption {
678− type = types.nullOr types.str;
679− default = null;
680− example = "enp4s0f0";
681− description = ''
682− The underlying network device on which the tunnel resides.
683− '';
684692 };
685693
686− };
694+ });
687695 };
688696
689697 networking.vlans = mkOption {
@@ -706,23 +714,26 @@ in
706714 specifying the name of the vlan interface.
707715 '';
708716
709− type = types.attrsOf types.optionSet;
717+ type = with types; attrsOf (submodule {
710718
711− options = {
719+ options = {
712720
713− id = mkOption {
714− example = 1;
715− type = types.int;
716− description = "The vlan identifier";
717− };
721+ id = mkOption {
722+ example = 1;
723+ type = types.int;
724+ description = "The vlan identifier";
725+ };
726+
727+ interface = mkOption {
728+ example = "enp4s0";
729+ type = types.str;
730+ description = "The interface the vlan will transmit packets through.";
731+ };
718732
719− interface = mkOption {
720− example = "enp4s0";
721− type = types.str;
722− description = "The interface the vlan will transmit packets through.";
723733 };
724734
725− };
735+ });
736+
726737 };
727738
728739 networking.wlanInterfaces = mkOption {
@@ -760,73 +771,76 @@ in
760771 would have to be created explicitly.
761772 '';
762773
763− type = types.attrsOf types.optionSet;
764−
765− options = {
774+ type = with types; attrsOf (submodule {
766775
767− device = mkOption {
768− type = types.string;
769− example = "wlp6s0";
770− description = "The name of the underlying hardware WLAN device as assigned by <literal>udev</literal>.";
771− };
776+ options = {
772777
773− type = mkOption {
774− type = types.string;
775− default = "managed";
776− example = "ibss";
777− description = ''
778− The type of the WLAN interface. The type has to be either <literal>managed</literal>,
779− <literal>ibss</literal>, <literal>monitor</literal>, <literal>mesh</literal> or <literal>wds</literal>.
780− Also, the type has to be supported by the underlying hardware of the device.
781− '';
782− };
778+ device = mkOption {
779+ type = types.string;
780+ example = "wlp6s0";
781+ description = "The name of the underlying hardware WLAN device as assigned by <literal>udev</literal>.";
782+ };
783783
784− meshID = mkOption {
785− type = types.nullOr types.string;
786− default = null;
787− description = "MeshID of interface with type <literal>mesh</literal>.";
788− };
789−
790− flags = mkOption {
791− type = types.nullOr types.string;
792− default = null;
793− example = "control";
794− description = ''
795− Flags for interface of type <literal>monitor</literal>. The valid flags are:
796− none: no special flags
797− fcsfail: show frames with FCS errors
798− control: show control frames
799− otherbss: show frames from other BSSes
800− cook: use cooked mode
801− active: use active mode (ACK incoming unicast packets)
802− '';
803− };
784+ type = mkOption {
785+ type = types.string;
786+ default = "managed";
787+ example = "ibss";
788+ description = ''
789+ The type of the WLAN interface. The type has to be either <literal>managed</literal>,
790+ <literal>ibss</literal>, <literal>monitor</literal>, <literal>mesh</literal> or <literal>wds</literal>.
791+ Also, the type has to be supported by the underlying hardware of the device.
792+ '';
793+ };
794+
795+ meshID = mkOption {
796+ type = types.nullOr types.string;
797+ default = null;
798+ description = "MeshID of interface with type <literal>mesh</literal>.";
799+ };
800+
801+ flags = mkOption {
802+ type = types.nullOr types.string;
803+ default = null;
804+ example = "control";
805+ description = ''
806+ Flags for interface of type <literal>monitor</literal>. The valid flags are:
807+ none: no special flags
808+ fcsfail: show frames with FCS errors
809+ control: show control frames
810+ otherbss: show frames from other BSSes
811+ cook: use cooked mode
812+ active: use active mode (ACK incoming unicast packets)
813+ '';
814+ };
815+
816+ fourAddr = mkOption {
817+ type = types.nullOr types.bool;
818+ default = null;
819+ description = "Whether to enable <literal>4-address mode</literal> with type <literal>managed</literal>.";
820+ };
821+
822+ mac = mkOption {
823+ type = types.nullOr types.str;
824+ default = null;
825+ example = "02:00:00:00:00:01";
826+ description = ''
827+ MAC address to use for the device. If <literal>null</literal>, then the MAC of the
828+ underlying hardware WLAN device is used.
829+
830+ INFO: Locally administered MAC addresses are of the form:
831+ <itemizedlist>
832+ <listitem><para>x2:xx:xx:xx:xx:xx</para></listitem>
833+ <listitem><para>x6:xx:xx:xx:xx:xx</para></listitem>
834+ <listitem><para>xA:xx:xx:xx:xx:xx</para></listitem>
835+ <listitem><para>xE:xx:xx:xx:xx:xx</para></listitem>
836+ </itemizedlist>
837+ '';
838+ };
804839
805− fourAddr = mkOption {
806− type = types.nullOr types.bool;
807− default = null;
808− description = "Whether to enable <literal>4-address mode</literal> with type <literal>managed</literal>.";
809840 };
810841
811− mac = mkOption {
812− type = types.nullOr types.str;
813− default = null;
814− example = "02:00:00:00:00:01";
815− description = ''
816− MAC address to use for the device. If <literal>null</literal>, then the MAC of the
817− underlying hardware WLAN device is used.
818−
819− INFO: Locally administered MAC addresses are of the form:
820− <itemizedlist>
821− <listitem><para>x2:xx:xx:xx:xx:xx</para></listitem>
822− <listitem><para>x6:xx:xx:xx:xx:xx</para></listitem>
823− <listitem><para>xA:xx:xx:xx:xx:xx</para></listitem>
824− <listitem><para>xE:xx:xx:xx:xx:xx</para></listitem>
825− </itemizedlist>
826− '';
827− };
842+ });
828843
829− };
830844 };
831845
832846 networking.useDHCP = mkOption {