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"
20 "IPv6PrivacyExtensions"
25 (assertValueOneOf "SpeedMeter" boolValues)
26 (assertInt "SpeedMeterIntervalSec")
27 (assertValueOneOf "ManageForeignRoutingPolicyRules" boolValues)
28 (assertValueOneOf "ManageForeignRoutes" boolValues)
29 (assertValueOneOf "IPv6PrivacyExtensions" (boolValues ++ ["prefer-public" "kernel"]))
30 (assertValueOneOf "IPv4Forwarding" boolValues)
31 (assertValueOneOf "IPv6Forwarding" boolValues)
32 (assertValueOneOf "UseDomains" (boolValues ++ ["route"]))
35 sectionDHCPv4 = checkUnitConfig "DHCPv4" [
41 (assertValueOneOf "ClientIdentifier" ["mac" "duid" "duid-only"])
44 sectionDHCPv6 = checkUnitConfig "DHCPv6" [
54 sectionLink = checkUnitConfig "Link" [
62 "AlternativeNamesPolicy"
71 "ReceiveChecksumOffload"
72 "TransmitChecksumOffload"
73 "TCPSegmentationOffload"
74 "TCP6SegmentationOffload"
75 "GenericSegmentationOffload"
76 "GenericReceiveOffload"
88 (assertValueOneOf "MACAddressPolicy" ["persistent" "random" "none"])
89 (assertMacAddress "MACAddress")
90 (assertByteFormat "MTUBytes")
91 (assertByteFormat "BitsPerSecond")
92 (assertValueOneOf "Duplex" ["half" "full"])
93 (assertValueOneOf "AutoNegotiation" boolValues)
94 (assertValuesSomeOfOr "WakeOnLan" ["phy" "unicast" "multicast" "broadcast" "arp" "magic" "secureon"] "off")
95 (assertValueOneOf "Port" ["tp" "aui" "bnc" "mii" "fibre"])
96 (assertValueOneOf "ReceiveChecksumOffload" boolValues)
97 (assertValueOneOf "TransmitChecksumOffload" boolValues)
98 (assertValueOneOf "TCPSegmentationOffload" boolValues)
99 (assertValueOneOf "TCP6SegmentationOffload" boolValues)
100 (assertValueOneOf "GenericSegmentationOffload" boolValues)
101 (assertValueOneOf "GenericReceiveOffload" boolValues)
102 (assertValueOneOf "LargeReceiveOffload" boolValues)
103 (assertInt "RxChannels")
104 (assertRange "RxChannels" 1 4294967295)
105 (assertInt "TxChannels")
106 (assertRange "TxChannels" 1 4294967295)
107 (assertInt "OtherChannels")
108 (assertRange "OtherChannels" 1 4294967295)
109 (assertInt "CombinedChannels")
110 (assertRange "CombinedChannels" 1 4294967295)
111 (assertInt "RxBufferSize")
112 (assertInt "TxBufferSize")
113 (assertRange "ReceiveQueues" 1 4096)
114 (assertRange "TransmitQueues" 1 4096)
115 (assertRange "TransmitQueueLength" 1 4294967294)
130 (assertValueOneOf "MultiQueue" boolValues)
131 (assertValueOneOf "PacketInfo" boolValues)
132 (assertValueOneOf "VNetHeader" boolValues)
133 (assertValueOneOf "KeepCarrier" boolValues)
136 # See https://www.freedesktop.org/software/systemd/man/latest/systemd.netdev.html#%5BIPVTAP%5D%20Section%20Options
142 (assertValueOneOf "Mode" ["L2" "L3" "L3S" ])
143 (assertValueOneOf "Flags" ["private" "vepa" "bridge" ])
147 sectionNetdev = checkUnitConfig "Netdev" [
155 (assertHasField "Name")
156 (assertHasField "Kind")
157 (assertValueOneOf "Kind" [
195 (assertByteFormat "MTUBytes")
196 (assertNetdevMacAddress "MACAddress")
199 sectionBridge = checkUnitConfig "Bridge" [
213 "MulticastIGMPVersion"
215 (assertInt "HelloTimeSec")
216 (assertInt "MaxAgeSec")
217 (assertInt "ForwardDelaySec")
218 (assertInt "AgeingTimeSec")
219 (assertRange "Priority" 0 65535)
220 (assertRange "GroupForwardMask" 0 65535)
221 (assertRangeOrOneOf "DefaultPVID" 0 4094 ["none"])
222 (assertValueOneOf "MulticastQuerier" boolValues)
223 (assertValueOneOf "MulticastSnooping" boolValues)
224 (assertValueOneOf "VLANFiltering" boolValues)
225 (assertValueOneOf "VLANProtocol" ["802.1q" "802.ad"])
226 (assertValueOneOf "STP" boolValues)
227 (assertValueOneOf "MulticastIGMPVersion" [2 3])
230 sectionVLAN = checkUnitConfig "VLAN" [
239 (assertRange "Id" 0 4094)
240 (assertValueOneOf "GVRP" boolValues)
241 (assertValueOneOf "MVRP" boolValues)
242 (assertValueOneOf "LooseBinding" boolValues)
243 (assertValueOneOf "ReorderHeader" boolValues)
246 sectionIPVLAN = checkUnitConfig "IPVLAN" ipVlanVtapChecks;
248 sectionIPVTAP = checkUnitConfig "IPVTAP" ipVlanVtapChecks;
250 sectionMACVLAN = checkUnitConfig "MACVLAN" [
254 (assertValueOneOf "Mode" ["private" "vepa" "bridge" "passthru"])
257 sectionVXLAN = checkUnitConfig "VXLAN" [
277 "GroupPolicyExtension"
278 "GenericProtocolExtension"
286 (assertRange "VNI" 1 16777215)
287 (assertValueOneOf "MacLearning" boolValues)
288 (assertInt "MaximumFDBEntries")
289 (assertValueOneOf "ReduceARPProxy" boolValues)
290 (assertValueOneOf "L2MissNotification" boolValues)
291 (assertValueOneOf "L3MissNotification" boolValues)
292 (assertValueOneOf "RouteShortCircuit" boolValues)
293 (assertValueOneOf "UDPChecksum" boolValues)
294 (assertValueOneOf "UDP6ZeroChecksumTx" boolValues)
295 (assertValueOneOf "UDP6ZeroChecksumRx" boolValues)
296 (assertValueOneOf "RemoteChecksumTx" boolValues)
297 (assertValueOneOf "RemoteChecksumRx" boolValues)
298 (assertValueOneOf "GroupPolicyExtension" boolValues)
299 (assertValueOneOf "GenericProtocolExtension" boolValues)
300 (assertInt "FlowLabel")
301 (assertRange "FlowLabel" 0 1048575)
302 (assertValueOneOf "IPDoNotFragment" (boolValues + ["inherit"]))
303 (assertValueOneOf "Independent" boolValues)
306 sectionTunnel = checkUnitConfig "Tunnel" [
327 "IPv6RapidDeploymentPrefix"
329 "SerializeTunneledPackets"
333 (assertRange "TTL" 0 255)
334 (assertValueOneOf "DiscoverPathMTU" boolValues)
335 (assertValueOneOf "CopyDSCP" boolValues)
336 (assertValueOneOf "Mode" ["ip6ip6" "ipip6" "any"])
337 (assertValueOneOf "Independent" boolValues)
338 (assertValueOneOf "AssignToLoopback" boolValues)
339 (assertValueOneOf "AllowLocalRemote" boolValues)
340 (assertValueOneOf "FooOverUDP" boolValues)
341 (assertPort "FOUDestinationPort")
342 (assertPort "FOUSourcePort")
343 (assertValueOneOf "Encapsulation" ["FooOverUDP" "GenericUDPEncapsulation"])
344 (assertValueOneOf "ISATAP" boolValues)
345 (assertValueOneOf "SerializeTunneledPackets" boolValues)
346 (assertInt "ERSPANIndex")
347 (assertRange "ERSPANIndex" 1 1048575)
350 sectionFooOverUDP = checkUnitConfig "FooOverUDP" [
357 (assertValueOneOf "Encapsulation" ["FooOverUDP" "GenericUDPEncapsulation"])
360 sectionPeer = checkUnitConfig "Peer" [
365 (assertMacAddress "MACAddress")
368 sectionTun = checkUnitConfig "Tun" tunChecks;
370 sectionTap = checkUnitConfig "Tap" tunChecks;
372 sectionL2TP = checkUnitConfig "L2TP" [
385 (assertInt "TunnelId")
386 (assertRange "TunnelId" 1 4294967295)
387 (assertInt "PeerTunnelId")
388 (assertRange "PeerTunnelId" 1 4294967295)
389 (assertValueOneOf "EncapsulationType" [ "ip" "udp" ])
390 (assertPort "UDPSourcePort")
391 (assertPort "UDPDestinationPort")
392 (assertValueOneOf "UDPChecksum" boolValues)
393 (assertValueOneOf "UDP6ZeroChecksumTx" boolValues)
394 (assertValueOneOf "UDP6ZeroChecksumRx" boolValues)
397 sectionL2TPSession = checkUnitConfigWithLegacyKey "l2tpSessionConfig" "L2TPSession" [
402 "Layer2SpecificHeader"
404 (assertHasField "Name")
405 (assertHasField "SessionId")
406 (assertInt "SessionId")
407 (assertRange "SessionId" 1 4294967295)
408 (assertHasField "PeerSessionId")
409 (assertInt "PeerSessionId")
410 (assertRange "PeerSessionId" 1 4294967295)
411 (assertValueOneOf "Layer2SpecificHeader" [ "none" "default" ])
414 # NOTE Check whether the key starts with an @, in which case it is
415 # interpreted as the name of the credential from which the actual key
416 # shall be read by systemd-creds.
417 # Do not remove this check as the nix store is world-readable.
418 sectionWireGuard = checkUnitConfig "WireGuard" [
419 (assertKeyIsSystemdCredential "PrivateKey")
428 (assertInt "FirewallMark")
429 (assertRange "FirewallMark" 1 4294967295)
432 # NOTE Check whether the key starts with an @, in which case it is
433 # interpreted as the name of the credential from which the actual key
434 # shall be read by systemd-creds.
435 # Do not remove this check as the nix store is world-readable.
436 sectionWireGuardPeer = checkUnitConfigWithLegacyKey "wireguardPeerConfig" "WireGuardPeer" [
437 (assertKeyIsSystemdCredential "PresharedKey")
444 "PersistentKeepalive"
448 (assertInt "PersistentKeepalive")
449 (assertRange "PersistentKeepalive" 0 65535)
452 sectionBond = checkUnitConfig "Bond" [
460 "LearnPacketIntervalSec"
462 "AdActorSystemPriority"
470 "PrimaryReselectPolicy"
475 "DynamicTransmitLoadBalancing"
478 (assertValueOneOf "Mode" [
487 (assertValueOneOf "TransmitHashPolicy" [
494 (assertValueOneOf "LACPTransmitRate" ["slow" "fast"])
495 (assertValueOneOf "AdSelect" ["stable" "bandwidth" "count"])
496 (assertInt "AdActorSystemPriority")
497 (assertRange "AdActorSystemPriority" 1 65535)
498 (assertInt "AdUserPortKey")
499 (assertRange "AdUserPortKey" 0 1023)
500 (assertValueOneOf "FailOverMACPolicy" ["none" "active" "follow"])
501 (assertValueOneOf "ARPValidate" ["none" "active" "backup" "all"])
502 (assertValueOneOf "ARPAllTargets" ["any" "all"])
503 (assertValueOneOf "PrimaryReselectPolicy" ["always" "better" "failure"])
504 (assertInt "ResendIGMP")
505 (assertRange "ResendIGMP" 0 255)
506 (assertInt "PacketsPerSlave")
507 (assertRange "PacketsPerSlave" 0 65535)
508 (assertInt "GratuitousARP")
509 (assertRange "GratuitousARP" 0 255)
510 (assertValueOneOf "AllSlavesActive" boolValues)
511 (assertValueOneOf "DynamicTransmitLoadBalancing" boolValues)
512 (assertInt "MinLinks")
513 (assertMinimum "MinLinks" 0)
516 sectionXfrm = checkUnitConfig "Xfrm" [
521 (assertInt "InterfaceId")
522 (assertRange "InterfaceId" 1 4294967295)
523 (assertValueOneOf "Independent" boolValues)
526 sectionVRF = checkUnitConfig "VRF" [
531 (assertMinimum "Table" 0)
534 sectionWLAN = checkUnitConfig "WLAN" [
536 "PhysicalDevice" # systemd supports both strings ("phy0") and indexes (0) here.
540 # See https://github.com/systemd/systemd/blob/main/src/basic/linux/nl80211.h#L3382
541 (assertValueOneOf "Type" [
555 (assertValueOneOf "WDS" boolValues)
558 sectionBatmanAdvanced = checkUnitConfig "BatmanAdvanced" [
562 "BridgeLoopAvoidance"
563 "DistributedArpTable"
566 "OriginatorIntervalSec"
567 "GatewayBandwithDown"
571 (assertValueOneOf "GatewayMode" ["off" "client" "server"])
572 (assertValueOneOf "Aggregation" boolValues)
573 (assertValueOneOf "BridgeLoopAvoidance" boolValues)
574 (assertValueOneOf "DistributedArpTable" boolValues)
575 (assertValueOneOf "Fragmentation" boolValues)
576 (assertInt "HopPenalty")
577 (assertRange "HopPenalty" 0 255)
578 (assertValueOneOf "RoutingAlgorithm" ["batman-v" "batman-iv"])
584 sectionLink = checkUnitConfig "Link" [
594 "RequiredFamilyForOnline"
598 (assertMacAddress "MACAddress")
599 (assertByteFormat "MTUBytes")
600 (assertValueOneOf "ARP" boolValues)
601 (assertValueOneOf "Multicast" boolValues)
602 (assertValueOneOf "AllMulticast" boolValues)
603 (assertValueOneOf "Promiscuous" boolValues)
604 (assertValueOneOf "Unmanaged" boolValues)
606 (assertRange "Group" 0 2147483647)
607 (assertValueOneOf "RequiredForOnline" (boolValues ++ (
609 # https://freedesktop.org/software/systemd/man/networkctl.html#missing
610 operationalStates = [
621 operationalStateRanges = concatLists (imap0 (i: min: map (max: "${min}:${max}") (drop i operationalStates)) operationalStates);
623 operationalStates ++ operationalStateRanges
625 (assertValueOneOf "RequiredFamilyForOnline" [
631 (assertValueOneOf "ActivationPolicy" ([
641 sectionNetwork = checkUnitConfig "Network" [
646 "LinkLocalAddressing"
647 "IPv6LinkLocalAddressGenerationMode"
648 "IPv6StableSecretAddress"
651 "DefaultRouteOnDevice"
656 "DNSSECNegativeTrustAnchors"
671 "IPv6PrivacyExtensions"
673 "IPv6DuplicateAddressDetection"
675 "IPv6RetransmissionTimeSec"
676 "IPv4ReversePathFilter"
680 "IPv4ProxyARPPrivateVLAN"
682 "IPv6ProxyNDPAddress"
684 "DHCPPrefixDelegation"
700 "ConfigureWithoutCarrier"
706 # Note: For DHCP the values both, none, v4, v6 are deprecated
707 (assertValueOneOf "DHCP" (boolValues ++ ["ipv4" "ipv6"]))
708 (assertValueOneOf "DHCPServer" boolValues)
709 (assertValueOneOf "LinkLocalAddressing" (boolValues ++ ["ipv4" "ipv6" "fallback" "ipv4-fallback"]))
710 (assertValueOneOf "IPv6LinkLocalAddressGenerationMode" ["eui64" "none" "stable-privacy" "random"])
711 (assertValueOneOf "IPv4LLRoute" boolValues)
712 (assertValueOneOf "DefaultRouteOnDevice" boolValues)
713 (assertValueOneOf "LLMNR" (boolValues ++ ["resolve"]))
714 (assertValueOneOf "MulticastDNS" (boolValues ++ ["resolve"]))
715 (assertValueOneOf "DNSOverTLS" (boolValues ++ ["opportunistic"]))
716 (assertValueOneOf "DNSSEC" (boolValues ++ ["allow-downgrade"]))
717 (assertValueOneOf "LLDP" (boolValues ++ ["routers-only"]))
718 (assertValueOneOf "EmitLLDP" (boolValues ++ ["nearest-bridge" "non-tpmr-bridge" "customer-bridge"]))
719 (assertValueOneOf "UseDomains" (boolValues ++ ["route"]))
720 (assertValueOneOf "DNSDefaultRoute" boolValues)
721 (assertRemoved "IPForward" "IPv4Forwarding and IPv6Forwarding in systemd.network(5) and networkd.conf(5). Please note that setting these options on multiple interfaces may lead to unintended results, see https://github.com/systemd/systemd/issues/33414 or the relevant sections in systemd.network(5).")
722 (assertValueOneOf "IPv4Forwarding" boolValues)
723 (assertValueOneOf "IPv6Forwarding" boolValues)
724 (assertValueOneOf "IPMasquerade" (boolValues ++ ["ipv4" "ipv6" "both"]))
725 (assertValueOneOf "IPv6PrivacyExtensions" (boolValues ++ ["prefer-public" "kernel"]))
726 (assertValueOneOf "IPv6AcceptRA" boolValues)
727 (assertInt "IPv6DuplicateAddressDetection")
728 (assertMinimum "IPv6DuplicateAddressDetection" 0)
729 (assertInt "IPv6HopLimit")
730 (assertMinimum "IPv6HopLimit" 0)
731 (assertInt "IPv6RetransmissionTimeSec")
732 (assertValueOneOf "IPv4ReversePathFilter" ["no" "strict" "loose"])
733 (assertValueOneOf "IPv4AcceptLocal" boolValues)
734 (assertValueOneOf "IPv4RouteLocalnet" boolValues)
735 (assertValueOneOf "IPv4ProxyARP" boolValues)
736 (assertValueOneOf "IPv4ProxyARPPrivateVLAN" boolValues)
737 (assertValueOneOf "IPv6ProxyNDP" boolValues)
738 (assertValueOneOf "IPv6SendRA" boolValues)
739 (assertValueOneOf "DHCPPrefixDelegation" boolValues)
740 (assertByteFormat "IPv6MTUBytes")
741 (assertValueOneOf "KeepMaster" boolValues)
742 (assertValueOneOf "ActiveSlave" boolValues)
743 (assertValueOneOf "PrimarySlave" boolValues)
744 (assertValueOneOf "ConfigureWithoutCarrier" boolValues)
745 (assertValueOneOf "KeepConfiguration" (boolValues ++ ["static" "dhcp-on-stop" "dhcp"]))
748 sectionAddress = checkUnitConfigWithLegacyKey "addressConfig" "Address" [
758 "DuplicateAddressDetection"
759 "ManageTemporaryAddress"
765 (assertHasField "Address")
766 (assertValueOneOf "PreferredLifetime" ["forever" "infinity" "0" 0])
767 (assertInt "RouteMetric")
768 (assertValueOneOf "HomeAddress" boolValues)
769 (assertValueOneOf "DuplicateAddressDetection" ["ipv4" "ipv6" "both" "none"])
770 (assertValueOneOf "ManageTemporaryAddress" boolValues)
771 (assertValueOneOf "AddPrefixRoute" boolValues)
772 (assertValueOneOf "AutoJoin" boolValues)
775 sectionRoutingPolicyRule = checkUnitConfigWithLegacyKey "routingPolicyRuleConfig" "RoutingPolicyRule" [
792 "SuppressPrefixLength"
794 "SuppressInterfaceGroup"
796 (assertInt "TypeOfService")
797 (assertRange "TypeOfService" 0 255)
798 (assertRangeWithOptionalMask "FirewallMark" 1 4294967295)
799 (assertInt "Priority")
800 (assertValueOneOf "L3MasterDevice" boolValues)
801 (assertPortOrPortRange "SourcePort")
802 (assertPortOrPortRange "DestinationPort")
803 (assertValueOneOf "InvertRule" boolValues)
804 (assertValueOneOf "Family" ["ipv4" "ipv6" "both"])
805 (assertInt "SuppressPrefixLength")
806 (assertRange "SuppressPrefixLength" 0 128)
807 (assertValueOneOf "Type" ["blackhole" "unreachable" "prohibit"])
808 (assertRange "SuppressInterfaceGroup" 0 2147483647)
811 sectionRoute = checkUnitConfigWithLegacyKey "routeConfig" "Route" [
824 "InitialCongestionWindow"
825 "InitialAdvertisedReceiveWindow"
833 (assertValueOneOf "GatewayOnLink" boolValues)
835 (assertValueOneOf "IPv6Preference" ["low" "medium" "high"])
836 (assertValueOneOf "Scope" ["global" "site" "link" "host" "nowhere"])
837 (assertValueOneOf "Type" [
850 (assertValueOneOf "QuickAck" boolValues)
851 (assertValueOneOf "FastOpenNoCookie" boolValues)
852 (assertValueOneOf "TTLPropagate" boolValues)
853 (assertByteFormat "MTUBytes")
854 (assertValueOneOf "IPServiceType" ["CS6" "CS4"])
857 sectionDHCPv4 = checkUnitConfig "DHCPv4" [
874 "VendorClassIdentifier"
892 "FallbackLeaseLifetimeSec"
898 (assertValueOneOf "UseDNS" boolValues)
899 (assertValueOneOf "RoutesToDNS" boolValues)
900 (assertValueOneOf "UseNTP" boolValues)
901 (assertValueOneOf "UseSIP" boolValues)
902 (assertValueOneOf "UseMTU" boolValues)
903 (assertValueOneOf "Anonymize" boolValues)
904 (assertValueOneOf "SendHostname" boolValues)
905 (assertValueOneOf "UseHostname" boolValues)
906 (assertValueOneOf "UseDomains" (boolValues ++ ["route"]))
907 (assertValueOneOf "UseGateway" boolValues)
908 (assertValueOneOf "UseRoutes" boolValues)
909 (assertValueOneOf "UseTimezone" boolValues)
910 (assertValueOneOf "IPv6OnlyMode" boolValues)
911 (assertValueOneOf "ClientIdentifier" ["mac" "duid" "duid-only"])
913 (assertValueOneOf "RequestBroadcast" boolValues)
914 (assertInt "RouteMetric")
915 (assertValueOneOf "RapidCommit" boolValues)
916 (assertInt "RouteTable")
917 (assertRange "RouteTable" 0 4294967295)
918 (assertByteFormat "RouteMTUBytes")
919 (assertPort "ListenPort")
920 (assertValueOneOf "SendRelease" boolValues)
921 (assertValueOneOf "SendDecline" boolValues)
922 (assertValueOneOf "FallbackLeaseLifetimeSec" ["forever" "infinity"])
923 (assertValueOneOf "Use6RD" boolValues)
926 sectionDHCPv6 = checkUnitConfig "DHCPv6" [
940 "PrefixDelegationHint"
953 (assertValueOneOf "UseAddress" boolValues)
954 (assertValueOneOf "UseDNS" boolValues)
955 (assertValueOneOf "UseNTP" boolValues)
956 (assertValueOneOf "SendHostname" boolValues)
957 (assertValueOneOf "UseHostname" boolValues)
958 (assertValueOneOf "UseDomains" (boolValues ++ ["route"]))
959 (assertInt "RouteMetric")
960 (assertValueOneOf "RapidCommit" boolValues)
961 (assertValueOneOf "WithoutRA" ["no" "solicit" "information-request"])
962 (assertRange "SendOption" 1 65536)
964 (assertValueOneOf "UseDelegatedPrefix" boolValues)
965 (assertValueOneOf "SendRelease" boolValues)
968 sectionDHCPPrefixDelegation = checkUnitConfig "DHCPPrefixDelegation" [
975 "ManageTemporaryAddress"
980 (assertValueOneOf "Announce" boolValues)
981 (assertValueOneOf "Assign" boolValues)
982 (assertValueOneOf "ManageTemporaryAddress" boolValues)
983 (assertRange "RouteMetric" 0 4294967295)
986 sectionIPv6AcceptRA = checkUnitConfig "IPv6AcceptRA" [
991 "UseAutonomousPrefix"
1009 (assertValueOneOf "UseDNS" boolValues)
1010 (assertValueOneOf "UseDomains" (boolValues ++ ["route"]))
1011 (assertRange "RouteTable" 0 4294967295)
1012 (assertValueOneOf "UseAutonomousPrefix" boolValues)
1013 (assertValueOneOf "UseOnLinkPrefix" boolValues)
1014 (assertValueOneOf "DHCPv6Client" (boolValues ++ ["always"]))
1015 (assertValueOneOf "UseMTU" boolValues)
1016 (assertValueOneOf "UseGateway" boolValues)
1017 (assertValueOneOf "UseRoutePrefix" boolValues)
1018 (assertValueOneOf "UsePREF64" boolValues)
1021 sectionDHCPServer = checkUnitConfig "DHCPServer" [
1026 "DefaultLeaseTimeSec"
1049 "RelayAgentCircuitId"
1050 "RelayAgentRemoteId"
1054 "IPv6OnlyPreferredSec"
1057 (assertInt "PoolOffset")
1058 (assertMinimum "PoolOffset" 0)
1059 (assertInt "PoolSize")
1060 (assertMinimum "PoolSize" 0)
1061 (assertValueOneOf "EmitDNS" boolValues)
1062 (assertValueOneOf "EmitNTP" boolValues)
1063 (assertValueOneOf "EmitSIP" boolValues)
1064 (assertValueOneOf "EmitPOP3" boolValues)
1065 (assertValueOneOf "EmitSMTP" boolValues)
1066 (assertValueOneOf "EmitLPR" boolValues)
1067 (assertValueOneOf "EmitRouter" boolValues)
1068 (assertValueOneOf "EmitTimezone" boolValues)
1069 (assertValueOneOf "BindToInterface" boolValues)
1070 (assertValueOneOf "PersistLeases" boolValues)
1073 sectionIPv6SendRA = checkUnitConfig "IPv6SendRA" [
1088 "HomeAgentLifetimeSec"
1089 "HomeAgentPreference"
1091 (assertValueOneOf "Managed" boolValues)
1092 (assertValueOneOf "OtherInformation" boolValues)
1093 (assertValueOneOf "RouterPreference" ["high" "medium" "low" "normal" "default"])
1094 (assertInt "HopLimit")
1095 (assertValueOneOf "EmitDNS" boolValues)
1096 (assertValueOneOf "EmitDomains" boolValues)
1097 (assertValueOneOf "HomeAgent" boolValues)
1098 (assertInt "HomeAgentPreference")
1101 sectionIPv6PREF64Prefix = checkUnitConfigWithLegacyKey "ipv6PREF64PrefixConfig" "IPv6PREF64Prefix" [
1106 (assertInt "LifetimeSec")
1109 sectionIPv6Prefix = checkUnitConfigWithLegacyKey "ipv6PrefixConfig" "IPv6Prefix" [
1111 "AddressAutoconfiguration"
1114 "PreferredLifetimeSec"
1119 (assertValueOneOf "AddressAutoconfiguration" boolValues)
1120 (assertValueOneOf "OnLink" boolValues)
1121 (assertValueOneOf "Assign" boolValues)
1124 sectionIPv6RoutePrefix = checkUnitConfigWithLegacyKey "ipv6RoutePrefixConfig" "IPv6RoutePrefix" [
1129 (assertHasField "Route")
1130 (assertInt "LifetimeSec")
1133 sectionDHCPServerStaticLease = checkUnitConfigWithLegacyKey "dhcpServerStaticLeaseConfig" "DHCPServerStaticLease" [
1138 (assertHasField "MACAddress")
1139 (assertHasField "Address")
1140 (assertMacAddress "MACAddress")
1143 sectionBridge = checkUnitConfig "Bridge" [
1147 "MulticastToUnicast"
1148 "NeighborSuppression"
1161 (assertValueOneOf "UnicastFlood" boolValues)
1162 (assertValueOneOf "MulticastFlood" boolValues)
1163 (assertValueOneOf "MulticastToUnicast" boolValues)
1164 (assertValueOneOf "NeighborSuppression" boolValues)
1165 (assertValueOneOf "Learning" boolValues)
1166 (assertValueOneOf "HairPin" boolValues)
1167 (assertValueOneOf "Isolated" boolValues)
1168 (assertValueOneOf "UseBPDU" boolValues)
1169 (assertValueOneOf "FastLeave" boolValues)
1170 (assertValueOneOf "AllowPortToBeRoot" boolValues)
1171 (assertValueOneOf "ProxyARP" boolValues)
1172 (assertValueOneOf "ProxyARPWiFi" boolValues)
1173 (assertValueOneOf "MulticastRouter" [ "no" "query" "permanent" "temporary" ])
1175 (assertRange "Cost" 1 65535)
1176 (assertInt "Priority")
1177 (assertRange "Priority" 0 63)
1180 sectionBridgeFDB = checkUnitConfigWithLegacyKey "bridgeFDBConfig" "BridgeFDB" [
1189 (assertHasField "MACAddress")
1190 (assertInt "VLANId")
1191 (assertRange "VLANId" 0 4094)
1193 (assertRange "VNI" 1 16777215)
1194 (assertValueOneOf "AssociatedWith" [ "use" "self" "master" "router" ])
1197 sectionBridgeMDB = checkUnitConfigWithLegacyKey "bridgeMDBConfig" "BridgeMDB" [
1199 "MulticastGroupAddress"
1202 (assertHasField "MulticastGroupAddress")
1203 (assertInt "VLANId")
1204 (assertRange "VLANId" 0 4094)
1207 sectionLLDP = checkUnitConfig "LLDP" [
1213 sectionCAN = checkUnitConfig "CAN" [
1218 "PropagationSegment"
1219 "PhaseBufferSegment1"
1220 "PhaseBufferSegment2"
1224 "DataTimeQuantaNSec"
1225 "DataPropagationSegment"
1226 "DataPhaseBufferSegment1"
1227 "DataPhaseBufferSegment2"
1239 "ClassicDataLengthCode"
1241 (assertInt "TimeQuantaNSec" )
1242 (assertRange "TimeQuantaNSec" 0 4294967295 )
1243 (assertInt "PropagationSegment" )
1244 (assertRange "PropagationSegment" 0 4294967295 )
1245 (assertInt "PhaseBufferSegment1" )
1246 (assertRange "PhaseBufferSegment1" 0 4294967295 )
1247 (assertInt "PhaseBufferSegment2" )
1248 (assertRange "PhaseBufferSegment2" 0 4294967295 )
1249 (assertInt "SyncJumpWidth" )
1250 (assertRange "SyncJumpWidth" 0 4294967295 )
1251 (assertInt "DataTimeQuantaNSec" )
1252 (assertRange "DataTimeQuantaNSec" 0 4294967295 )
1253 (assertInt "DataPropagationSegment" )
1254 (assertRange "DataPropagationSegment" 0 4294967295 )
1255 (assertInt "DataPhaseBufferSegment1" )
1256 (assertRange "DataPhaseBufferSegment1" 0 4294967295 )
1257 (assertInt "DataPhaseBufferSegment2" )
1258 (assertRange "DataPhaseBufferSegment2" 0 4294967295 )
1259 (assertInt "DataSyncJumpWidth" )
1260 (assertRange "DataSyncJumpWidth" 0 4294967295 )
1261 (assertValueOneOf "FDMode" boolValues)
1262 (assertValueOneOf "FDNonISO" boolValues)
1263 (assertValueOneOf "TripleSampling" boolValues)
1264 (assertValueOneOf "BusErrorReporting" boolValues)
1265 (assertValueOneOf "ListenOnly" boolValues)
1266 (assertValueOneOf "Loopback" boolValues)
1267 (assertValueOneOf "OneShot" boolValues)
1268 (assertValueOneOf "PresumeAck" boolValues)
1269 (assertValueOneOf "ClassicDataLengthCode" boolValues)
1272 sectionIPoIB = checkUnitConfig "IPoIB" [
1275 "IgnoreUserspaceMulticastGroup"
1277 (assertValueOneOf "Mode" [ "datagram" "connected" ])
1278 (assertValueOneOf "IgnoreUserspaceMulticastGroup" boolValues)
1281 sectionQDisc = checkUnitConfig "QDisc" [
1286 (assertValueOneOf "Parent" [ "clsact" "ingress" ])
1289 sectionNetworkEmulator = checkUnitConfig "NetworkEmulator" [
1299 (assertInt "PacketLimit")
1300 (assertRange "PacketLimit" 0 4294967294)
1303 sectionTokenBucketFilter = checkUnitConfig "TokenBucketFilter" [
1317 sectionPIE = checkUnitConfig "PIE" [
1323 (assertInt "PacketLimit")
1324 (assertRange "PacketLimit" 1 4294967294)
1327 sectionFlowQueuePIE = checkUnitConfig "FlowQueuePIE" [
1333 (assertInt "PacketLimit")
1334 (assertRange "PacketLimit" 1 4294967294)
1337 sectionStochasticFairBlue = checkUnitConfig "StochasticFairBlue" [
1343 (assertInt "PacketLimit")
1344 (assertRange "PacketLimit" 1 4294967294)
1347 sectionStochasticFairnessQueueing = checkUnitConfig "StochasticFairnessQueueing" [
1353 (assertInt "PerturbPeriodSec")
1356 sectionBFIFO = checkUnitConfig "BFIFO" [
1364 sectionPFIFO = checkUnitConfig "PFIFO" [
1370 (assertInt "PacketLimit")
1371 (assertRange "PacketLimit" 0 4294967294)
1374 sectionPFIFOHeadDrop = checkUnitConfig "PFIFOHeadDrop" [
1380 (assertInt "PacketLimit")
1381 (assertRange "PacketLimit" 0 4294967294)
1384 sectionPFIFOFast = checkUnitConfig "PFIFOFast" [
1391 sectionCAKE = checkUnitConfig "CAKE" [
1403 "PriorityQueueingPreset"
1410 (assertValueOneOf "AutoRateIngress" boolValues)
1411 (assertInt "OverheadBytes")
1412 (assertRange "OverheadBytes" (-64) 256)
1413 (assertInt "MPUBytes")
1414 (assertRange "MPUBytes" 1 256)
1415 (assertValueOneOf "CompensationMode" [ "none" "atm" "ptm" ])
1416 (assertValueOneOf "UseRawPacketSize" boolValues)
1417 (assertValueOneOf "FlowIsolationMode"
1428 (assertValueOneOf "NAT" boolValues)
1429 (assertValueOneOf "PriorityQueueingPreset"
1437 (assertInt "FirewallMark")
1438 (assertRange "FirewallMark" 1 4294967295)
1439 (assertValueOneOf "Wash" boolValues)
1440 (assertValueOneOf "SplitGSO" boolValues)
1441 (assertValueOneOf "AckFilter" (boolValues ++ ["aggressive"]))
1444 sectionControlledDelay = checkUnitConfig "ControlledDelay" [
1454 (assertValueOneOf "ECN" boolValues)
1457 sectionDeficitRoundRobinScheduler = checkUnitConfig "DeficitRoundRobinScheduler" [
1464 sectionDeficitRoundRobinSchedulerClass = checkUnitConfig "DeficitRoundRobinSchedulerClass" [
1472 sectionEnhancedTransmissionSelection = checkUnitConfig "EnhancedTransmissionSelection" [
1482 (assertRange "Bands" 1 16)
1483 (assertInt "StrictBands")
1484 (assertRange "StrictBands" 1 16)
1487 sectionGenericRandomEarlyDetection = checkUnitConfig "GenericRandomEarlyDetection" [
1492 "DefaultVirtualQueue"
1495 (assertInt "VirtualQueues")
1496 (assertRange "VirtualQueues" 1 16)
1497 (assertInt "DefaultVirtualQueue")
1498 (assertRange "DefaultVirtualQueue" 1 16)
1499 (assertValueOneOf "GenericRIO" boolValues)
1502 sectionFairQueueingControlledDelay = checkUnitConfig "FairQueueingControlledDelay" [
1515 (assertInt "PacketLimit")
1517 (assertValueOneOf "ECN" boolValues)
1520 sectionFairQueueing = checkUnitConfig "FairQueueing" [
1527 "InitualQuantumBytes"
1534 (assertInt "PacketLimit")
1535 (assertInt "FlowLimit")
1536 (assertInt "OrphanMask")
1537 (assertValueOneOf "Pacing" boolValues)
1540 sectionTrivialLinkEqualizer = checkUnitConfig "TrivialLinkEqualizer" [
1548 sectionHierarchyTokenBucket = checkUnitConfig "HierarchyTokenBucket" [
1555 (assertInt "RateToQuantum")
1558 sectionHierarchyTokenBucketClass = checkUnitConfig "HierarchyTokenBucketClass" [
1573 sectionHeavyHitterFilter = checkUnitConfig "HeavyHitterFilter" [
1579 (assertInt "PacketLimit")
1580 (assertRange "PacketLimit" 0 4294967294)
1583 sectionQuickFairQueueing = checkUnitConfig "QuickFairQueueing" [
1590 sectionQuickFairQueueingClass = checkUnitConfig "QuickFairQueueingClass" [
1597 (assertInt "Weight")
1598 (assertRange "Weight" 1 1023)
1601 sectionBridgeVLAN = checkUnitConfigWithLegacyKey "bridgeVLANConfig" "BridgeVLAN" [
1608 (assertRange "PVID" 0 4094)
1613 commonNetworkOptions = {
1619 Whether to manage network configuration using {command}`systemd-network`.
1621 This also enables {option}`systemd.networkd.enable`.
1625 matchConfig = mkOption {
1627 example = { Name = "eth0"; };
1628 type = types.attrsOf unitOption;
1630 Each attribute in this set specifies an option in the
1631 `[Match]` section of the unit. See
1632 {manpage}`systemd.link(5)`
1633 {manpage}`systemd.netdev(5)`
1634 {manpage}`systemd.network(5)`
1639 extraConfig = mkOption {
1642 description = "Extra configuration append to unit";
1647 networkConfig = mkOption {
1649 example = { SpeedMeter = true; ManageForeignRoutingPolicyRules = false; };
1650 type = types.addCheck (types.attrsOf unitOption) check.global.sectionNetwork;
1652 Each attribute in this set specifies an option in the
1653 `[Network]` section of the networkd config.
1654 See {manpage}`networkd.conf(5)` for details.
1658 dhcpV4Config = mkOption {
1660 example = { DUIDType = "vendor"; };
1661 type = types.addCheck (types.attrsOf unitOption) check.global.sectionDHCPv4;
1663 Each attribute in this set specifies an option in the
1664 `[DHCPv4]` section of the networkd config.
1665 See {manpage}`networkd.conf(5)` for details.
1669 dhcpV6Config = mkOption {
1671 example = { DUIDType = "vendor"; };
1672 type = types.addCheck (types.attrsOf unitOption) check.global.sectionDHCPv6;
1674 Each attribute in this set specifies an option in the
1675 `[DHCPv6]` section of the networkd config.
1676 See {manpage}`networkd.conf(5)` for details.
1681 linkOptions = commonNetworkOptions // {
1682 # overwrite enable option from above
1687 Whether to enable this .link unit. It's handled by udev no matter if {command}`systemd-networkd` is enabled or not
1691 linkConfig = mkOption {
1693 example = { MACAddress = "00:ff:ee:aa:cc:dd"; };
1694 type = types.addCheck (types.attrsOf unitOption) check.link.sectionLink;
1696 Each attribute in this set specifies an option in the
1697 `[Link]` section of the unit. See
1698 {manpage}`systemd.link(5)` for details.
1704 mkSubsectionType = oldKey: checkF:
1706 type = types.addCheck (types.attrsOf unitOption) checkF;
1710 final = type.merge loc defs;
1714 "Using '${oldKey}' is deprecated! Move all attributes inside one level up and remove it."
1720 netdevOptions = commonNetworkOptions // {
1722 netdevConfig = mkOption {
1723 example = { Name = "mybridge"; Kind = "bridge"; };
1724 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionNetdev;
1726 Each attribute in this set specifies an option in the
1727 `[Netdev]` section of the unit. See
1728 {manpage}`systemd.netdev(5)` for details.
1732 bridgeConfig = mkOption {
1734 example = { STP = true; };
1735 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionBridge;
1737 Each attribute in this set specifies an option in the
1738 `[Bridge]` section of the unit. See
1739 {manpage}`systemd.netdev(5)` for details.
1743 vlanConfig = mkOption {
1745 example = { Id = 4; };
1746 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionVLAN;
1748 Each attribute in this set specifies an option in the
1749 `[VLAN]` section of the unit. See
1750 {manpage}`systemd.netdev(5)` for details.
1754 ipvlanConfig = mkOption {
1756 example = { Mode = "L2"; Flags = "private"; };
1757 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionIPVLAN;
1759 Each attribute in this set specifies an option in the `[IPVLAN]` section of the unit.
1760 See {manpage}`systemd.netdev(5)` for details.
1764 ipvtapConfig = mkOption {
1766 example = { Mode = "L3"; Flags = "vepa"; };
1767 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionIPVTAP;
1769 Each attribute in this set specifies an option in the `[IPVTAP]` section of the unit.
1770 See {manpage}`systemd.netdev(5)` for details.
1774 macvlanConfig = mkOption {
1776 example = { Mode = "private"; };
1777 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionMACVLAN;
1779 Each attribute in this set specifies an option in the
1780 `[MACVLAN]` section of the unit. See
1781 {manpage}`systemd.netdev(5)` for details.
1785 vxlanConfig = mkOption {
1787 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionVXLAN;
1789 Each attribute in this set specifies an option in the
1790 `[VXLAN]` section of the unit. See
1791 {manpage}`systemd.netdev(5)` for details.
1795 tunnelConfig = mkOption {
1797 example = { Remote = "192.168.1.1"; };
1798 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionTunnel;
1800 Each attribute in this set specifies an option in the
1801 `[Tunnel]` section of the unit. See
1802 {manpage}`systemd.netdev(5)` for details.
1806 fooOverUDPConfig = mkOption {
1808 example = { Port = 9001; };
1809 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionFooOverUDP;
1811 Each attribute in this set specifies an option in the
1812 `[FooOverUDP]` section of the unit. See
1813 {manpage}`systemd.netdev(5)` for details.
1817 peerConfig = mkOption {
1819 example = { Name = "veth2"; };
1820 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionPeer;
1822 Each attribute in this set specifies an option in the
1823 `[Peer]` section of the unit. See
1824 {manpage}`systemd.netdev(5)` for details.
1828 tunConfig = mkOption {
1830 example = { User = "openvpn"; };
1831 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionTun;
1833 Each attribute in this set specifies an option in the
1834 `[Tun]` section of the unit. See
1835 {manpage}`systemd.netdev(5)` for details.
1839 tapConfig = mkOption {
1841 example = { User = "openvpn"; };
1842 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionTap;
1844 Each attribute in this set specifies an option in the
1845 `[Tap]` section of the unit. See
1846 {manpage}`systemd.netdev(5)` for details.
1850 l2tpConfig = mkOption {
1856 Remote = "192.168.30.101";
1857 EncapsulationType = "ip";
1859 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionL2TP;
1861 Each attribute in this set specifies an option in the
1862 `[L2TP]` section of the unit. See
1863 {manpage}`systemd.netdev(5)` for details.
1867 l2tpSessions = mkOption {
1874 type = types.listOf (mkSubsectionType "l2tpSessionConfig" check.netdev.sectionL2TPSession);
1876 Each item in this array specifies an option in the
1877 `[L2TPSession]` section of the unit. See
1878 {manpage}`systemd.netdev(5)` for details.
1882 wireguardConfig = mkOption {
1885 PrivateKeyFile = "/etc/wireguard/secret.key";
1889 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionWireGuard;
1891 Each attribute in this set specifies an option in the
1892 `[WireGuard]` section of the unit. See
1893 {manpage}`systemd.netdev(5)` for details.
1894 Use `PrivateKeyFile` instead of
1895 `PrivateKey`: the nix store is
1900 wireguardPeers = mkOption {
1903 Endpoint = "192.168.1.1:51820";
1904 PublicKey = "27s0OvaBBdHoJYkH9osZpjpgSOVNw+RaKfboT/Sfq0g=";
1905 PresharedKeyFile = "/etc/wireguard/psk.key";
1906 AllowedIPs = [ "10.0.0.1/32" ];
1907 PersistentKeepalive = 15;
1909 type = types.listOf (mkSubsectionType "wireguardPeerConfig" check.netdev.sectionWireGuardPeer);
1911 Each item in this array specifies an option in the
1912 `[WireGuardPeer]` section of the unit. See
1913 {manpage}`systemd.netdev(5)` for details.
1914 Use `PresharedKeyFile` instead of
1915 `PresharedKey`: the nix store is
1920 bondConfig = mkOption {
1922 example = { Mode = "802.3ad"; };
1923 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionBond;
1925 Each attribute in this set specifies an option in the
1926 `[Bond]` section of the unit. See
1927 {manpage}`systemd.netdev(5)` for details.
1931 xfrmConfig = mkOption {
1933 example = { InterfaceId = 1; };
1934 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionXfrm;
1936 Each attribute in this set specifies an option in the
1937 `[Xfrm]` section of the unit. See
1938 {manpage}`systemd.netdev(5)` for details.
1942 vrfConfig = mkOption {
1944 example = { Table = 2342; };
1945 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionVRF;
1947 Each attribute in this set specifies an option in the
1948 `[VRF]` section of the unit. See
1949 {manpage}`systemd.netdev(5)` for details.
1950 A detailed explanation about how VRFs work can be found in the
1951 [kernel docs](https://www.kernel.org/doc/Documentation/networking/vrf.txt).
1955 wlanConfig = mkOption {
1957 example = { PhysicalDevice = 0; Type = "station"; };
1958 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionWLAN;
1960 Each attribute in this set specifies an option in the `[WLAN]` section of the unit.
1961 See {manpage}`systemd.netdev(5)` for details.
1965 batmanAdvancedConfig = mkOption {
1968 GatewayMode = "server";
1969 RoutingAlgorithm = "batman-v";
1971 type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionBatmanAdvanced;
1973 Each attribute in this set specifies an option in the
1974 `[BatmanAdvanced]` section of the unit. See
1975 {manpage}`systemd.netdev(5)` for details.
1981 networkOptions = commonNetworkOptions // {
1983 linkConfig = mkOption {
1985 example = { Unmanaged = true; };
1986 type = types.addCheck (types.attrsOf unitOption) check.network.sectionLink;
1988 Each attribute in this set specifies an option in the
1989 `[Link]` section of the unit. See
1990 {manpage}`systemd.network(5)` for details.
1994 networkConfig = mkOption {
1996 example = { Description = "My Network"; };
1997 type = types.addCheck (types.attrsOf unitOption) check.network.sectionNetwork;
1999 Each attribute in this set specifies an option in the
2000 `[Network]` section of the unit. See
2001 {manpage}`systemd.network(5)` for details.
2005 # systemd.network.networks.*.dhcpConfig has been deprecated in favor of ….dhcpV4Config
2006 # Produce a nice warning message so users know it is gone.
2007 dhcpConfig = mkOption {
2009 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.";
2012 dhcpV4Config = mkOption {
2014 example = { UseDNS = true; UseRoutes = true; };
2015 type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPv4;
2017 Each attribute in this set specifies an option in the
2018 `[DHCPv4]` section of the unit. See
2019 {manpage}`systemd.network(5)` for details.
2023 dhcpV6Config = mkOption {
2025 example = { UseDNS = true; };
2026 type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPv6;
2028 Each attribute in this set specifies an option in the
2029 `[DHCPv6]` section of the unit. See
2030 {manpage}`systemd.network(5)` for details.
2034 dhcpV6PrefixDelegationConfig = mkOption {
2036 apply = _: throw "The option `systemd.network.networks.<name>.dhcpV6PrefixDelegationConfig` has been renamed to `systemd.network.networks.<name>.dhcpPrefixDelegationConfig`.";
2039 dhcpPrefixDelegationConfig = mkOption {
2041 example = { SubnetId = "auto"; Announce = true; };
2042 type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPPrefixDelegation;
2044 Each attribute in this set specifies an option in the
2045 `[DHCPPrefixDelegation]` section of the unit. See
2046 {manpage}`systemd.network(5)` for details.
2050 ipv6AcceptRAConfig = mkOption {
2052 example = { UseDNS = true; DHCPv6Client = "always"; };
2053 type = types.addCheck (types.attrsOf unitOption) check.network.sectionIPv6AcceptRA;
2055 Each attribute in this set specifies an option in the
2056 `[IPv6AcceptRA]` section of the unit. See
2057 {manpage}`systemd.network(5)` for details.
2061 dhcpServerConfig = mkOption {
2063 example = { PoolOffset = 50; EmitDNS = false; };
2064 type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPServer;
2066 Each attribute in this set specifies an option in the
2067 `[DHCPServer]` section of the unit. See
2068 {manpage}`systemd.network(5)` for details.
2072 # systemd.network.networks.*.ipv6PrefixDelegationConfig has been deprecated
2073 # in 247 in favor of systemd.network.networks.*.ipv6SendRAConfig.
2074 ipv6PrefixDelegationConfig = mkOption {
2076 apply = _: throw "The option `systemd.network.networks.*.ipv6PrefixDelegationConfig` has been replaced by `systemd.network.networks.*.ipv6SendRAConfig`.";
2079 ipv6SendRAConfig = mkOption {
2081 example = { EmitDNS = true; Managed = true; OtherInformation = true; };
2082 type = types.addCheck (types.attrsOf unitOption) check.network.sectionIPv6SendRA;
2084 Each attribute in this set specifies an option in the
2085 `[IPv6SendRA]` section of the unit. See
2086 {manpage}`systemd.network(5)` for details.
2090 ipv6PREF64Prefixes = mkOption {
2092 example = [ { Prefix = "64:ff9b::/96"; } ];
2093 type = types.listOf (mkSubsectionType "ipv6PREF64PrefixConfig" check.network.sectionIPv6PREF64Prefix);
2095 A list of IPv6PREF64Prefix sections to be added to the unit. See
2096 {manpage}`systemd.network(5)` for details.
2100 dhcpServerStaticLeases = mkOption {
2102 example = [ { MACAddress = "65:43:4a:5b:d8:5f"; Address = "192.168.1.42"; } ];
2103 type = types.listOf (mkSubsectionType "dhcpServerStaticLeaseConfig" check.network.sectionDHCPServerStaticLease);
2105 A list of DHCPServerStaticLease sections to be added to the unit. See
2106 {manpage}`systemd.network(5)` for details.
2110 ipv6Prefixes = mkOption {
2112 example = [ { AddressAutoconfiguration = true; OnLink = true; } ];
2113 type = types.listOf (mkSubsectionType "ipv6PrefixConfig" check.network.sectionIPv6Prefix);
2115 A list of ipv6Prefix sections to be added to the unit. See
2116 {manpage}`systemd.network(5)` for details.
2120 ipv6RoutePrefixes = mkOption {
2122 example = [ { Route = "fd00::/64"; LifetimeSec = 3600; } ];
2123 type = types.listOf (mkSubsectionType "ipv6RoutePrefixConfig" check.network.sectionIPv6RoutePrefix);
2125 A list of ipv6RoutePrefix sections to be added to the unit. See
2126 {manpage}`systemd.network(5)` for details.
2130 bridgeConfig = mkOption {
2132 example = { MulticastFlood = false; Cost = 20; };
2133 type = types.addCheck (types.attrsOf unitOption) check.network.sectionBridge;
2135 Each attribute in this set specifies an option in the
2136 `[Bridge]` section of the unit. See
2137 {manpage}`systemd.network(5)` for details.
2141 bridgeFDBs = mkOption {
2143 example = [ { MACAddress = "90:e2:ba:43:fc:71"; Destination = "192.168.100.4"; VNI = 3600; } ];
2144 type = types.listOf (mkSubsectionType "bridgeFDBConfig" check.network.sectionBridgeFDB);
2146 A list of BridgeFDB sections to be added to the unit. See
2147 {manpage}`systemd.network(5)` for details.
2151 bridgeMDBs = mkOption {
2153 example = [ { MulticastGroupAddress = "ff02::1:2:3:4"; VLANId = 10; } ];
2154 type = types.listOf (mkSubsectionType "bridgeMDBConfig" check.network.sectionBridgeMDB);
2156 A list of BridgeMDB sections to be added to the unit. See
2157 {manpage}`systemd.network(5)` for details.
2161 lldpConfig = mkOption {
2163 example = { MUDURL = "https://things.example.org/product_abc123/v5"; };
2164 type = types.addCheck (types.attrsOf unitOption) check.network.sectionLLDP;
2166 Each attribute in this set specifies an option in the
2167 `[LLDP]` section of the unit. See
2168 {manpage}`systemd.network(5)` for details.
2172 canConfig = mkOption {
2175 type = types.addCheck (types.attrsOf unitOption) check.network.sectionCAN;
2177 Each attribute in this set specifies an option in the
2178 `[CAN]` section of the unit. See
2179 {manpage}`systemd.network(5)` for details.
2183 ipoIBConfig = mkOption {
2186 type = types.addCheck (types.attrsOf unitOption) check.network.sectionIPoIB;
2188 Each attribute in this set specifies an option in the
2189 `[IPoIB]` section of the unit. See
2190 {manpage}`systemd.network(5)` for details.
2194 qdiscConfig = mkOption {
2196 example = { Parent = "ingress"; };
2197 type = types.addCheck (types.attrsOf unitOption) check.network.sectionQDisc;
2199 Each attribute in this set specifies an option in the
2200 `[QDisc]` section of the unit. See
2201 {manpage}`systemd.network(5)` for details.
2205 networkEmulatorConfig = mkOption {
2207 example = { Parent = "ingress"; DelaySec = "20msec"; };
2208 type = types.addCheck (types.attrsOf unitOption) check.network.sectionNetworkEmulator;
2210 Each attribute in this set specifies an option in the
2211 `[NetworkEmulator]` section of the unit. See
2212 {manpage}`systemd.network(5)` for details.
2216 tokenBucketFilterConfig = mkOption {
2218 example = { Parent = "ingress"; Rate = "100k"; };
2219 type = types.addCheck (types.attrsOf unitOption) check.network.sectionTokenBucketFilter;
2221 Each attribute in this set specifies an option in the
2222 `[TokenBucketFilter]` section of the unit. See
2223 {manpage}`systemd.network(5)` for details.
2227 pieConfig = mkOption {
2229 example = { Parent = "ingress"; PacketLimit = "3847"; };
2230 type = types.addCheck (types.attrsOf unitOption) check.network.sectionPIE;
2232 Each attribute in this set specifies an option in the
2233 `[PIE]` section of the unit. See
2234 {manpage}`systemd.network(5)` for details.
2238 flowQueuePIEConfig = mkOption {
2240 example = { Parent = "ingress"; PacketLimit = "3847"; };
2241 type = types.addCheck (types.attrsOf unitOption) check.network.sectionFlowQueuePIE;
2243 Each attribute in this set specifies an option in the
2244 `[FlowQueuePIE]` section of the unit. See
2245 {manpage}`systemd.network(5)` for details.
2249 stochasticFairBlueConfig = mkOption {
2251 example = { Parent = "ingress"; PacketLimit = "3847"; };
2252 type = types.addCheck (types.attrsOf unitOption) check.network.sectionStochasticFairBlue;
2254 Each attribute in this set specifies an option in the
2255 `[StochasticFairBlue]` section of the unit. See
2256 {manpage}`systemd.network(5)` for details.
2260 stochasticFairnessQueueingConfig = mkOption {
2262 example = { Parent = "ingress"; PerturbPeriodSec = "30"; };
2263 type = types.addCheck (types.attrsOf unitOption) check.network.sectionStochasticFairnessQueueing;
2265 Each attribute in this set specifies an option in the
2266 `[StochasticFairnessQueueing]` section of the unit. See
2267 {manpage}`systemd.network(5)` for details.
2271 bfifoConfig = mkOption {
2273 example = { Parent = "ingress"; LimitBytes = "20K"; };
2274 type = types.addCheck (types.attrsOf unitOption) check.network.sectionBFIFO;
2276 Each attribute in this set specifies an option in the
2277 `[BFIFO]` section of the unit. See
2278 {manpage}`systemd.network(5)` for details.
2282 pfifoConfig = mkOption {
2284 example = { Parent = "ingress"; PacketLimit = "300"; };
2285 type = types.addCheck (types.attrsOf unitOption) check.network.sectionPFIFO;
2287 Each attribute in this set specifies an option in the
2288 `[PFIFO]` section of the unit. See
2289 {manpage}`systemd.network(5)` for details.
2293 pfifoHeadDropConfig = mkOption {
2295 example = { Parent = "ingress"; PacketLimit = "300"; };
2296 type = types.addCheck (types.attrsOf unitOption) check.network.sectionPFIFOHeadDrop;
2298 Each attribute in this set specifies an option in the
2299 `[PFIFOHeadDrop]` section of the unit. See
2300 {manpage}`systemd.network(5)` for details.
2304 pfifoFastConfig = mkOption {
2306 example = { Parent = "ingress"; };
2307 type = types.addCheck (types.attrsOf unitOption) check.network.sectionPFIFOFast;
2309 Each attribute in this set specifies an option in the
2310 `[PFIFOFast]` section of the unit. See
2311 {manpage}`systemd.network(5)` for details.
2315 cakeConfig = mkOption {
2317 example = { Bandwidth = "40M"; OverheadBytes = 8; CompensationMode = "ptm"; };
2318 type = types.addCheck (types.attrsOf unitOption) check.network.sectionCAKE;
2320 Each attribute in this set specifies an option in the
2321 `[CAKE]` section of the unit. See
2322 {manpage}`systemd.network(5)` for details.
2326 controlledDelayConfig = mkOption {
2328 example = { Parent = "ingress"; TargetSec = "20msec"; };
2329 type = types.addCheck (types.attrsOf unitOption) check.network.sectionControlledDelay;
2331 Each attribute in this set specifies an option in the
2332 `[ControlledDelay]` section of the unit. See
2333 {manpage}`systemd.network(5)` for details.
2337 deficitRoundRobinSchedulerConfig = mkOption {
2339 example = { Parent = "root"; };
2340 type = types.addCheck (types.attrsOf unitOption) check.network.sectionDeficitRoundRobinScheduler;
2342 Each attribute in this set specifies an option in the
2343 `[DeficitRoundRobinScheduler]` section of the unit. See
2344 {manpage}`systemd.network(5)` for details.
2348 deficitRoundRobinSchedulerClassConfig = mkOption {
2350 example = { Parent = "root"; QuantumBytes = "300k"; };
2351 type = types.addCheck (types.attrsOf unitOption) check.network.sectionDeficitRoundRobinSchedulerClass;
2353 Each attribute in this set specifies an option in the
2354 `[DeficitRoundRobinSchedulerClass]` section of the unit. See
2355 {manpage}`systemd.network(5)` for details.
2359 enhancedTransmissionSelectionConfig = mkOption {
2361 example = { Parent = "root"; QuantumBytes = "300k"; Bands = 3; PriorityMap = "100 200 300"; };
2362 type = types.addCheck (types.attrsOf unitOption) check.network.sectionEnhancedTransmissionSelection;
2364 Each attribute in this set specifies an option in the
2365 `[EnhancedTransmissionSelection]` section of the unit. See
2366 {manpage}`systemd.network(5)` for details.
2370 genericRandomEarlyDetectionConfig = mkOption {
2372 example = { Parent = "root"; VirtualQueues = 5; DefaultVirtualQueue = 3; };
2373 type = types.addCheck (types.attrsOf unitOption) check.network.sectionGenericRandomEarlyDetection;
2375 Each attribute in this set specifies an option in the
2376 `[GenericRandomEarlyDetection]` section of the unit. See
2377 {manpage}`systemd.network(5)` for details.
2381 fairQueueingControlledDelayConfig = mkOption {
2383 example = { Parent = "root"; Flows = 5; };
2384 type = types.addCheck (types.attrsOf unitOption) check.network.sectionFairQueueingControlledDelay;
2386 Each attribute in this set specifies an option in the
2387 `[FairQueueingControlledDelay]` section of the unit. See
2388 {manpage}`systemd.network(5)` for details.
2392 fairQueueingConfig = mkOption {
2394 example = { Parent = "root"; FlowLimit = 5; };
2395 type = types.addCheck (types.attrsOf unitOption) check.network.sectionFairQueueing;
2397 Each attribute in this set specifies an option in the
2398 `[FairQueueing]` section of the unit. See
2399 {manpage}`systemd.network(5)` for details.
2403 trivialLinkEqualizerConfig = mkOption {
2405 example = { Parent = "root"; Id = 0; };
2406 type = types.addCheck (types.attrsOf unitOption) check.network.sectionTrivialLinkEqualizer;
2408 Each attribute in this set specifies an option in the
2409 `[TrivialLinkEqualizer]` section of the unit. See
2410 {manpage}`systemd.network(5)` for details.
2414 hierarchyTokenBucketConfig = mkOption {
2416 example = { Parent = "root"; };
2417 type = types.addCheck (types.attrsOf unitOption) check.network.sectionHierarchyTokenBucket;
2419 Each attribute in this set specifies an option in the
2420 `[HierarchyTokenBucket]` section of the unit. See
2421 {manpage}`systemd.network(5)` for details.
2425 hierarchyTokenBucketClassConfig = mkOption {
2427 example = { Parent = "root"; Rate = "10M"; };
2428 type = types.addCheck (types.attrsOf unitOption) check.network.sectionHierarchyTokenBucketClass;
2430 Each attribute in this set specifies an option in the
2431 `[HierarchyTokenBucketClass]` section of the unit. See
2432 {manpage}`systemd.network(5)` for details.
2436 heavyHitterFilterConfig = mkOption {
2438 example = { Parent = "root"; PacketLimit = 10000; };
2439 type = types.addCheck (types.attrsOf unitOption) check.network.sectionHeavyHitterFilter;
2441 Each attribute in this set specifies an option in the
2442 `[HeavyHitterFilter]` section of the unit. See
2443 {manpage}`systemd.network(5)` for details.
2447 quickFairQueueingConfig = mkOption {
2449 example = { Parent = "root"; };
2450 type = types.addCheck (types.attrsOf unitOption) check.network.sectionQuickFairQueueing;
2452 Each attribute in this set specifies an option in the
2453 `[QuickFairQueueing]` section of the unit. See
2454 {manpage}`systemd.network(5)` for details.
2458 quickFairQueueingConfigClass = mkOption {
2460 example = { Parent = "root"; Weight = 133; };
2461 type = types.addCheck (types.attrsOf unitOption) check.network.sectionQuickFairQueueingClass;
2463 Each attribute in this set specifies an option in the
2464 `[QuickFairQueueingClass]` section of the unit. See
2465 {manpage}`systemd.network(5)` for details.
2469 bridgeVLANs = mkOption {
2471 example = [ { VLAN = "10-20"; } ];
2472 type = types.listOf (mkSubsectionType "bridgeVLANConfig" check.network.sectionBridgeVLAN);
2474 A list of BridgeVLAN sections to be added to the unit. See
2475 {manpage}`systemd.network(5)` for details.
2480 type = types.nullOr types.str;
2483 The name of the network interface to match against.
2488 type = types.nullOr types.str;
2491 Whether to enable DHCP on the interfaces matched.
2495 domains = mkOption {
2496 type = types.nullOr (types.listOf types.str);
2499 A list of domains to pass to the network config.
2503 address = mkOption {
2505 type = types.listOf types.str;
2507 A list of addresses to be added to the network section of the
2508 unit. See {manpage}`systemd.network(5)` for details.
2512 gateway = mkOption {
2514 type = types.listOf types.str;
2516 A list of gateways to be added to the network section of the
2517 unit. See {manpage}`systemd.network(5)` for details.
2523 type = types.listOf types.str;
2525 A list of dns servers to be added to the network section of the
2526 unit. See {manpage}`systemd.network(5)` for details.
2532 type = types.listOf types.str;
2534 A list of ntp servers to be added to the network section of the
2535 unit. See {manpage}`systemd.network(5)` for details.
2541 type = types.listOf types.str;
2543 A list of bridge interfaces to be added to the network section of the
2544 unit. See {manpage}`systemd.network(5)` for details.
2550 type = types.listOf types.str;
2552 A list of bond interfaces to be added to the network section of the
2553 unit. See {manpage}`systemd.network(5)` for details.
2559 type = types.listOf types.str;
2561 A list of vrf interfaces to be added to the network section of the
2562 unit. See {manpage}`systemd.network(5)` for details.
2568 type = types.listOf types.str;
2570 A list of vlan interfaces to be added to the network section of the
2571 unit. See {manpage}`systemd.network(5)` for details.
2575 macvlan = mkOption {
2577 type = types.listOf types.str;
2579 A list of macvlan interfaces to be added to the network section of the
2580 unit. See {manpage}`systemd.network(5)` for details.
2584 macvtap = mkOption {
2586 type = types.listOf types.str;
2588 A list of macvtap interfaces to be added to the network section of the
2589 unit. See {manpage}`systemd.network(5)` for details.
2595 type = types.listOf types.str;
2597 A list of vxlan interfaces to be added to the network section of the
2598 unit. See {manpage}`systemd.network(5)` for details.
2604 type = types.listOf types.str;
2606 A list of tunnel interfaces to be added to the network section of the
2607 unit. See {manpage}`systemd.network(5)` for details.
2613 type = types.listOf types.str;
2615 A list of xfrm interfaces to be added to the network section of the
2616 unit. See {manpage}`systemd.network(5)` for details.
2620 addresses = mkOption {
2622 example = [ { Address = "192.168.0.100/24"; } ];
2623 type = types.listOf (mkSubsectionType "addressConfig" check.network.sectionAddress);
2625 A list of address sections to be added to the unit. See
2626 {manpage}`systemd.network(5)` for details.
2630 routingPolicyRules = mkOption {
2632 example = [ { Table = 10; IncomingInterface = "eth1"; Family = "both"; } ];
2633 type = types.listOf (mkSubsectionType "routingPolicyRuleConfig" check.network.sectionRoutingPolicyRule);
2635 A list of routing policy rules sections to be added to the unit. See
2636 {manpage}`systemd.network(5)` for details.
2642 example = [ { Gateway = "192.168.0.1"; } ];
2643 type = types.listOf (mkSubsectionType "routeConfig" check.network.sectionRoute);
2645 A list of route sections to be added to the unit. See
2646 {manpage}`systemd.network(5)` for details.
2652 networkConfig = { config, ... }: {
2654 matchConfig = optionalAttrs (config.name != null) {
2657 networkConfig = optionalAttrs (config.DHCP != null) {
2659 } // optionalAttrs (config.domains != null) {
2660 Domains = concatStringsSep " " config.domains;
2665 networkdConfig = { config, ... }: {
2667 routeTables = mkOption {
2669 example = { foo = 27; };
2670 type = with types; attrsOf int;
2672 Defines route table names as an attrset of name to number.
2673 See {manpage}`networkd.conf(5)` for details.
2677 addRouteTablesToIPRoute2 = mkOption {
2682 If true and routeTables are set, then the specified route tables
2683 will also be installed into /etc/iproute2/rt_tables.
2689 networkConfig = optionalAttrs (config.routeTables != { }) {
2690 RouteTable = mapAttrsToList
2691 (name: number: "${name}:${toString number}")
2700 ${attrsToSection def.networkConfig}
2702 + optionalString (def.dhcpV4Config != { }) ''
2704 ${attrsToSection def.dhcpV4Config}
2706 + optionalString (def.dhcpV6Config != { }) ''
2708 ${attrsToSection def.dhcpV6Config}
2711 mkUnitFiles = prefix: cfg: listToAttrs (map (name: {
2712 name = "${prefix}systemd/network/${name}";
2713 value.source = "${cfg.units.${name}.unit}/${name}";
2714 }) (attrNames cfg.units));
2716 commonOptions = visible: {
2722 Whether to enable networkd or not.
2729 type = with types; attrsOf (submodule [ { options = linkOptions; } ]);
2730 description = "Definition of systemd network links.";
2733 netdevs = mkOption {
2736 type = with types; attrsOf (submodule [ { options = netdevOptions; } ]);
2737 description = "Definition of systemd network devices.";
2740 networks = mkOption {
2743 type = with types; attrsOf (submodule [ { options = networkOptions; } networkConfig ]);
2744 description = "Definition of systemd networks.";
2750 type = with types; submodule [ { options = networkdOptions; } networkdConfig ];
2751 description = "Definition of global systemd network config.";
2755 description = "Definition of networkd units.";
2758 type = with types; attrsOf (submodule (
2759 { name, config, ... }:
2760 { options = mapAttrs (_: x: x // { internal = true; }) concreteUnitOptions;
2762 unit = mkDefault (makeUnit name config);
2773 Whether to enable the systemd-networkd-wait-online service.
2775 systemd-networkd-wait-online can timeout and fail if there are no network interfaces
2776 available for it to manage. When systemd-networkd is enabled but a different service is
2777 responsible for managing the system's internet connection (for example, NetworkManager or
2778 connman are used to manage WiFi connections), this service is unnecessary and can be
2782 anyInterface = mkOption {
2784 Whether to consider the network online when any interface is online, as opposed to all of them.
2785 This is useful on portable machines with a wired and a wireless interface, for example.
2787 This is on by default if {option}`networking.useDHCP` is enabled.
2790 defaultText = "config.networking.useDHCP";
2791 default = config.networking.useDHCP;
2794 ignoredInterfaces = mkOption {
2796 Network interfaces to be ignored when deciding if the system is online.
2798 type = with types; listOf str;
2800 example = [ "wg0" ];
2803 timeout = mkOption {
2805 Time to wait for the network to come online, in seconds. Set to 0 to disable.
2807 type = types.ints.unsigned;
2812 extraArgs = mkOption {
2814 Extra command-line arguments to pass to systemd-networkd-wait-online.
2815 These also affect per-interface `systemd-network-wait-online@` services.
2817 See {manpage}`systemd-networkd-wait-online.service(8)` for all available options.
2819 type = with types; listOf str;
2826 commonConfig = config: let
2827 cfg = config.systemd.network;
2828 mkUnit = f: def: { inherit (def) enable; text = f def; };
2831 # .link units are honored by udev, no matter if systemd-networkd is enabled or not.
2833 systemd.network.units = mapAttrs' (n: v: nameValuePair "${n}.link" (mkUnit linkToUnit v)) cfg.links;
2835 systemd.network.wait-online.extraArgs =
2836 [ "--timeout=${toString cfg.wait-online.timeout}" ]
2837 ++ optional cfg.wait-online.anyInterface "--any"
2838 ++ map (i: "--ignore=${i}") cfg.wait-online.ignoredInterfaces;
2841 (mkIf config.systemd.network.enable {
2843 systemd.network.units = mapAttrs' (n: v: nameValuePair "${n}.netdev" (mkUnit netdevToUnit v)) cfg.netdevs
2844 // mapAttrs' (n: v: nameValuePair "${n}.network" (mkUnit networkToUnit v)) cfg.networks;
2846 # systemd-networkd is socket-activated by kernel netlink route change
2847 # messages. It is important to have systemd buffer those on behalf of
2849 systemd.sockets.systemd-networkd.wantedBy = [ "sockets.target" ];
2851 systemd.services.systemd-networkd-wait-online = {
2852 inherit (cfg.wait-online) enable;
2853 wantedBy = [ "network-online.target" ];
2854 serviceConfig.ExecStart = [
2856 "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online ${utils.escapeSystemdExecArgs cfg.wait-online.extraArgs}"
2860 systemd.services."systemd-networkd-wait-online@" = {
2861 serviceConfig.ExecStart = [
2863 "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online -i %i ${utils.escapeSystemdExecArgs cfg.wait-online.extraArgs}"
2871 cfg = config.systemd.network;
2872 unitFiles = mkUnitFiles "" cfg;
2874 (commonConfig config)
2876 { environment.etc = unitFiles; }
2878 (mkIf config.systemd.network.enable {
2880 users.users.systemd-network.group = "systemd-network";
2882 systemd.additionalUpstreamSystemUnits = [
2883 "systemd-networkd-wait-online.service"
2884 "systemd-networkd-wait-online@.service"
2885 "systemd-networkd.service"
2886 "systemd-networkd.socket"
2887 "systemd-networkd-persistent-storage.service"
2890 environment.etc."systemd/networkd.conf" = renderConfig cfg.config;
2892 systemd.services.systemd-networkd = let
2893 isReloadableUnitFileName = unitFileName: strings.hasSuffix ".network" unitFileName;
2894 reloadableUnitFiles = attrsets.filterAttrs (k: v: isReloadableUnitFileName k) unitFiles;
2895 nonReloadableUnitFiles = attrsets.filterAttrs (k: v: !isReloadableUnitFileName k) unitFiles;
2896 unitFileSources = unitFiles: map (x: x.source) (attrValues unitFiles);
2898 wantedBy = [ "multi-user.target" ];
2899 reloadTriggers = unitFileSources reloadableUnitFiles;
2900 restartTriggers = unitFileSources nonReloadableUnitFiles ++ [
2901 config.environment.etc."systemd/networkd.conf".source
2903 aliases = [ "dbus-org.freedesktop.network1.service" ];
2904 notSocketActivated = true;
2905 stopIfChanged = false;
2908 networking.iproute2 = mkIf (cfg.config.addRouteTablesToIPRoute2 && cfg.config.routeTables != { }) {
2909 enable = mkDefault true;
2910 rttablesExtraConfig = ''
2912 # Extra tables defined in NixOS systemd.networkd.config.routeTables.
2913 ${concatStringsSep "\n" (mapAttrsToList (name: number: "${toString number} ${name}") cfg.config.routeTables)}
2917 services.resolved.enable = mkDefault true;
2923 options.boot.initrd.systemd.network.networks = mkOption {
2924 type = with types; attrsOf (submodule {
2925 # Default in initrd is dhcp-on-stop, which is correct if flushBeforeStage2 = false
2926 config = mkIf config.boot.initrd.network.flushBeforeStage2 {
2927 networkConfig.KeepConfiguration = mkDefault false;
2934 cfg = config.boot.initrd.systemd.network;
2936 (commonConfig config.boot.initrd)
2939 systemd.network.enable = mkDefault config.boot.initrd.network.enable;
2940 systemd.contents = mkUnitFiles "/etc/" cfg;
2942 # Networkd link files are used early by udev to set up interfaces early.
2943 # This must be done in stage 1 to avoid race conditions between udev and
2945 systemd.network.units = lib.filterAttrs (n: _: hasSuffix ".link" n) config.systemd.network.units;
2946 systemd.storePaths = ["${config.boot.initrd.systemd.package}/lib/systemd/network/99-default.link"];
2952 systemd.dbus.enable = mkDefault true;
2954 systemd.additionalUpstreamUnits = [
2955 "systemd-networkd-wait-online.service"
2956 "systemd-networkd.service"
2957 "systemd-networkd.socket"
2958 "systemd-network-generator.service"
2959 "network-online.target"
2960 "network-pre.target"
2963 "nss-user-lookup.target"
2964 "remote-fs-pre.target"
2967 systemd.users.systemd-network = {};
2968 systemd.groups.systemd-network = {};
2970 systemd.contents."/etc/systemd/networkd.conf" = renderConfig cfg.config;
2972 systemd.services.systemd-networkd = {
2973 wantedBy = [ "initrd.target" ];
2975 systemd.sockets.systemd-networkd = {
2976 wantedBy = [ "initrd.target" ];
2979 systemd.services.systemd-network-generator.wantedBy = [ "sysinit.target" ];
2981 systemd.storePaths = [
2982 "${config.boot.initrd.systemd.package}/lib/systemd/systemd-networkd"
2983 "${config.boot.initrd.systemd.package}/lib/systemd/systemd-networkd-wait-online"
2984 "${config.boot.initrd.systemd.package}/lib/systemd/systemd-network-generator"
2986 kernelModules = [ "af_packet" ];
2994 imports = [ stage1Options ];
2997 systemd.network = commonOptions true;
2998 boot.initrd.systemd.network = commonOptions "shallow";
3003 (mkIf config.boot.initrd.systemd.enable {
3005 assertion = !config.boot.initrd.network.udhcpc.enable && config.boot.initrd.network.udhcpc.extraArgs == [];
3007 systemd stage 1 networking does not support 'boot.initrd.network.udhcpc'. Configure
3008 DHCP with 'networking.*' options or with 'boot.initrd.systemd.network' options.
3012 boot.initrd = stage1Config;