1 { config, lib, pkgs, utils, ... }:
3 with utils.systemdUtils.unitOptions;
4 with utils.systemdUtils.lib;
5 with utils.systemdUtils.network.units;
13 sectionNetwork = checkUnitConfig "Network" [
16 "SpeedMeterIntervalSec"
17 "ManageForeignRoutingPolicyRules"
21 (assertValueOneOf "SpeedMeter" boolValues)
22 (assertInt "SpeedMeterIntervalSec")
23 (assertValueOneOf "ManageForeignRoutingPolicyRules" boolValues)
24 (assertValueOneOf "ManageForeignRoutes" boolValues)
27 sectionDHCPv4 = checkUnitConfig "DHCPv4" [
33 (assertValueOneOf "ClientIdentifier" ["mac" "duid" "duid-only"])
36 sectionDHCPv6 = checkUnitConfig "DHCPv6" [
46 sectionLink = checkUnitConfig "Link" [
54 "AlternativeNamesPolicy"
63 "ReceiveChecksumOffload"
64 "TransmitChecksumOffload"
65 "TCPSegmentationOffload"
66 "TCP6SegmentationOffload"
67 "GenericSegmentationOffload"
68 "GenericReceiveOffload"
80 (assertValueOneOf "MACAddressPolicy" ["persistent" "random" "none"])
81 (assertMacAddress "MACAddress")
82 (assertByteFormat "MTUBytes")
83 (assertByteFormat "BitsPerSecond")
84 (assertValueOneOf "Duplex" ["half" "full"])
85 (assertValueOneOf "AutoNegotiation" boolValues)
86 (assertValuesSomeOfOr "WakeOnLan" ["phy" "unicast" "multicast" "broadcast" "arp" "magic" "secureon"] "off")
87 (assertValueOneOf "Port" ["tp" "aui" "bnc" "mii" "fibre"])
88 (assertValueOneOf "ReceiveChecksumOffload" boolValues)
89 (assertValueOneOf "TransmitChecksumOffload" boolValues)
90 (assertValueOneOf "TCPSegmentationOffload" boolValues)
91 (assertValueOneOf "TCP6SegmentationOffload" boolValues)
92 (assertValueOneOf "GenericSegmentationOffload" boolValues)
93 (assertValueOneOf "GenericReceiveOffload" boolValues)
94 (assertValueOneOf "LargeReceiveOffload" boolValues)
95 (assertInt "RxChannels")
96 (assertRange "RxChannels" 1 4294967295)
97 (assertInt "TxChannels")
98 (assertRange "TxChannels" 1 4294967295)
99 (assertInt "OtherChannels")
100 (assertRange "OtherChannels" 1 4294967295)
101 (assertInt "CombinedChannels")
102 (assertRange "CombinedChannels" 1 4294967295)
103 (assertInt "RxBufferSize")
104 (assertInt "TxBufferSize")
105 (assertRange "ReceiveQueues" 1 4096)
106 (assertRange "TransmitQueues" 1 4096)
107 (assertRange "TransmitQueueLength" 1 4294967294)
121 (assertValueOneOf "MultiQueue" boolValues)
122 (assertValueOneOf "PacketInfo" boolValues)
123 (assertValueOneOf "VNetHeader" boolValues)
126 # See https://www.freedesktop.org/software/systemd/man/latest/systemd.netdev.html#%5BIPVTAP%5D%20Section%20Options
132 (assertValueOneOf "Mode" ["L2" "L3" "L3S" ])
133 (assertValueOneOf "Flags" ["private" "vepa" "bridge" ])
137 sectionNetdev = checkUnitConfig "Netdev" [
145 (assertHasField "Name")
146 (assertHasField "Kind")
147 (assertValueOneOf "Kind" [
185 (assertByteFormat "MTUBytes")
186 (assertNetdevMacAddress "MACAddress")
189 sectionVLAN = checkUnitConfig "VLAN" [
198 (assertRange "Id" 0 4094)
199 (assertValueOneOf "GVRP" boolValues)
200 (assertValueOneOf "MVRP" boolValues)
201 (assertValueOneOf "LooseBinding" boolValues)
202 (assertValueOneOf "ReorderHeader" boolValues)
205 sectionIPVLAN = checkUnitConfig "IPVLAN" ipVlanVtapChecks;
207 sectionIPVTAP = checkUnitConfig "IPVTAP" ipVlanVtapChecks;
209 sectionMACVLAN = checkUnitConfig "MACVLAN" [
213 (assertValueOneOf "Mode" ["private" "vepa" "bridge" "passthru"])
216 sectionVXLAN = checkUnitConfig "VXLAN" [
236 "GroupPolicyExtension"
237 "GenericProtocolExtension"
245 (assertRange "VNI" 1 16777215)
246 (assertValueOneOf "MacLearning" boolValues)
247 (assertInt "MaximumFDBEntries")
248 (assertValueOneOf "ReduceARPProxy" boolValues)
249 (assertValueOneOf "L2MissNotification" boolValues)
250 (assertValueOneOf "L3MissNotification" boolValues)
251 (assertValueOneOf "RouteShortCircuit" boolValues)
252 (assertValueOneOf "UDPChecksum" boolValues)
253 (assertValueOneOf "UDP6ZeroChecksumTx" boolValues)
254 (assertValueOneOf "UDP6ZeroChecksumRx" boolValues)
255 (assertValueOneOf "RemoteChecksumTx" boolValues)
256 (assertValueOneOf "RemoteChecksumRx" boolValues)
257 (assertValueOneOf "GroupPolicyExtension" boolValues)
258 (assertValueOneOf "GenericProtocolExtension" boolValues)
259 (assertInt "FlowLabel")
260 (assertRange "FlowLabel" 0 1048575)
261 (assertValueOneOf "IPDoNotFragment" (boolValues + ["inherit"]))
262 (assertValueOneOf "Independent" boolValues)
265 sectionTunnel = checkUnitConfig "Tunnel" [
286 "IPv6RapidDeploymentPrefix"
288 "SerializeTunneledPackets"
292 (assertRange "TTL" 0 255)
293 (assertValueOneOf "DiscoverPathMTU" boolValues)
294 (assertValueOneOf "CopyDSCP" boolValues)
295 (assertValueOneOf "Mode" ["ip6ip6" "ipip6" "any"])
296 (assertValueOneOf "Independent" boolValues)
297 (assertValueOneOf "AssignToLoopback" boolValues)
298 (assertValueOneOf "AllowLocalRemote" boolValues)
299 (assertValueOneOf "FooOverUDP" boolValues)
300 (assertPort "FOUDestinationPort")
301 (assertPort "FOUSourcePort")
302 (assertValueOneOf "Encapsulation" ["FooOverUDP" "GenericUDPEncapsulation"])
303 (assertValueOneOf "ISATAP" boolValues)
304 (assertValueOneOf "SerializeTunneledPackets" boolValues)
305 (assertInt "ERSPANIndex")
306 (assertRange "ERSPANIndex" 1 1048575)
309 sectionFooOverUDP = checkUnitConfig "FooOverUDP" [
316 (assertValueOneOf "Encapsulation" ["FooOverUDP" "GenericUDPEncapsulation"])
319 sectionPeer = checkUnitConfig "Peer" [
324 (assertMacAddress "MACAddress")
327 sectionTun = checkUnitConfig "Tun" tunChecks;
329 sectionTap = checkUnitConfig "Tap" tunChecks;
331 sectionL2TP = checkUnitConfig "L2TP" [
344 (assertInt "TunnelId")
345 (assertRange "TunnelId" 1 4294967295)
346 (assertInt "PeerTunnelId")
347 (assertRange "PeerTunnelId" 1 4294967295)
348 (assertValueOneOf "EncapsulationType" [ "ip" "udp" ])
349 (assertPort "UDPSourcePort")
350 (assertPort "UDPDestinationPort")
351 (assertValueOneOf "UDPChecksum" boolValues)
352 (assertValueOneOf "UDP6ZeroChecksumTx" boolValues)
353 (assertValueOneOf "UDP6ZeroChecksumRx" boolValues)
356 sectionL2TPSession = checkUnitConfig "L2TPSession" [
361 "Layer2SpecificHeader"
363 (assertHasField "Name")
364 (assertHasField "SessionId")
365 (assertInt "SessionId")
366 (assertRange "SessionId" 1 4294967295)
367 (assertHasField "PeerSessionId")
368 (assertInt "PeerSessionId")
369 (assertRange "PeerSessionId" 1 4294967295)
370 (assertValueOneOf "Layer2SpecificHeader" [ "none" "default" ])
373 # NOTE The PrivateKey directive is missing on purpose here, please
374 # do not add it to this list. The nix store is world-readable let's
375 # refrain ourselves from providing a footgun.
376 sectionWireGuard = checkUnitConfig "WireGuard" [
384 (assertInt "FirewallMark")
385 (assertRange "FirewallMark" 1 4294967295)
388 # NOTE The PresharedKey directive is missing on purpose here, please
389 # do not add it to this list. The nix store is world-readable,let's
390 # refrain ourselves from providing a footgun.
391 sectionWireGuardPeer = checkUnitConfig "WireGuardPeer" [
397 "PersistentKeepalive"
401 (assertInt "PersistentKeepalive")
402 (assertRange "PersistentKeepalive" 0 65535)
405 sectionBond = checkUnitConfig "Bond" [
413 "LearnPacketIntervalSec"
415 "AdActorSystemPriority"
423 "PrimaryReselectPolicy"
428 "DynamicTransmitLoadBalancing"
431 (assertValueOneOf "Mode" [
440 (assertValueOneOf "TransmitHashPolicy" [
447 (assertValueOneOf "LACPTransmitRate" ["slow" "fast"])
448 (assertValueOneOf "AdSelect" ["stable" "bandwidth" "count"])
449 (assertInt "AdActorSystemPriority")
450 (assertRange "AdActorSystemPriority" 1 65535)
451 (assertInt "AdUserPortKey")
452 (assertRange "AdUserPortKey" 0 1023)
453 (assertValueOneOf "FailOverMACPolicy" ["none" "active" "follow"])
454 (assertValueOneOf "ARPValidate" ["none" "active" "backup" "all"])
455 (assertValueOneOf "ARPAllTargets" ["any" "all"])
456 (assertValueOneOf "PrimaryReselectPolicy" ["always" "better" "failure"])
457 (assertInt "ResendIGMP")
458 (assertRange "ResendIGMP" 0 255)
459 (assertInt "PacketsPerSlave")
460 (assertRange "PacketsPerSlave" 0 65535)
461 (assertInt "GratuitousARP")
462 (assertRange "GratuitousARP" 0 255)
463 (assertValueOneOf "AllSlavesActive" boolValues)
464 (assertValueOneOf "DynamicTransmitLoadBalancing" boolValues)
465 (assertInt "MinLinks")
466 (assertMinimum "MinLinks" 0)
469 sectionXfrm = checkUnitConfig "Xfrm" [
474 (assertInt "InterfaceId")
475 (assertRange "InterfaceId" 1 4294967295)
476 (assertValueOneOf "Independent" boolValues)
479 sectionVRF = checkUnitConfig "VRF" [
484 (assertMinimum "Table" 0)
487 sectionWLAN = checkUnitConfig "WLAN" [
489 "PhysicalDevice" # systemd supports both strings ("phy0") and indexes (0) here.
493 # See https://github.com/systemd/systemd/blob/main/src/basic/linux/nl80211.h#L3382
494 (assertValueOneOf "Type" [
508 (assertValueOneOf "WDS" boolValues)
511 sectionBatmanAdvanced = checkUnitConfig "BatmanAdvanced" [
515 "BridgeLoopAvoidance"
516 "DistributedArpTable"
519 "OriginatorIntervalSec"
520 "GatewayBandwithDown"
524 (assertValueOneOf "GatewayMode" ["off" "client" "server"])
525 (assertValueOneOf "Aggregation" boolValues)
526 (assertValueOneOf "BridgeLoopAvoidance" boolValues)
527 (assertValueOneOf "DistributedArpTable" boolValues)
528 (assertValueOneOf "Fragmentation" boolValues)
529 (assertInt "HopPenalty")
530 (assertRange "HopPenalty" 0 255)
531 (assertValueOneOf "RoutingAlgorithm" ["batman-v" "batman-iv"])
537 sectionLink = checkUnitConfig "Link" [
547 "RequiredFamilyForOnline"
551 (assertMacAddress "MACAddress")
552 (assertByteFormat "MTUBytes")
553 (assertValueOneOf "ARP" boolValues)
554 (assertValueOneOf "Multicast" boolValues)
555 (assertValueOneOf "AllMulticast" boolValues)
556 (assertValueOneOf "Promiscuous" boolValues)
557 (assertValueOneOf "Unmanaged" boolValues)
559 (assertRange "Group" 0 2147483647)
560 (assertValueOneOf "RequiredForOnline" (boolValues ++ (
562 # https://freedesktop.org/software/systemd/man/networkctl.html#missing
563 operationalStates = [
574 operationalStateRanges = concatLists (imap0 (i: min: map (max: "${min}:${max}") (drop i operationalStates)) operationalStates);
576 operationalStates ++ operationalStateRanges
578 (assertValueOneOf "RequiredFamilyForOnline" [
584 (assertValueOneOf "ActivationPolicy" ([
594 sectionNetwork = checkUnitConfig "Network" [
599 "LinkLocalAddressing"
601 "DefaultRouteOnDevice"
606 "DNSSECNegativeTrustAnchors"
618 "IPv6PrivacyExtensions"
620 "IPv6DuplicateAddressDetection"
624 "IPv6ProxyNDPAddress"
626 "DHCPPrefixDelegation"
641 "ConfigureWithoutCarrier"
647 # Note: For DHCP the values both, none, v4, v6 are deprecated
648 (assertValueOneOf "DHCP" ["yes" "no" "ipv4" "ipv6"])
649 (assertValueOneOf "DHCPServer" boolValues)
650 (assertValueOneOf "LinkLocalAddressing" ["yes" "no" "ipv4" "ipv6" "fallback" "ipv4-fallback"])
651 (assertValueOneOf "IPv4LLRoute" boolValues)
652 (assertValueOneOf "DefaultRouteOnDevice" boolValues)
653 (assertValueOneOf "LLMNR" (boolValues ++ ["resolve"]))
654 (assertValueOneOf "MulticastDNS" (boolValues ++ ["resolve"]))
655 (assertValueOneOf "DNSOverTLS" (boolValues ++ ["opportunistic"]))
656 (assertValueOneOf "DNSSEC" (boolValues ++ ["allow-downgrade"]))
657 (assertValueOneOf "LLDP" (boolValues ++ ["routers-only"]))
658 (assertValueOneOf "EmitLLDP" (boolValues ++ ["nearest-bridge" "non-tpmr-bridge" "customer-bridge"]))
659 (assertValueOneOf "DNSDefaultRoute" boolValues)
660 (assertValueOneOf "IPForward" (boolValues ++ ["ipv4" "ipv6"]))
661 (assertValueOneOf "IPMasquerade" (boolValues ++ ["ipv4" "ipv6" "both"]))
662 (assertValueOneOf "IPv6PrivacyExtensions" (boolValues ++ ["prefer-public" "kernel"]))
663 (assertValueOneOf "IPv6AcceptRA" boolValues)
664 (assertInt "IPv6DuplicateAddressDetection")
665 (assertMinimum "IPv6DuplicateAddressDetection" 0)
666 (assertInt "IPv6HopLimit")
667 (assertMinimum "IPv6HopLimit" 0)
668 (assertValueOneOf "IPv4ProxyARP" boolValues)
669 (assertValueOneOf "IPv6ProxyNDP" boolValues)
670 (assertValueOneOf "IPv6SendRA" boolValues)
671 (assertValueOneOf "DHCPPrefixDelegation" boolValues)
672 (assertByteFormat "IPv6MTUBytes")
673 (assertValueOneOf "ActiveSlave" boolValues)
674 (assertValueOneOf "PrimarySlave" boolValues)
675 (assertValueOneOf "ConfigureWithoutCarrier" boolValues)
676 (assertValueOneOf "KeepConfiguration" (boolValues ++ ["static" "dhcp-on-stop" "dhcp"]))
679 sectionAddress = checkUnitConfig "Address" [
689 "DuplicateAddressDetection"
690 "ManageTemporaryAddress"
694 (assertHasField "Address")
695 (assertValueOneOf "PreferredLifetime" ["forever" "infinity" "0" 0])
696 (assertInt "RouteMetric")
697 (assertValueOneOf "HomeAddress" boolValues)
698 (assertValueOneOf "DuplicateAddressDetection" ["ipv4" "ipv6" "both" "none"])
699 (assertValueOneOf "ManageTemporaryAddress" boolValues)
700 (assertValueOneOf "AddPrefixRoute" boolValues)
701 (assertValueOneOf "AutoJoin" boolValues)
704 sectionRoutingPolicyRule = checkUnitConfig "RoutingPolicyRule" [
720 "SuppressPrefixLength"
722 "SuppressInterfaceGroup"
724 (assertInt "TypeOfService")
725 (assertRange "TypeOfService" 0 255)
726 (assertInt "FirewallMark")
727 (assertRange "FirewallMark" 1 4294967295)
728 (assertInt "Priority")
729 (assertPort "SourcePort")
730 (assertPort "DestinationPort")
731 (assertValueOneOf "InvertRule" boolValues)
732 (assertValueOneOf "Family" ["ipv4" "ipv6" "both"])
733 (assertInt "SuppressPrefixLength")
734 (assertRange "SuppressPrefixLength" 0 128)
735 (assertValueOneOf "Type" ["blackhole" "unreachable" "prohibit"])
736 (assertRange "SuppressInterfaceGroup" 0 2147483647)
739 sectionRoute = checkUnitConfig "Route" [
752 "InitialCongestionWindow"
753 "InitialAdvertisedReceiveWindow"
761 (assertValueOneOf "GatewayOnLink" boolValues)
763 (assertValueOneOf "IPv6Preference" ["low" "medium" "high"])
764 (assertValueOneOf "Scope" ["global" "site" "link" "host" "nowhere"])
765 (assertValueOneOf "Type" [
778 (assertValueOneOf "QuickAck" boolValues)
779 (assertValueOneOf "FastOpenNoCookie" boolValues)
780 (assertValueOneOf "TTLPropagate" boolValues)
781 (assertByteFormat "MTUBytes")
782 (assertValueOneOf "IPServiceType" ["CS6" "CS4"])
785 sectionDHCPv4 = checkUnitConfig "DHCPv4" [
800 "VendorClassIdentifier"
816 "FallbackLeaseLifetimeSec"
820 (assertValueOneOf "UseDNS" boolValues)
821 (assertValueOneOf "RoutesToDNS" boolValues)
822 (assertValueOneOf "UseNTP" boolValues)
823 (assertValueOneOf "UseSIP" boolValues)
824 (assertValueOneOf "UseMTU" boolValues)
825 (assertValueOneOf "Anonymize" boolValues)
826 (assertValueOneOf "SendHostname" boolValues)
827 (assertValueOneOf "UseHostname" boolValues)
828 (assertValueOneOf "UseDomains" (boolValues ++ ["route"]))
829 (assertValueOneOf "UseRoutes" boolValues)
830 (assertValueOneOf "UseTimezone" boolValues)
831 (assertValueOneOf "ClientIdentifier" ["mac" "duid" "duid-only"])
833 (assertValueOneOf "RequestBroadcast" boolValues)
834 (assertInt "RouteMetric")
835 (assertInt "RouteTable")
836 (assertRange "RouteTable" 0 4294967295)
837 (assertByteFormat "RouteMTUBytes")
838 (assertPort "ListenPort")
839 (assertValueOneOf "SendRelease" boolValues)
840 (assertValueOneOf "SendDecline" boolValues)
841 (assertValueOneOf "FallbackLeaseLifetimeSec" ["forever" "infinity"])
842 (assertValueOneOf "Use6RD" boolValues)
845 sectionDHCPv6 = checkUnitConfig "DHCPv6" [
857 "PrefixDelegationHint"
868 (assertValueOneOf "UseAddress" boolValues)
869 (assertValueOneOf "UseDNS" boolValues)
870 (assertValueOneOf "UseNTP" boolValues)
871 (assertValueOneOf "UseHostname" boolValues)
872 (assertValueOneOf "UseDomains" (boolValues ++ ["route"]))
873 (assertInt "RouteMetric")
874 (assertValueOneOf "RapidCommit" boolValues)
875 (assertValueOneOf "WithoutRA" ["no" "solicit" "information-request"])
876 (assertRange "SendOption" 1 65536)
878 (assertValueOneOf "UseDelegatedPrefix" boolValues)
879 (assertValueOneOf "SendRelease" boolValues)
882 sectionDHCPPrefixDelegation = checkUnitConfig "DHCPPrefixDelegation" [
889 "ManageTemporaryAddress"
892 (assertValueOneOf "Announce" boolValues)
893 (assertValueOneOf "Assign" boolValues)
894 (assertValueOneOf "ManageTemporaryAddress" boolValues)
895 (assertRange "RouteMetric" 0 4294967295)
898 sectionIPv6AcceptRA = checkUnitConfig "IPv6AcceptRA" [
903 "UseAutonomousPrefix"
918 (assertValueOneOf "UseDNS" boolValues)
919 (assertValueOneOf "UseDomains" (boolValues ++ ["route"]))
920 (assertRange "RouteTable" 0 4294967295)
921 (assertValueOneOf "UseAutonomousPrefix" boolValues)
922 (assertValueOneOf "UseOnLinkPrefix" boolValues)
923 (assertValueOneOf "DHCPv6Client" (boolValues ++ ["always"]))
924 (assertValueOneOf "UseMTU" boolValues)
925 (assertValueOneOf "UseGateway" boolValues)
926 (assertValueOneOf "UseRoutePrefix" boolValues)
929 sectionDHCPServer = checkUnitConfig "DHCPServer" [
934 "DefaultLeaseTimeSec"
957 "RelayAgentCircuitId"
963 (assertInt "PoolOffset")
964 (assertMinimum "PoolOffset" 0)
965 (assertInt "PoolSize")
966 (assertMinimum "PoolSize" 0)
967 (assertValueOneOf "EmitDNS" boolValues)
968 (assertValueOneOf "EmitNTP" boolValues)
969 (assertValueOneOf "EmitSIP" boolValues)
970 (assertValueOneOf "EmitPOP3" boolValues)
971 (assertValueOneOf "EmitSMTP" boolValues)
972 (assertValueOneOf "EmitLPR" boolValues)
973 (assertValueOneOf "EmitRouter" boolValues)
974 (assertValueOneOf "EmitTimezone" boolValues)
975 (assertValueOneOf "BindToInterface" boolValues)
978 sectionIPv6SendRA = checkUnitConfig "IPv6SendRA" [
991 (assertValueOneOf "Managed" boolValues)
992 (assertValueOneOf "OtherInformation" boolValues)
993 (assertValueOneOf "RouterPreference" ["high" "medium" "low" "normal" "default"])
994 (assertValueOneOf "EmitDNS" boolValues)
995 (assertValueOneOf "EmitDomains" boolValues)
998 sectionIPv6Prefix = checkUnitConfig "IPv6Prefix" [
1000 "AddressAutoconfiguration"
1003 "PreferredLifetimeSec"
1008 (assertValueOneOf "AddressAutoconfiguration" boolValues)
1009 (assertValueOneOf "OnLink" boolValues)
1010 (assertValueOneOf "Assign" boolValues)
1013 sectionIPv6RoutePrefix = checkUnitConfig "IPv6RoutePrefix" [
1018 (assertHasField "Route")
1019 (assertInt "LifetimeSec")
1022 sectionDHCPServerStaticLease = checkUnitConfig "DHCPServerStaticLease" [
1027 (assertHasField "MACAddress")
1028 (assertHasField "Address")
1029 (assertMacAddress "MACAddress")
1032 sectionBridge = checkUnitConfig "Bridge" [
1036 "MulticastToUnicast"
1037 "NeighborSuppression"
1050 (assertValueOneOf "UnicastFlood" boolValues)
1051 (assertValueOneOf "MulticastFlood" boolValues)
1052 (assertValueOneOf "MulticastToUnicast" boolValues)
1053 (assertValueOneOf "NeighborSuppression" boolValues)
1054 (assertValueOneOf "Learning" boolValues)
1055 (assertValueOneOf "HairPin" boolValues)
1056 (assertValueOneOf "Isolated" boolValues)
1057 (assertValueOneOf "UseBPDU" boolValues)
1058 (assertValueOneOf "FastLeave" boolValues)
1059 (assertValueOneOf "AllowPortToBeRoot" boolValues)
1060 (assertValueOneOf "ProxyARP" boolValues)
1061 (assertValueOneOf "ProxyARPWiFi" boolValues)
1062 (assertValueOneOf "MulticastRouter" [ "no" "query" "permanent" "temporary" ])
1064 (assertRange "Cost" 1 65535)
1065 (assertInt "Priority")
1066 (assertRange "Priority" 0 63)
1069 sectionBridgeFDB = checkUnitConfig "BridgeFDB" [
1078 (assertHasField "MACAddress")
1079 (assertInt "VLANId")
1080 (assertRange "VLANId" 0 4094)
1082 (assertRange "VNI" 1 16777215)
1083 (assertValueOneOf "AssociatedWith" [ "use" "self" "master" "router" ])
1086 sectionBridgeMDB = checkUnitConfig "BridgeMDB" [
1088 "MulticastGroupAddress"
1091 (assertHasField "MulticastGroupAddress")
1092 (assertInt "VLANId")
1093 (assertRange "VLANId" 0 4094)
1096 sectionLLDP = checkUnitConfig "LLDP" [
1102 sectionCAN = checkUnitConfig "CAN" [
1107 "PropagationSegment"
1108 "PhaseBufferSegment1"
1109 "PhaseBufferSegment2"
1113 "DataTimeQuantaNSec"
1114 "DataPropagationSegment"
1115 "DataPhaseBufferSegment1"
1116 "DataPhaseBufferSegment2"
1128 "ClassicDataLengthCode"
1130 (assertInt "TimeQuantaNSec" )
1131 (assertRange "TimeQuantaNSec" 0 4294967295 )
1132 (assertInt "PropagationSegment" )
1133 (assertRange "PropagationSegment" 0 4294967295 )
1134 (assertInt "PhaseBufferSegment1" )
1135 (assertRange "PhaseBufferSegment1" 0 4294967295 )
1136 (assertInt "PhaseBufferSegment2" )
1137 (assertRange "PhaseBufferSegment2" 0 4294967295 )
1138 (assertInt "SyncJumpWidth" )
1139 (assertRange "SyncJumpWidth" 0 4294967295 )
1140 (assertInt "DataTimeQuantaNSec" )
1141 (assertRange "DataTimeQuantaNSec" 0 4294967295 )
1142 (assertInt "DataPropagationSegment" )
1143 (assertRange "DataPropagationSegment" 0 4294967295 )
1144 (assertInt "DataPhaseBufferSegment1" )
1145 (assertRange "DataPhaseBufferSegment1" 0 4294967295 )
1146 (assertInt "DataPhaseBufferSegment2" )
1147 (assertRange "DataPhaseBufferSegment2" 0 4294967295 )
1148 (assertInt "DataSyncJumpWidth" )
1149 (assertRange "DataSyncJumpWidth" 0 4294967295 )
1150 (assertValueOneOf "FDMode" boolValues)
1151 (assertValueOneOf "FDNonISO" boolValues)
1152 (assertValueOneOf "TripleSampling" boolValues)
1153 (assertValueOneOf "BusErrorReporting" boolValues)
1154 (assertValueOneOf "ListenOnly" boolValues)
1155 (assertValueOneOf "Loopback" boolValues)
1156 (assertValueOneOf "OneShot" boolValues)
1157 (assertValueOneOf "PresumeAck" boolValues)
1158 (assertValueOneOf "ClassicDataLengthCode" boolValues)
1161 sectionIPoIB = checkUnitConfig "IPoIB" [
1164 "IgnoreUserspaceMulticastGroup"
1166 (assertValueOneOf "Mode" [ "datagram" "connected" ])
1167 (assertValueOneOf "IgnoreUserspaceMulticastGroup" boolValues)
1170 sectionQDisc = checkUnitConfig "QDisc" [
1175 (assertValueOneOf "Parent" [ "clsact" "ingress" ])
1178 sectionNetworkEmulator = checkUnitConfig "NetworkEmulator" [
1188 (assertInt "PacketLimit")
1189 (assertRange "PacketLimit" 0 4294967294)
1192 sectionTokenBucketFilter = checkUnitConfig "TokenBucketFilter" [
1206 sectionPIE = checkUnitConfig "PIE" [
1212 (assertInt "PacketLimit")
1213 (assertRange "PacketLimit" 1 4294967294)
1216 sectionFlowQueuePIE = checkUnitConfig "FlowQueuePIE" [
1222 (assertInt "PacketLimit")
1223 (assertRange "PacketLimit" 1 4294967294)
1226 sectionStochasticFairBlue = checkUnitConfig "StochasticFairBlue" [
1232 (assertInt "PacketLimit")
1233 (assertRange "PacketLimit" 1 4294967294)
1236 sectionStochasticFairnessQueueing = checkUnitConfig "StochasticFairnessQueueing" [
1242 (assertInt "PerturbPeriodSec")
1245 sectionBFIFO = checkUnitConfig "BFIFO" [
1253 sectionPFIFO = checkUnitConfig "PFIFO" [
1259 (assertInt "PacketLimit")
1260 (assertRange "PacketLimit" 0 4294967294)
1263 sectionPFIFOHeadDrop = checkUnitConfig "PFIFOHeadDrop" [
1269 (assertInt "PacketLimit")
1270 (assertRange "PacketLimit" 0 4294967294)
1273 sectionPFIFOFast = checkUnitConfig "PFIFOFast" [
1280 sectionCAKE = checkUnitConfig "CAKE" [
1292 "PriorityQueueingPreset"
1298 (assertValueOneOf "AutoRateIngress" boolValues)
1299 (assertInt "OverheadBytes")
1300 (assertRange "OverheadBytes" (-64) 256)
1301 (assertInt "MPUBytes")
1302 (assertRange "MPUBytes" 1 256)
1303 (assertValueOneOf "CompensationMode" [ "none" "atm" "ptm" ])
1304 (assertValueOneOf "UseRawPacketSize" boolValues)
1305 (assertValueOneOf "FlowIsolationMode"
1316 (assertValueOneOf "NAT" boolValues)
1317 (assertValueOneOf "PriorityQueueingPreset"
1325 (assertInt "FirewallMark")
1326 (assertRange "FirewallMark" 1 4294967295)
1327 (assertValueOneOf "Wash" boolValues)
1328 (assertValueOneOf "SplitGSO" boolValues)
1329 (assertValueOneOf "AckFilter" (boolValues ++ ["aggressive"]))
1332 sectionControlledDelay = checkUnitConfig "ControlledDelay" [
1342 (assertValueOneOf "ECN" boolValues)
1345 sectionDeficitRoundRobinScheduler = checkUnitConfig "DeficitRoundRobinScheduler" [
1352 sectionDeficitRoundRobinSchedulerClass = checkUnitConfig "DeficitRoundRobinSchedulerClass" [
1360 sectionEnhancedTransmissionSelection = checkUnitConfig "EnhancedTransmissionSelection" [
1370 (assertRange "Bands" 1 16)
1371 (assertInt "StrictBands")
1372 (assertRange "StrictBands" 1 16)
1375 sectionGenericRandomEarlyDetection = checkUnitConfig "GenericRandomEarlyDetection" [
1380 "DefaultVirtualQueue"
1383 (assertInt "VirtualQueues")
1384 (assertRange "VirtualQueues" 1 16)
1385 (assertInt "DefaultVirtualQueue")
1386 (assertRange "DefaultVirtualQueue" 1 16)
1387 (assertValueOneOf "GenericRIO" boolValues)
1390 sectionFairQueueingControlledDelay = checkUnitConfig "FairQueueingControlledDelay" [
1403 (assertInt "PacketLimit")
1405 (assertValueOneOf "ECN" boolValues)
1408 sectionFairQueueing = checkUnitConfig "FairQueueing" [
1415 "InitualQuantumBytes"
1422 (assertInt "PacketLimit")
1423 (assertInt "FlowLimit")
1424 (assertInt "OrphanMask")
1425 (assertValueOneOf "Pacing" boolValues)
1428 sectionTrivialLinkEqualizer = checkUnitConfig "TrivialLinkEqualizer" [
1436 sectionHierarchyTokenBucket = checkUnitConfig "HierarchyTokenBucket" [
1443 (assertInt "RateToQuantum")
1446 sectionHierarchyTokenBucketClass = checkUnitConfig "HierarchyTokenBucketClass" [
1461 sectionHeavyHitterFilter = checkUnitConfig "HeavyHitterFilter" [
1467 (assertInt "PacketLimit")
1468 (assertRange "PacketLimit" 0 4294967294)
1471 sectionQuickFairQueueing = checkUnitConfig "QuickFairQueueing" [
1478 sectionQuickFairQueueingClass = checkUnitConfig "QuickFairQueueingClass" [
1485 (assertInt "Weight")
1486 (assertRange "Weight" 1 1023)
1489 sectionBridgeVLAN = checkUnitConfig "BridgeVLAN" [
1496 (assertRange "PVID" 0 4094)
1501 commonNetworkOptions = {
1506 description = lib.mdDoc ''
1507 Whether to manage network configuration using {command}`systemd-network`.
1509 This also enables {option}`systemd.networkd.enable`.
1513 matchConfig = mkOption {
1515 example = { Name = "eth0"; };
1516 type = types.attrsOf unitOption;
1517 description = lib.mdDoc ''
1518 Each attribute in this set specifies an option in the
1519 `[Match]` section of the unit. See
1520 {manpage}`systemd.link(5)`
1521 {manpage}`systemd.netdev(5)`
1522 {manpage}`systemd.network(5)`
1527 extraConfig = mkOption {
1530 description = lib.mdDoc "Extra configuration append to unit";
1535 networkConfig = mkOption {
1537 example = { SpeedMeter = true; ManageForeignRoutingPolicyRules = false; };
1538 type = types.addCheck (types.attrsOf unitOption) check.global.sectionNetwork;
1539 description = lib.mdDoc ''
1540 Each attribute in this set specifies an option in the
1541 `[Network]` section of the networkd config.
1542 See {manpage}`networkd.conf(5)` for details.
1546 dhcpV4Config = mkOption {
1548 example = { DUIDType = "vendor"; };
1549 type = types.addCheck (types.attrsOf unitOption) check.global.sectionDHCPv4;
1550 description = lib.mdDoc ''
1551 Each attribute in this set specifies an option in the
1552 `[DHCPv4]` section of the networkd config.
1553 See {manpage}`networkd.conf(5)` for details.
1557 dhcpV6Config = mkOption {
1559 example = { DUIDType = "vendor"; };
1560 type = types.addCheck (types.attrsOf unitOption) check.global.sectionDHCPv6;
1561 description = lib.mdDoc ''
1562 Each attribute in this set specifies an option in the
1563 `[DHCPv6]` section of the networkd config.
1564 See {manpage}`networkd.conf(5)` for details.
1569 linkOptions = commonNetworkOptions // {
1570 # overwrite enable option from above
1574 description = lib.mdDoc ''
1575 Whether to enable this .link unit. It's handled by udev no matter if {command}`systemd-networkd` is enabled or not
1579 linkConfig = mkOption {
1581 example = { MACAddress = "00:ff:ee:aa:cc:dd"; };
1582 type = types.addCheck (types.attrsOf unitOption) check.link.sectionLink;
1583 description = lib.mdDoc ''
1584 Each attribute in this set specifies an option in the
1585 `[Link]` section of the unit. See
1586 {manpage}`systemd.link(5)` for details.
1593 l2tpSessionOptions = {
1595 l2tpSessionConfig = mkOption {
1597 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionL2TPSession;
1598 description = lib.mdDoc ''
1599 Each attribute in this set specifies an option in the
1600 `[L2TPSession]` section of the unit. See
1601 {manpage}`systemd.netdev(5)` for details.
1607 wireguardPeerOptions = {
1609 wireguardPeerConfig = mkOption {
1611 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionWireGuardPeer;
1612 description = lib.mdDoc ''
1613 Each attribute in this set specifies an option in the
1614 `[WireGuardPeer]` section of the unit. See
1615 {manpage}`systemd.network(5)` for details.
1621 netdevOptions = commonNetworkOptions // {
1623 netdevConfig = mkOption {
1624 example = { Name = "mybridge"; Kind = "bridge"; };
1625 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionNetdev;
1626 description = lib.mdDoc ''
1627 Each attribute in this set specifies an option in the
1628 `[Netdev]` section of the unit. See
1629 {manpage}`systemd.netdev(5)` for details.
1633 vlanConfig = mkOption {
1635 example = { Id = 4; };
1636 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionVLAN;
1637 description = lib.mdDoc ''
1638 Each attribute in this set specifies an option in the
1639 `[VLAN]` section of the unit. See
1640 {manpage}`systemd.netdev(5)` for details.
1644 ipvlanConfig = mkOption {
1646 example = { Mode = "L2"; Flags = "private"; };
1647 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionIPVLAN;
1648 description = lib.mdDoc ''
1649 Each attribute in this set specifies an option in the `[IPVLAN]` section of the unit.
1650 See {manpage}`systemd.netdev(5)` for details.
1654 ipvtapConfig = mkOption {
1656 example = { Mode = "L3"; Flags = "vepa"; };
1657 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionIPVTAP;
1658 description = lib.mdDoc ''
1659 Each attribute in this set specifies an option in the `[IPVTAP]` section of the unit.
1660 See {manpage}`systemd.netdev(5)` for details.
1664 macvlanConfig = mkOption {
1666 example = { Mode = "private"; };
1667 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionMACVLAN;
1668 description = lib.mdDoc ''
1669 Each attribute in this set specifies an option in the
1670 `[MACVLAN]` section of the unit. See
1671 {manpage}`systemd.netdev(5)` for details.
1675 vxlanConfig = mkOption {
1677 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionVXLAN;
1678 description = lib.mdDoc ''
1679 Each attribute in this set specifies an option in the
1680 `[VXLAN]` section of the unit. See
1681 {manpage}`systemd.netdev(5)` for details.
1685 tunnelConfig = mkOption {
1687 example = { Remote = "192.168.1.1"; };
1688 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionTunnel;
1689 description = lib.mdDoc ''
1690 Each attribute in this set specifies an option in the
1691 `[Tunnel]` section of the unit. See
1692 {manpage}`systemd.netdev(5)` for details.
1696 fooOverUDPConfig = mkOption {
1698 example = { Port = 9001; };
1699 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionFooOverUDP;
1700 description = lib.mdDoc ''
1701 Each attribute in this set specifies an option in the
1702 `[FooOverUDP]` section of the unit. See
1703 {manpage}`systemd.netdev(5)` for details.
1707 peerConfig = mkOption {
1709 example = { Name = "veth2"; };
1710 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionPeer;
1711 description = lib.mdDoc ''
1712 Each attribute in this set specifies an option in the
1713 `[Peer]` section of the unit. See
1714 {manpage}`systemd.netdev(5)` for details.
1718 tunConfig = mkOption {
1720 example = { User = "openvpn"; };
1721 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionTun;
1722 description = lib.mdDoc ''
1723 Each attribute in this set specifies an option in the
1724 `[Tun]` section of the unit. See
1725 {manpage}`systemd.netdev(5)` for details.
1729 tapConfig = mkOption {
1731 example = { User = "openvpn"; };
1732 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionTap;
1733 description = lib.mdDoc ''
1734 Each attribute in this set specifies an option in the
1735 `[Tap]` section of the unit. See
1736 {manpage}`systemd.netdev(5)` for details.
1740 l2tpConfig = mkOption {
1746 Remote = "192.168.30.101";
1747 EncapsulationType = "ip";
1749 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionL2TP;
1750 description = lib.mdDoc ''
1751 Each attribute in this set specifies an option in the
1752 `[L2TP]` section of the unit. See
1753 {manpage}`systemd.netdev(5)` for details.
1757 l2tpSessions = mkOption {
1759 example = [ { l2tpSessionConfig={
1764 type = with types; listOf (submodule l2tpSessionOptions);
1765 description = lib.mdDoc ''
1766 Each item in this array specifies an option in the
1767 `[L2TPSession]` section of the unit. See
1768 {manpage}`systemd.netdev(5)` for details.
1772 wireguardConfig = mkOption {
1775 PrivateKeyFile = "/etc/wireguard/secret.key";
1779 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionWireGuard;
1780 description = lib.mdDoc ''
1781 Each attribute in this set specifies an option in the
1782 `[WireGuard]` section of the unit. See
1783 {manpage}`systemd.netdev(5)` for details.
1784 Use `PrivateKeyFile` instead of
1785 `PrivateKey`: the nix store is
1790 wireguardPeers = mkOption {
1792 example = [ { wireguardPeerConfig={
1793 Endpoint = "192.168.1.1:51820";
1794 PublicKey = "27s0OvaBBdHoJYkH9osZpjpgSOVNw+RaKfboT/Sfq0g=";
1795 PresharedKeyFile = "/etc/wireguard/psk.key";
1796 AllowedIPs = [ "10.0.0.1/32" ];
1797 PersistentKeepalive = 15;
1799 type = with types; listOf (submodule wireguardPeerOptions);
1800 description = lib.mdDoc ''
1801 Each item in this array specifies an option in the
1802 `[WireGuardPeer]` section of the unit. See
1803 {manpage}`systemd.netdev(5)` for details.
1804 Use `PresharedKeyFile` instead of
1805 `PresharedKey`: the nix store is
1810 bondConfig = mkOption {
1812 example = { Mode = "802.3ad"; };
1813 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionBond;
1814 description = lib.mdDoc ''
1815 Each attribute in this set specifies an option in the
1816 `[Bond]` section of the unit. See
1817 {manpage}`systemd.netdev(5)` for details.
1821 xfrmConfig = mkOption {
1823 example = { InterfaceId = 1; };
1824 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionXfrm;
1825 description = lib.mdDoc ''
1826 Each attribute in this set specifies an option in the
1827 `[Xfrm]` section of the unit. See
1828 {manpage}`systemd.netdev(5)` for details.
1832 vrfConfig = mkOption {
1834 example = { Table = 2342; };
1835 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionVRF;
1836 description = lib.mdDoc ''
1837 Each attribute in this set specifies an option in the
1838 `[VRF]` section of the unit. See
1839 {manpage}`systemd.netdev(5)` for details.
1840 A detailed explanation about how VRFs work can be found in the
1841 [kernel docs](https://www.kernel.org/doc/Documentation/networking/vrf.txt).
1845 wlanConfig = mkOption {
1847 example = { PhysicalDevice = 0; Type = "station"; };
1848 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionWLAN;
1849 description = lib.mdDoc ''
1850 Each attribute in this set specifies an option in the `[WLAN]` section of the unit.
1851 See {manpage}`systemd.netdev(5)` for details.
1855 batmanAdvancedConfig = mkOption {
1858 GatewayMode = "server";
1859 RoutingAlgorithm = "batman-v";
1861 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionBatmanAdvanced;
1862 description = lib.mdDoc ''
1863 Each attribute in this set specifies an option in the
1864 `[BatmanAdvanced]` section of the unit. See
1865 {manpage}`systemd.netdev(5)` for details.
1873 addressConfig = mkOption {
1874 example = { Address = "192.168.0.100/24"; };
1875 type = types.addCheck (types.attrsOf unitOption) check.network.sectionAddress;
1876 description = lib.mdDoc ''
1877 Each attribute in this set specifies an option in the
1878 `[Address]` section of the unit. See
1879 {manpage}`systemd.network(5)` for details.
1885 routingPolicyRulesOptions = {
1887 routingPolicyRuleConfig = mkOption {
1889 example = { Table = 10; IncomingInterface = "eth1"; Family = "both"; };
1890 type = types.addCheck (types.attrsOf unitOption) check.network.sectionRoutingPolicyRule;
1891 description = lib.mdDoc ''
1892 Each attribute in this set specifies an option in the
1893 `[RoutingPolicyRule]` section of the unit. See
1894 {manpage}`systemd.network(5)` for details.
1902 routeConfig = mkOption {
1904 example = { Gateway = "192.168.0.1"; };
1905 type = types.addCheck (types.attrsOf unitOption) check.network.sectionRoute;
1906 description = lib.mdDoc ''
1907 Each attribute in this set specifies an option in the
1908 `[Route]` section of the unit. See
1909 {manpage}`systemd.network(5)` for details.
1915 ipv6PrefixOptions = {
1917 ipv6PrefixConfig = mkOption {
1919 example = { Prefix = "fd00::/64"; };
1920 type = types.addCheck (types.attrsOf unitOption) check.network.sectionIPv6Prefix;
1921 description = lib.mdDoc ''
1922 Each attribute in this set specifies an option in the
1923 `[IPv6Prefix]` section of the unit. See
1924 {manpage}`systemd.network(5)` for details.
1930 ipv6RoutePrefixOptions = {
1932 ipv6RoutePrefixConfig = mkOption {
1934 example = { Route = "fd00::/64"; };
1935 type = types.addCheck (types.attrsOf unitOption) check.network.sectionIPv6RoutePrefix;
1936 description = lib.mdDoc ''
1937 Each attribute in this set specifies an option in the
1938 `[IPv6RoutePrefix]` section of the unit. See
1939 {manpage}`systemd.network(5)` for details.
1945 dhcpServerStaticLeaseOptions = {
1947 dhcpServerStaticLeaseConfig = mkOption {
1949 example = { MACAddress = "65:43:4a:5b:d8:5f"; Address = "192.168.1.42"; };
1950 type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPServerStaticLease;
1951 description = lib.mdDoc ''
1952 Each attribute in this set specifies an option in the
1953 `[DHCPServerStaticLease]` section of the unit. See
1954 {manpage}`systemd.network(5)` for details.
1956 Make sure to configure the corresponding client interface to use
1957 `ClientIdentifier=mac`.
1963 bridgeFDBOptions = {
1965 bridgeFDBConfig = mkOption {
1967 example = { MACAddress = "65:43:4a:5b:d8:5f"; Destination = "192.168.1.42"; VNI = 20; };
1968 type = types.addCheck (types.attrsOf unitOption) check.network.sectionBridgeFDB;
1969 description = lib.mdDoc ''
1970 Each attribute in this set specifies an option in the
1971 `[BridgeFDB]` section of the unit. See
1972 {manpage}`systemd.network(5)` for details.
1978 bridgeMDBOptions = {
1980 bridgeMDBConfig = mkOption {
1982 example = { MulticastGroupAddress = "ff02::1:2:3:4"; VLANId = 10; };
1983 type = types.addCheck (types.attrsOf unitOption) check.network.sectionBridgeMDB;
1984 description = lib.mdDoc ''
1985 Each attribute in this set specifies an option in the
1986 `[BridgeMDB]` section of the unit. See
1987 {manpage}`systemd.network(5)` for details.
1993 bridgeVLANOptions = {
1995 bridgeVLANConfig = mkOption {
1997 example = { VLAN = 20; };
1998 type = types.addCheck (types.attrsOf unitOption) check.network.sectionBridgeVLAN;
1999 description = lib.mdDoc ''
2000 Each attribute in this set specifies an option in the
2001 `[BridgeVLAN]` section of the unit. See
2002 {manpage}`systemd.network(5)` for details.
2008 networkOptions = commonNetworkOptions // {
2010 linkConfig = mkOption {
2012 example = { Unmanaged = true; };
2013 type = types.addCheck (types.attrsOf unitOption) check.network.sectionLink;
2014 description = lib.mdDoc ''
2015 Each attribute in this set specifies an option in the
2016 `[Link]` section of the unit. See
2017 {manpage}`systemd.network(5)` for details.
2021 networkConfig = mkOption {
2023 example = { Description = "My Network"; };
2024 type = types.addCheck (types.attrsOf unitOption) check.network.sectionNetwork;
2025 description = lib.mdDoc ''
2026 Each attribute in this set specifies an option in the
2027 `[Network]` section of the unit. See
2028 {manpage}`systemd.network(5)` for details.
2032 # systemd.network.networks.*.dhcpConfig has been deprecated in favor of ….dhcpV4Config
2033 # Produce a nice warning message so users know it is gone.
2034 dhcpConfig = mkOption {
2036 apply = _: throw "The option `systemd.network.networks.*.dhcpConfig` can no longer be used since it's been removed. Please use `systemd.network.networks.*.dhcpV4Config` instead.";
2039 dhcpV4Config = mkOption {
2041 example = { UseDNS = true; UseRoutes = true; };
2042 type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPv4;
2043 description = lib.mdDoc ''
2044 Each attribute in this set specifies an option in the
2045 `[DHCPv4]` section of the unit. See
2046 {manpage}`systemd.network(5)` for details.
2050 dhcpV6Config = mkOption {
2052 example = { UseDNS = true; };
2053 type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPv6;
2054 description = lib.mdDoc ''
2055 Each attribute in this set specifies an option in the
2056 `[DHCPv6]` section of the unit. See
2057 {manpage}`systemd.network(5)` for details.
2061 dhcpV6PrefixDelegationConfig = mkOption {
2063 apply = _: throw "The option `systemd.network.networks.<name>.dhcpV6PrefixDelegationConfig` has been renamed to `systemd.network.networks.<name>.dhcpPrefixDelegationConfig`.";
2066 dhcpPrefixDelegationConfig = mkOption {
2068 example = { SubnetId = "auto"; Announce = true; };
2069 type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPPrefixDelegation;
2070 description = lib.mdDoc ''
2071 Each attribute in this set specifies an option in the
2072 `[DHCPPrefixDelegation]` section of the unit. See
2073 {manpage}`systemd.network(5)` for details.
2077 ipv6AcceptRAConfig = mkOption {
2079 example = { UseDNS = true; DHCPv6Client = "always"; };
2080 type = types.addCheck (types.attrsOf unitOption) check.network.sectionIPv6AcceptRA;
2081 description = lib.mdDoc ''
2082 Each attribute in this set specifies an option in the
2083 `[IPv6AcceptRA]` section of the unit. See
2084 {manpage}`systemd.network(5)` for details.
2088 dhcpServerConfig = mkOption {
2090 example = { PoolOffset = 50; EmitDNS = false; };
2091 type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPServer;
2092 description = lib.mdDoc ''
2093 Each attribute in this set specifies an option in the
2094 `[DHCPServer]` section of the unit. See
2095 {manpage}`systemd.network(5)` for details.
2099 # systemd.network.networks.*.ipv6PrefixDelegationConfig has been deprecated
2100 # in 247 in favor of systemd.network.networks.*.ipv6SendRAConfig.
2101 ipv6PrefixDelegationConfig = mkOption {
2103 apply = _: throw "The option `systemd.network.networks.*.ipv6PrefixDelegationConfig` has been replaced by `systemd.network.networks.*.ipv6SendRAConfig`.";
2106 ipv6SendRAConfig = mkOption {
2108 example = { EmitDNS = true; Managed = true; OtherInformation = true; };
2109 type = types.addCheck (types.attrsOf unitOption) check.network.sectionIPv6SendRA;
2110 description = lib.mdDoc ''
2111 Each attribute in this set specifies an option in the
2112 `[IPv6SendRA]` section of the unit. See
2113 {manpage}`systemd.network(5)` for details.
2117 dhcpServerStaticLeases = mkOption {
2119 example = [ { dhcpServerStaticLeaseConfig = { MACAddress = "65:43:4a:5b:d8:5f"; Address = "192.168.1.42"; }; } ];
2120 type = with types; listOf (submodule dhcpServerStaticLeaseOptions);
2121 description = lib.mdDoc ''
2122 A list of DHCPServerStaticLease sections to be added to the unit. See
2123 {manpage}`systemd.network(5)` for details.
2127 ipv6Prefixes = mkOption {
2129 example = [ { ipv6PrefixConfig = { AddressAutoconfiguration = true; OnLink = true; }; } ];
2130 type = with types; listOf (submodule ipv6PrefixOptions);
2131 description = lib.mdDoc ''
2132 A list of ipv6Prefix sections to be added to the unit. See
2133 {manpage}`systemd.network(5)` for details.
2137 ipv6RoutePrefixes = mkOption {
2139 example = [ { ipv6RoutePrefixConfig = { Route = "fd00::/64"; LifetimeSec = 3600; }; } ];
2140 type = with types; listOf (submodule ipv6RoutePrefixOptions);
2141 description = lib.mdDoc ''
2142 A list of ipv6RoutePrefix sections to be added to the unit. See
2143 {manpage}`systemd.network(5)` for details.
2147 bridgeConfig = mkOption {
2149 example = { MulticastFlood = false; Cost = 20; };
2150 type = types.addCheck (types.attrsOf unitOption) check.network.sectionBridge;
2151 description = lib.mdDoc ''
2152 Each attribute in this set specifies an option in the
2153 `[Bridge]` section of the unit. See
2154 {manpage}`systemd.network(5)` for details.
2158 bridgeFDBs = mkOption {
2160 example = [ { bridgeFDBConfig = { MACAddress = "90:e2:ba:43:fc:71"; Destination = "192.168.100.4"; VNI = 3600; }; } ];
2161 type = with types; listOf (submodule bridgeFDBOptions);
2162 description = lib.mdDoc ''
2163 A list of BridgeFDB sections to be added to the unit. See
2164 {manpage}`systemd.network(5)` for details.
2168 bridgeMDBs = mkOption {
2170 example = [ { bridgeMDBConfig = { MulticastGroupAddress = "ff02::1:2:3:4"; VLANId = 10; } ; } ];
2171 type = with types; listOf (submodule bridgeMDBOptions);
2172 description = lib.mdDoc ''
2173 A list of BridgeMDB sections to be added to the unit. See
2174 {manpage}`systemd.network(5)` for details.
2178 lldpConfig = mkOption {
2180 example = { MUDURL = "https://things.example.org/product_abc123/v5"; };
2181 type = types.addCheck (types.attrsOf unitOption) check.network.sectionLLDP;
2182 description = lib.mdDoc ''
2183 Each attribute in this set specifies an option in the
2184 `[LLDP]` section of the unit. See
2185 {manpage}`systemd.network(5)` for details.
2189 canConfig = mkOption {
2192 type = types.addCheck (types.attrsOf unitOption) check.network.sectionCAN;
2193 description = lib.mdDoc ''
2194 Each attribute in this set specifies an option in the
2195 `[CAN]` section of the unit. See
2196 {manpage}`systemd.network(5)` for details.
2200 ipoIBConfig = mkOption {
2203 type = types.addCheck (types.attrsOf unitOption) check.network.sectionIPoIB;
2204 description = lib.mdDoc ''
2205 Each attribute in this set specifies an option in the
2206 `[IPoIB]` section of the unit. See
2207 {manpage}`systemd.network(5)` for details.
2211 qdiscConfig = mkOption {
2213 example = { Parent = "ingress"; };
2214 type = types.addCheck (types.attrsOf unitOption) check.network.sectionQDisc;
2215 description = lib.mdDoc ''
2216 Each attribute in this set specifies an option in the
2217 `[QDisc]` section of the unit. See
2218 {manpage}`systemd.network(5)` for details.
2222 networkEmulatorConfig = mkOption {
2224 example = { Parent = "ingress"; DelaySec = "20msec"; };
2225 type = types.addCheck (types.attrsOf unitOption) check.network.sectionNetworkEmulator;
2226 description = lib.mdDoc ''
2227 Each attribute in this set specifies an option in the
2228 `[NetworkEmulator]` section of the unit. See
2229 {manpage}`systemd.network(5)` for details.
2233 tokenBucketFilterConfig = mkOption {
2235 example = { Parent = "ingress"; Rate = "100k"; };
2236 type = types.addCheck (types.attrsOf unitOption) check.network.sectionTokenBucketFilter;
2237 description = lib.mdDoc ''
2238 Each attribute in this set specifies an option in the
2239 `[TokenBucketFilter]` section of the unit. See
2240 {manpage}`systemd.network(5)` for details.
2244 pieConfig = mkOption {
2246 example = { Parent = "ingress"; PacketLimit = "3847"; };
2247 type = types.addCheck (types.attrsOf unitOption) check.network.sectionPIE;
2248 description = lib.mdDoc ''
2249 Each attribute in this set specifies an option in the
2250 `[PIE]` section of the unit. See
2251 {manpage}`systemd.network(5)` for details.
2255 flowQueuePIEConfig = mkOption {
2257 example = { Parent = "ingress"; PacketLimit = "3847"; };
2258 type = types.addCheck (types.attrsOf unitOption) check.network.sectionFlowQueuePIE;
2259 description = lib.mdDoc ''
2260 Each attribute in this set specifies an option in the
2261 `[FlowQueuePIE]` section of the unit. See
2262 {manpage}`systemd.network(5)` for details.
2266 stochasticFairBlueConfig = mkOption {
2268 example = { Parent = "ingress"; PacketLimit = "3847"; };
2269 type = types.addCheck (types.attrsOf unitOption) check.network.sectionStochasticFairBlue;
2270 description = lib.mdDoc ''
2271 Each attribute in this set specifies an option in the
2272 `[StochasticFairBlue]` section of the unit. See
2273 {manpage}`systemd.network(5)` for details.
2277 stochasticFairnessQueueingConfig = mkOption {
2279 example = { Parent = "ingress"; PerturbPeriodSec = "30"; };
2280 type = types.addCheck (types.attrsOf unitOption) check.network.sectionStochasticFairnessQueueing;
2281 description = lib.mdDoc ''
2282 Each attribute in this set specifies an option in the
2283 `[StochasticFairnessQueueing]` section of the unit. See
2284 {manpage}`systemd.network(5)` for details.
2288 bfifoConfig = mkOption {
2290 example = { Parent = "ingress"; LimitBytes = "20K"; };
2291 type = types.addCheck (types.attrsOf unitOption) check.network.sectionBFIFO;
2292 description = lib.mdDoc ''
2293 Each attribute in this set specifies an option in the
2294 `[BFIFO]` section of the unit. See
2295 {manpage}`systemd.network(5)` for details.
2299 pfifoConfig = mkOption {
2301 example = { Parent = "ingress"; PacketLimit = "300"; };
2302 type = types.addCheck (types.attrsOf unitOption) check.network.sectionPFIFO;
2303 description = lib.mdDoc ''
2304 Each attribute in this set specifies an option in the
2305 `[PFIFO]` section of the unit. See
2306 {manpage}`systemd.network(5)` for details.
2310 pfifoHeadDropConfig = mkOption {
2312 example = { Parent = "ingress"; PacketLimit = "300"; };
2313 type = types.addCheck (types.attrsOf unitOption) check.network.sectionPFIFOHeadDrop;
2314 description = lib.mdDoc ''
2315 Each attribute in this set specifies an option in the
2316 `[PFIFOHeadDrop]` section of the unit. See
2317 {manpage}`systemd.network(5)` for details.
2321 pfifoFastConfig = mkOption {
2323 example = { Parent = "ingress"; };
2324 type = types.addCheck (types.attrsOf unitOption) check.network.sectionPFIFOFast;
2325 description = lib.mdDoc ''
2326 Each attribute in this set specifies an option in the
2327 `[PFIFOFast]` section of the unit. See
2328 {manpage}`systemd.network(5)` for details.
2332 cakeConfig = mkOption {
2334 example = { Bandwidth = "40M"; OverheadBytes = 8; CompensationMode = "ptm"; };
2335 type = types.addCheck (types.attrsOf unitOption) check.network.sectionCAKE;
2336 description = lib.mdDoc ''
2337 Each attribute in this set specifies an option in the
2338 `[CAKE]` section of the unit. See
2339 {manpage}`systemd.network(5)` for details.
2343 controlledDelayConfig = mkOption {
2345 example = { Parent = "ingress"; TargetSec = "20msec"; };
2346 type = types.addCheck (types.attrsOf unitOption) check.network.sectionControlledDelay;
2347 description = lib.mdDoc ''
2348 Each attribute in this set specifies an option in the
2349 `[ControlledDelay]` section of the unit. See
2350 {manpage}`systemd.network(5)` for details.
2354 deficitRoundRobinSchedulerConfig = mkOption {
2356 example = { Parent = "root"; };
2357 type = types.addCheck (types.attrsOf unitOption) check.network.sectionDeficitRoundRobinScheduler;
2358 description = lib.mdDoc ''
2359 Each attribute in this set specifies an option in the
2360 `[DeficitRoundRobinScheduler]` section of the unit. See
2361 {manpage}`systemd.network(5)` for details.
2365 deficitRoundRobinSchedulerClassConfig = mkOption {
2367 example = { Parent = "root"; QuantumBytes = "300k"; };
2368 type = types.addCheck (types.attrsOf unitOption) check.network.sectionDeficitRoundRobinSchedulerClass;
2369 description = lib.mdDoc ''
2370 Each attribute in this set specifies an option in the
2371 `[DeficitRoundRobinSchedulerClass]` section of the unit. See
2372 {manpage}`systemd.network(5)` for details.
2376 enhancedTransmissionSelectionConfig = mkOption {
2378 example = { Parent = "root"; QuantumBytes = "300k"; Bands = 3; PriorityMap = "100 200 300"; };
2379 type = types.addCheck (types.attrsOf unitOption) check.network.sectionEnhancedTransmissionSelection;
2380 description = lib.mdDoc ''
2381 Each attribute in this set specifies an option in the
2382 `[EnhancedTransmissionSelection]` section of the unit. See
2383 {manpage}`systemd.network(5)` for details.
2387 genericRandomEarlyDetectionConfig = mkOption {
2389 example = { Parent = "root"; VirtualQueues = 5; DefaultVirtualQueue = 3; };
2390 type = types.addCheck (types.attrsOf unitOption) check.network.sectionGenericRandomEarlyDetection;
2391 description = lib.mdDoc ''
2392 Each attribute in this set specifies an option in the
2393 `[GenericRandomEarlyDetection]` section of the unit. See
2394 {manpage}`systemd.network(5)` for details.
2398 fairQueueingControlledDelayConfig = mkOption {
2400 example = { Parent = "root"; Flows = 5; };
2401 type = types.addCheck (types.attrsOf unitOption) check.network.sectionFairQueueingControlledDelay;
2402 description = lib.mdDoc ''
2403 Each attribute in this set specifies an option in the
2404 `[FairQueueingControlledDelay]` section of the unit. See
2405 {manpage}`systemd.network(5)` for details.
2409 fairQueueingConfig = mkOption {
2411 example = { Parent = "root"; FlowLimit = 5; };
2412 type = types.addCheck (types.attrsOf unitOption) check.network.sectionFairQueueing;
2413 description = lib.mdDoc ''
2414 Each attribute in this set specifies an option in the
2415 `[FairQueueing]` section of the unit. See
2416 {manpage}`systemd.network(5)` for details.
2420 trivialLinkEqualizerConfig = mkOption {
2422 example = { Parent = "root"; Id = 0; };
2423 type = types.addCheck (types.attrsOf unitOption) check.network.sectionTrivialLinkEqualizer;
2424 description = lib.mdDoc ''
2425 Each attribute in this set specifies an option in the
2426 `[TrivialLinkEqualizer]` section of the unit. See
2427 {manpage}`systemd.network(5)` for details.
2431 hierarchyTokenBucketConfig = mkOption {
2433 example = { Parent = "root"; };
2434 type = types.addCheck (types.attrsOf unitOption) check.network.sectionHierarchyTokenBucket;
2435 description = lib.mdDoc ''
2436 Each attribute in this set specifies an option in the
2437 `[HierarchyTokenBucket]` section of the unit. See
2438 {manpage}`systemd.network(5)` for details.
2442 hierarchyTokenBucketClassConfig = mkOption {
2444 example = { Parent = "root"; Rate = "10M"; };
2445 type = types.addCheck (types.attrsOf unitOption) check.network.sectionHierarchyTokenBucketClass;
2446 description = lib.mdDoc ''
2447 Each attribute in this set specifies an option in the
2448 `[HierarchyTokenBucketClass]` section of the unit. See
2449 {manpage}`systemd.network(5)` for details.
2453 heavyHitterFilterConfig = mkOption {
2455 example = { Parent = "root"; PacketLimit = 10000; };
2456 type = types.addCheck (types.attrsOf unitOption) check.network.sectionHeavyHitterFilter;
2457 description = lib.mdDoc ''
2458 Each attribute in this set specifies an option in the
2459 `[HeavyHitterFilter]` section of the unit. See
2460 {manpage}`systemd.network(5)` for details.
2464 quickFairQueueingConfig = mkOption {
2466 example = { Parent = "root"; };
2467 type = types.addCheck (types.attrsOf unitOption) check.network.sectionQuickFairQueueing;
2468 description = lib.mdDoc ''
2469 Each attribute in this set specifies an option in the
2470 `[QuickFairQueueing]` section of the unit. See
2471 {manpage}`systemd.network(5)` for details.
2475 quickFairQueueingConfigClass = mkOption {
2477 example = { Parent = "root"; Weight = 133; };
2478 type = types.addCheck (types.attrsOf unitOption) check.network.sectionQuickFairQueueingClass;
2479 description = lib.mdDoc ''
2480 Each attribute in this set specifies an option in the
2481 `[QuickFairQueueingClass]` section of the unit. See
2482 {manpage}`systemd.network(5)` for details.
2486 bridgeVLANs = mkOption {
2488 example = [ { bridgeVLANConfig = { VLAN = "10-20"; }; } ];
2489 type = with types; listOf (submodule bridgeVLANOptions);
2490 description = lib.mdDoc ''
2491 A list of BridgeVLAN sections to be added to the unit. See
2492 {manpage}`systemd.network(5)` for details.
2497 type = types.nullOr types.str;
2499 description = lib.mdDoc ''
2500 The name of the network interface to match against.
2505 type = types.nullOr types.str;
2507 description = lib.mdDoc ''
2508 Whether to enable DHCP on the interfaces matched.
2512 domains = mkOption {
2513 type = types.nullOr (types.listOf types.str);
2515 description = lib.mdDoc ''
2516 A list of domains to pass to the network config.
2520 address = mkOption {
2522 type = types.listOf types.str;
2523 description = lib.mdDoc ''
2524 A list of addresses to be added to the network section of the
2525 unit. See {manpage}`systemd.network(5)` for details.
2529 gateway = mkOption {
2531 type = types.listOf types.str;
2532 description = lib.mdDoc ''
2533 A list of gateways to be added to the network section of the
2534 unit. See {manpage}`systemd.network(5)` for details.
2540 type = types.listOf types.str;
2541 description = lib.mdDoc ''
2542 A list of dns servers to be added to the network section of the
2543 unit. See {manpage}`systemd.network(5)` for details.
2549 type = types.listOf types.str;
2550 description = lib.mdDoc ''
2551 A list of ntp servers to be added to the network section of the
2552 unit. See {manpage}`systemd.network(5)` for details.
2558 type = types.listOf types.str;
2559 description = lib.mdDoc ''
2560 A list of bridge interfaces to be added to the network section of the
2561 unit. See {manpage}`systemd.network(5)` for details.
2567 type = types.listOf types.str;
2568 description = lib.mdDoc ''
2569 A list of bond interfaces to be added to the network section of the
2570 unit. See {manpage}`systemd.network(5)` for details.
2576 type = types.listOf types.str;
2577 description = lib.mdDoc ''
2578 A list of vrf interfaces to be added to the network section of the
2579 unit. See {manpage}`systemd.network(5)` for details.
2585 type = types.listOf types.str;
2586 description = lib.mdDoc ''
2587 A list of vlan interfaces to be added to the network section of the
2588 unit. See {manpage}`systemd.network(5)` for details.
2592 macvlan = mkOption {
2594 type = types.listOf types.str;
2595 description = lib.mdDoc ''
2596 A list of macvlan interfaces to be added to the network section of the
2597 unit. See {manpage}`systemd.network(5)` for details.
2601 macvtap = mkOption {
2603 type = types.listOf types.str;
2604 description = lib.mdDoc ''
2605 A list of macvtap interfaces to be added to the network section of the
2606 unit. See {manpage}`systemd.network(5)` for details.
2612 type = types.listOf types.str;
2613 description = lib.mdDoc ''
2614 A list of vxlan interfaces to be added to the network section of the
2615 unit. See {manpage}`systemd.network(5)` for details.
2621 type = types.listOf types.str;
2622 description = lib.mdDoc ''
2623 A list of tunnel interfaces to be added to the network section of the
2624 unit. See {manpage}`systemd.network(5)` for details.
2630 type = types.listOf types.str;
2631 description = lib.mdDoc ''
2632 A list of xfrm interfaces to be added to the network section of the
2633 unit. See {manpage}`systemd.network(5)` for details.
2637 addresses = mkOption {
2639 type = with types; listOf (submodule addressOptions);
2640 description = lib.mdDoc ''
2641 A list of address sections to be added to the unit. See
2642 {manpage}`systemd.network(5)` for details.
2646 routingPolicyRules = mkOption {
2648 type = with types; listOf (submodule routingPolicyRulesOptions);
2649 description = lib.mdDoc ''
2650 A list of routing policy rules sections to be added to the unit. See
2651 {manpage}`systemd.network(5)` for details.
2657 type = with types; listOf (submodule routeOptions);
2658 description = lib.mdDoc ''
2659 A list of route sections to be added to the unit. See
2660 {manpage}`systemd.network(5)` for details.
2666 networkConfig = { config, ... }: {
2668 matchConfig = optionalAttrs (config.name != null) {
2671 networkConfig = optionalAttrs (config.DHCP != null) {
2673 } // optionalAttrs (config.domains != null) {
2674 Domains = concatStringsSep " " config.domains;
2679 networkdConfig = { config, ... }: {
2681 routeTables = mkOption {
2683 example = { foo = 27; };
2684 type = with types; attrsOf int;
2685 description = lib.mdDoc ''
2686 Defines route table names as an attrset of name to number.
2687 See {manpage}`networkd.conf(5)` for details.
2691 addRouteTablesToIPRoute2 = mkOption {
2695 description = lib.mdDoc ''
2696 If true and routeTables are set, then the specified route tables
2697 will also be installed into /etc/iproute2/rt_tables.
2703 networkConfig = optionalAttrs (config.routeTables != { }) {
2704 RouteTable = mapAttrsToList
2705 (name: number: "${name}:${toString number}")
2714 ${attrsToSection def.networkConfig}
2716 + optionalString (def.dhcpV4Config != { }) ''
2718 ${attrsToSection def.dhcpV4Config}
2720 + optionalString (def.dhcpV6Config != { }) ''
2722 ${attrsToSection def.dhcpV6Config}
2725 mkUnitFiles = prefix: cfg: listToAttrs (map (name: {
2726 name = "${prefix}systemd/network/${name}";
2727 value.source = "${cfg.units.${name}.unit}/${name}";
2728 }) (attrNames cfg.units));
2730 commonOptions = visible: {
2735 description = lib.mdDoc ''
2736 Whether to enable networkd or not.
2743 type = with types; attrsOf (submodule [ { options = linkOptions; } ]);
2744 description = lib.mdDoc "Definition of systemd network links.";
2747 netdevs = mkOption {
2750 type = with types; attrsOf (submodule [ { options = netdevOptions; } ]);
2751 description = lib.mdDoc "Definition of systemd network devices.";
2754 networks = mkOption {
2757 type = with types; attrsOf (submodule [ { options = networkOptions; } networkConfig ]);
2758 description = lib.mdDoc "Definition of systemd networks.";
2764 type = with types; submodule [ { options = networkdOptions; } networkdConfig ];
2765 description = lib.mdDoc "Definition of global systemd network config.";
2769 description = lib.mdDoc "Definition of networkd units.";
2772 type = with types; attrsOf (submodule (
2773 { name, config, ... }:
2774 { options = mapAttrs (_: x: x // { internal = true; }) concreteUnitOptions;
2776 unit = mkDefault (makeUnit name config);
2786 description = lib.mdDoc ''
2787 Whether to enable the systemd-networkd-wait-online service.
2789 systemd-networkd-wait-online can timeout and fail if there are no network interfaces
2790 available for it to manage. When systemd-networkd is enabled but a different service is
2791 responsible for managing the system's internet connection (for example, NetworkManager or
2792 connman are used to manage WiFi connections), this service is unnecessary and can be
2796 anyInterface = mkOption {
2797 description = lib.mdDoc ''
2798 Whether to consider the network online when any interface is online, as opposed to all of them.
2799 This is useful on portable machines with a wired and a wireless interface, for example.
2801 This is on by default if {option}`networking.useDHCP` is enabled.
2804 defaultText = "config.networking.useDHCP";
2805 default = config.networking.useDHCP;
2808 ignoredInterfaces = mkOption {
2809 description = lib.mdDoc ''
2810 Network interfaces to be ignored when deciding if the system is online.
2812 type = with types; listOf str;
2814 example = [ "wg0" ];
2817 timeout = mkOption {
2818 description = lib.mdDoc ''
2819 Time to wait for the network to come online, in seconds. Set to 0 to disable.
2821 type = types.ints.unsigned;
2826 extraArgs = mkOption {
2827 description = lib.mdDoc ''
2828 Extra command-line arguments to pass to systemd-networkd-wait-online.
2829 These also affect per-interface `systemd-network-wait-online@` services.
2831 See {manpage}`systemd-networkd-wait-online.service(8)` for all available options.
2833 type = with types; listOf str;
2840 commonConfig = config: let
2841 cfg = config.systemd.network;
2842 mkUnit = f: def: { inherit (def) enable; text = f def; };
2845 # .link units are honored by udev, no matter if systemd-networkd is enabled or not.
2847 systemd.network.units = mapAttrs' (n: v: nameValuePair "${n}.link" (mkUnit linkToUnit v)) cfg.links;
2849 systemd.network.wait-online.extraArgs =
2850 [ "--timeout=${toString cfg.wait-online.timeout}" ]
2851 ++ optional cfg.wait-online.anyInterface "--any"
2852 ++ map (i: "--ignore=${i}") cfg.wait-online.ignoredInterfaces;
2855 (mkIf config.systemd.network.enable {
2857 systemd.network.units = mapAttrs' (n: v: nameValuePair "${n}.netdev" (mkUnit netdevToUnit v)) cfg.netdevs
2858 // mapAttrs' (n: v: nameValuePair "${n}.network" (mkUnit networkToUnit v)) cfg.networks;
2860 # systemd-networkd is socket-activated by kernel netlink route change
2861 # messages. It is important to have systemd buffer those on behalf of
2863 systemd.sockets.systemd-networkd.wantedBy = [ "sockets.target" ];
2865 systemd.services.systemd-networkd-wait-online = {
2866 inherit (cfg.wait-online) enable;
2867 wantedBy = [ "network-online.target" ];
2868 serviceConfig.ExecStart = [
2870 "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online ${utils.escapeSystemdExecArgs cfg.wait-online.extraArgs}"
2874 systemd.services."systemd-network-wait-online@" = {
2875 description = "Wait for Network Interface %I to be Configured";
2876 conflicts = [ "shutdown.target" ];
2877 requisite = [ "systemd-networkd.service" ];
2878 after = [ "systemd-networkd.service" ];
2881 RemainAfterExit = true;
2882 ExecStart = "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online -i %I ${utils.escapeSystemdExecArgs cfg.wait-online.extraArgs}";
2890 cfg = config.systemd.network;
2891 unitFiles = mkUnitFiles "" cfg;
2893 (commonConfig config)
2895 { environment.etc = unitFiles; }
2897 (mkIf config.systemd.network.enable {
2899 users.users.systemd-network.group = "systemd-network";
2901 systemd.additionalUpstreamSystemUnits = [
2902 "systemd-networkd-wait-online.service"
2903 "systemd-networkd.service"
2904 "systemd-networkd.socket"
2907 environment.etc."systemd/networkd.conf" = renderConfig cfg.config;
2909 systemd.services.systemd-networkd = let
2910 isReloadableUnitFileName = unitFileName: strings.hasSuffix ".network" unitFileName;
2911 reloadableUnitFiles = attrsets.filterAttrs (k: v: isReloadableUnitFileName k) unitFiles;
2912 nonReloadableUnitFiles = attrsets.filterAttrs (k: v: !isReloadableUnitFileName k) unitFiles;
2913 unitFileSources = unitFiles: map (x: x.source) (attrValues unitFiles);
2915 wantedBy = [ "multi-user.target" ];
2916 reloadTriggers = unitFileSources reloadableUnitFiles;
2917 restartTriggers = unitFileSources nonReloadableUnitFiles ++ [
2918 config.environment.etc."systemd/networkd.conf".source
2920 aliases = [ "dbus-org.freedesktop.network1.service" ];
2923 networking.iproute2 = mkIf (cfg.config.addRouteTablesToIPRoute2 && cfg.config.routeTables != { }) {
2924 enable = mkDefault true;
2925 rttablesExtraConfig = ''
2927 # Extra tables defined in NixOS systemd.networkd.config.routeTables.
2928 ${concatStringsSep "\n" (mapAttrsToList (name: number: "${toString number} ${name}") cfg.config.routeTables)}
2932 services.resolved.enable = mkDefault true;
2938 options.boot.initrd.systemd.network.networks = mkOption {
2939 type = with types; attrsOf (submodule {
2940 # Default in initrd is dhcp-on-stop, which is correct if flushBeforeStage2 = false
2941 config = mkIf config.boot.initrd.network.flushBeforeStage2 {
2942 networkConfig.KeepConfiguration = mkDefault false;
2949 cfg = config.boot.initrd.systemd.network;
2951 (commonConfig config.boot.initrd)
2954 systemd.network.enable = mkDefault config.boot.initrd.network.enable;
2955 systemd.contents = mkUnitFiles "/etc/" cfg;
2957 # Networkd link files are used early by udev to set up interfaces early.
2958 # This must be done in stage 1 to avoid race conditions between udev and
2960 systemd.network.units = lib.filterAttrs (n: _: hasSuffix ".link" n) config.systemd.network.units;
2961 systemd.storePaths = ["${config.boot.initrd.systemd.package}/lib/systemd/network/99-default.link"];
2967 systemd.dbus.enable = mkDefault true;
2969 systemd.additionalUpstreamUnits = [
2970 "systemd-networkd-wait-online.service"
2971 "systemd-networkd.service"
2972 "systemd-networkd.socket"
2973 "systemd-network-generator.service"
2974 "network-online.target"
2975 "network-pre.target"
2978 "nss-user-lookup.target"
2979 "remote-fs-pre.target"
2982 systemd.users.systemd-network = {};
2983 systemd.groups.systemd-network = {};
2985 systemd.contents."/etc/systemd/networkd.conf" = renderConfig cfg.config;
2987 systemd.services.systemd-networkd = {
2988 wantedBy = [ "initrd.target" ];
2989 # These before and conflicts lines can be removed when this PR makes it into a release:
2990 # https://github.com/systemd/systemd/pull/27791
2991 before = ["initrd-switch-root.target"];
2992 conflicts = ["initrd-switch-root.target"];
2994 systemd.sockets.systemd-networkd = {
2995 wantedBy = [ "initrd.target" ];
2996 before = ["initrd-switch-root.target"];
2997 conflicts = ["initrd-switch-root.target"];
3000 systemd.services.systemd-network-generator.wantedBy = [ "sysinit.target" ];
3002 systemd.storePaths = [
3003 "${config.boot.initrd.systemd.package}/lib/systemd/systemd-networkd"
3004 "${config.boot.initrd.systemd.package}/lib/systemd/systemd-networkd-wait-online"
3005 "${config.boot.initrd.systemd.package}/lib/systemd/systemd-network-generator"
3007 kernelModules = [ "af_packet" ];
3015 imports = [ stage1Options ];
3018 systemd.network = commonOptions true;
3019 boot.initrd.systemd.network = commonOptions "shallow";
3024 (mkIf config.boot.initrd.systemd.enable {
3026 assertion = !config.boot.initrd.network.udhcpc.enable && config.boot.initrd.network.udhcpc.extraArgs == [];
3028 systemd stage 1 networking does not support 'boot.initrd.network.udhcpc'. Configure
3029 DHCP with 'networking.*' options or with 'boot.initrd.systemd.network' options.
3033 boot.initrd = stage1Config;