2015-04-19 21:05:12 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
with import ./systemd-unit-options.nix { inherit config lib; };
|
2015-04-20 11:31:17 +02:00
|
|
|
with import ./systemd-lib.nix { inherit config lib pkgs; };
|
2015-04-19 21:05:12 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.systemd.network;
|
|
|
|
|
2020-07-01 18:05:32 +02:00
|
|
|
check = {
|
|
|
|
|
|
|
|
link = {
|
|
|
|
|
|
|
|
sectionLink = checkUnitConfig "Link" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Description"
|
|
|
|
"Alias"
|
|
|
|
"MACAddressPolicy"
|
|
|
|
"MACAddress"
|
|
|
|
"NamePolicy"
|
|
|
|
"Name"
|
|
|
|
"AlternativeNamesPolicy"
|
|
|
|
"AlternativeName"
|
|
|
|
"MTUBytes"
|
|
|
|
"BitsPerSecond"
|
|
|
|
"Duplex"
|
|
|
|
"AutoNegotiation"
|
|
|
|
"WakeOnLan"
|
|
|
|
"Port"
|
|
|
|
"Advertise"
|
|
|
|
"ReceiveChecksumOffload"
|
|
|
|
"TransmitChecksumOffload"
|
|
|
|
"TCPSegmentationOffload"
|
|
|
|
"TCP6SegmentationOffload"
|
|
|
|
"GenericSegmentationOffload"
|
|
|
|
"GenericReceiveOffload"
|
|
|
|
"LargeReceiveOffload"
|
|
|
|
"RxChannels"
|
|
|
|
"TxChannels"
|
|
|
|
"OtherChannels"
|
|
|
|
"CombinedChannels"
|
|
|
|
"RxBufferSize"
|
|
|
|
"TxBufferSize"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "MACAddressPolicy" ["persistent" "random" "none"])
|
|
|
|
(assertMacAddress "MACAddress")
|
|
|
|
(assertByteFormat "MTUBytes")
|
|
|
|
(assertByteFormat "BitsPerSecond")
|
|
|
|
(assertValueOneOf "Duplex" ["half" "full"])
|
|
|
|
(assertValueOneOf "AutoNegotiation" boolValues)
|
|
|
|
(assertValueOneOf "WakeOnLan" ["phy" "unicast" "multicast" "broadcast" "arp" "magic" "secureon" "off"])
|
|
|
|
(assertValueOneOf "Port" ["tp" "aui" "bnc" "mii" "fibre"])
|
|
|
|
(assertValueOneOf "ReceiveChecksumOffload" boolValues)
|
|
|
|
(assertValueOneOf "TransmitChecksumOffload" boolValues)
|
|
|
|
(assertValueOneOf "TCPSegmentationOffload" boolValues)
|
|
|
|
(assertValueOneOf "TCP6SegmentationOffload" boolValues)
|
|
|
|
(assertValueOneOf "GenericSegmentationOffload" boolValues)
|
|
|
|
(assertValueOneOf "GenericReceiveOffload" boolValues)
|
|
|
|
(assertValueOneOf "LargeReceiveOffload" boolValues)
|
|
|
|
(assertInt "RxChannels")
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertRange "RxChannels" 1 4294967295)
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertInt "TxChannels")
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertRange "TxChannels" 1 4294967295)
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertInt "OtherChannels")
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertRange "OtherChannels" 1 4294967295)
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertInt "CombinedChannels")
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertRange "CombinedChannels" 1 4294967295)
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertInt "RxBufferSize")
|
|
|
|
(assertInt "TxBufferSize")
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
netdev = let
|
|
|
|
|
|
|
|
tunChecks = [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"MultiQueue"
|
|
|
|
"PacketInfo"
|
|
|
|
"VNetHeader"
|
|
|
|
"User"
|
|
|
|
"Group"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "MultiQueue" boolValues)
|
|
|
|
(assertValueOneOf "PacketInfo" boolValues)
|
|
|
|
(assertValueOneOf "VNetHeader" boolValues)
|
|
|
|
];
|
|
|
|
in {
|
|
|
|
|
|
|
|
sectionNetdev = checkUnitConfig "Netdev" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Description"
|
|
|
|
"Name"
|
|
|
|
"Kind"
|
|
|
|
"MTUBytes"
|
|
|
|
"MACAddress"
|
|
|
|
])
|
|
|
|
(assertHasField "Name")
|
|
|
|
(assertHasField "Kind")
|
|
|
|
(assertValueOneOf "Kind" [
|
|
|
|
"bond"
|
|
|
|
"bridge"
|
|
|
|
"dummy"
|
|
|
|
"gre"
|
|
|
|
"gretap"
|
|
|
|
"erspan"
|
|
|
|
"ip6gre"
|
|
|
|
"ip6tnl"
|
|
|
|
"ip6gretap"
|
|
|
|
"ipip"
|
|
|
|
"ipvlan"
|
|
|
|
"macvlan"
|
|
|
|
"macvtap"
|
|
|
|
"sit"
|
|
|
|
"tap"
|
|
|
|
"tun"
|
|
|
|
"veth"
|
|
|
|
"vlan"
|
|
|
|
"vti"
|
|
|
|
"vti6"
|
|
|
|
"vxlan"
|
|
|
|
"geneve"
|
|
|
|
"l2tp"
|
|
|
|
"macsec"
|
|
|
|
"vrf"
|
|
|
|
"vcan"
|
|
|
|
"vxcan"
|
|
|
|
"wireguard"
|
|
|
|
"netdevsim"
|
|
|
|
"nlmon"
|
|
|
|
"fou"
|
|
|
|
"xfrm"
|
|
|
|
"ifb"
|
|
|
|
])
|
|
|
|
(assertByteFormat "MTUBytes")
|
|
|
|
(assertMacAddress "MACAddress")
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionVLAN = checkUnitConfig "VLAN" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Id"
|
|
|
|
"GVRP"
|
|
|
|
"MVRP"
|
|
|
|
"LooseBinding"
|
|
|
|
"ReorderHeader"
|
|
|
|
])
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertInt "Id")
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertRange "Id" 0 4094)
|
|
|
|
(assertValueOneOf "GVRP" boolValues)
|
|
|
|
(assertValueOneOf "MVRP" boolValues)
|
|
|
|
(assertValueOneOf "LooseBinding" boolValues)
|
|
|
|
(assertValueOneOf "ReorderHeader" boolValues)
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionMACVLAN = checkUnitConfig "MACVLAN" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Mode"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "Mode" ["private" "vepa" "bridge" "passthru"])
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionVXLAN = checkUnitConfig "VXLAN" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"VNI"
|
|
|
|
"Remote"
|
|
|
|
"Local"
|
|
|
|
"Group"
|
|
|
|
"TOS"
|
|
|
|
"TTL"
|
|
|
|
"MacLearning"
|
|
|
|
"FDBAgeingSec"
|
|
|
|
"MaximumFDBEntries"
|
|
|
|
"ReduceARPProxy"
|
|
|
|
"L2MissNotification"
|
|
|
|
"L3MissNotification"
|
|
|
|
"RouteShortCircuit"
|
|
|
|
"UDPChecksum"
|
|
|
|
"UDP6ZeroChecksumTx"
|
|
|
|
"UDP6ZeroChecksumRx"
|
|
|
|
"RemoteChecksumTx"
|
|
|
|
"RemoteChecksumRx"
|
|
|
|
"GroupPolicyExtension"
|
|
|
|
"GenericProtocolExtension"
|
|
|
|
"DestinationPort"
|
|
|
|
"PortRange"
|
|
|
|
"FlowLabel"
|
|
|
|
"IPDoNotFragment"
|
|
|
|
])
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertInt "VNI")
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertRange "VNI" 1 16777215)
|
|
|
|
(assertValueOneOf "MacLearning" boolValues)
|
|
|
|
(assertInt "MaximumFDBEntries")
|
|
|
|
(assertValueOneOf "ReduceARPProxy" boolValues)
|
|
|
|
(assertValueOneOf "L2MissNotification" boolValues)
|
|
|
|
(assertValueOneOf "L3MissNotification" boolValues)
|
|
|
|
(assertValueOneOf "RouteShortCircuit" boolValues)
|
|
|
|
(assertValueOneOf "UDPChecksum" boolValues)
|
|
|
|
(assertValueOneOf "UDP6ZeroChecksumTx" boolValues)
|
|
|
|
(assertValueOneOf "UDP6ZeroChecksumRx" boolValues)
|
|
|
|
(assertValueOneOf "RemoteChecksumTx" boolValues)
|
|
|
|
(assertValueOneOf "RemoteChecksumRx" boolValues)
|
|
|
|
(assertValueOneOf "GroupPolicyExtension" boolValues)
|
|
|
|
(assertValueOneOf "GenericProtocolExtension" boolValues)
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertInt "FlowLabel")
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertRange "FlowLabel" 0 1048575)
|
|
|
|
(assertValueOneOf "IPDoNotFragment" (boolValues + ["inherit"]))
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionTunnel = checkUnitConfig "Tunnel" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Local"
|
|
|
|
"Remote"
|
|
|
|
"TOS"
|
|
|
|
"TTL"
|
|
|
|
"DiscoverPathMTU"
|
|
|
|
"IPv6FlowLabel"
|
|
|
|
"CopyDSCP"
|
|
|
|
"EncapsulationLimit"
|
|
|
|
"Key"
|
|
|
|
"InputKey"
|
|
|
|
"OutputKey"
|
|
|
|
"Mode"
|
|
|
|
"Independent"
|
|
|
|
"AssignToLoopback"
|
|
|
|
"AllowLocalRemote"
|
|
|
|
"FooOverUDP"
|
|
|
|
"FOUDestinationPort"
|
|
|
|
"FOUSourcePort"
|
|
|
|
"Encapsulation"
|
|
|
|
"IPv6RapidDeploymentPrefix"
|
|
|
|
"ISATAP"
|
|
|
|
"SerializeTunneledPackets"
|
|
|
|
"ERSPANIndex"
|
|
|
|
])
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertInt "TTL")
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertRange "TTL" 0 255)
|
|
|
|
(assertValueOneOf "DiscoverPathMTU" boolValues)
|
|
|
|
(assertValueOneOf "CopyDSCP" boolValues)
|
|
|
|
(assertValueOneOf "Mode" ["ip6ip6" "ipip6" "any"])
|
|
|
|
(assertValueOneOf "Independent" boolValues)
|
|
|
|
(assertValueOneOf "AssignToLoopback" boolValues)
|
|
|
|
(assertValueOneOf "AllowLocalRemote" boolValues)
|
|
|
|
(assertValueOneOf "FooOverUDP" boolValues)
|
|
|
|
(assertPort "FOUDestinationPort")
|
|
|
|
(assertPort "FOUSourcePort")
|
|
|
|
(assertValueOneOf "Encapsulation" ["FooOverUDP" "GenericUDPEncapsulation"])
|
|
|
|
(assertValueOneOf "ISATAP" boolValues)
|
|
|
|
(assertValueOneOf "SerializeTunneledPackets" boolValues)
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertInt "ERSPANIndex")
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertRange "ERSPANIndex" 1 1048575)
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionPeer = checkUnitConfig "Peer" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Name"
|
|
|
|
"MACAddress"
|
|
|
|
])
|
|
|
|
(assertMacAddress "MACAddress")
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionTun = checkUnitConfig "Tun" tunChecks;
|
|
|
|
|
|
|
|
sectionTap = checkUnitConfig "Tap" tunChecks;
|
|
|
|
|
|
|
|
# NOTE The PrivateKey directive is missing on purpose here, please
|
|
|
|
# do not add it to this list. The nix store is world-readable let's
|
|
|
|
# refrain ourselves from providing a footgun.
|
|
|
|
sectionWireGuard = checkUnitConfig "WireGuard" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"PrivateKeyFile"
|
|
|
|
"ListenPort"
|
|
|
|
"FirewallMark"
|
|
|
|
])
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertInt "FirewallMark")
|
|
|
|
(assertRange "FirewallMark" 1 4294967295)
|
2020-07-01 18:05:32 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
# NOTE The PresharedKey directive is missing on purpose here, please
|
|
|
|
# do not add it to this list. The nix store is world-readable,let's
|
|
|
|
# refrain ourselves from providing a footgun.
|
|
|
|
sectionWireGuardPeer = checkUnitConfig "WireGuardPeer" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"PublicKey"
|
|
|
|
"PresharedKeyFile"
|
|
|
|
"AllowedIPs"
|
|
|
|
"Endpoint"
|
|
|
|
"PersistentKeepalive"
|
|
|
|
])
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertInt "PersistentKeepalive")
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertRange "PersistentKeepalive" 0 65535)
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionBond = checkUnitConfig "Bond" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Mode"
|
|
|
|
"TransmitHashPolicy"
|
|
|
|
"LACPTransmitRate"
|
|
|
|
"MIIMonitorSec"
|
|
|
|
"UpDelaySec"
|
|
|
|
"DownDelaySec"
|
|
|
|
"LearnPacketIntervalSec"
|
|
|
|
"AdSelect"
|
|
|
|
"AdActorSystemPriority"
|
|
|
|
"AdUserPortKey"
|
|
|
|
"AdActorSystem"
|
|
|
|
"FailOverMACPolicy"
|
|
|
|
"ARPValidate"
|
|
|
|
"ARPIntervalSec"
|
|
|
|
"ARPIPTargets"
|
|
|
|
"ARPAllTargets"
|
|
|
|
"PrimaryReselectPolicy"
|
|
|
|
"ResendIGMP"
|
|
|
|
"PacketsPerSlave"
|
|
|
|
"GratuitousARP"
|
|
|
|
"AllSlavesActive"
|
|
|
|
"DynamicTransmitLoadBalancing"
|
|
|
|
"MinLinks"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "Mode" [
|
|
|
|
"balance-rr"
|
|
|
|
"active-backup"
|
|
|
|
"balance-xor"
|
|
|
|
"broadcast"
|
|
|
|
"802.3ad"
|
|
|
|
"balance-tlb"
|
|
|
|
"balance-alb"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "TransmitHashPolicy" [
|
|
|
|
"layer2"
|
|
|
|
"layer3+4"
|
|
|
|
"layer2+3"
|
|
|
|
"encap2+3"
|
|
|
|
"encap3+4"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "LACPTransmitRate" ["slow" "fast"])
|
|
|
|
(assertValueOneOf "AdSelect" ["stable" "bandwidth" "count"])
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertInt "AdActorSystemPriority")
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertRange "AdActorSystemPriority" 1 65535)
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertInt "AdUserPortKey")
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertRange "AdUserPortKey" 0 1023)
|
|
|
|
(assertValueOneOf "FailOverMACPolicy" ["none" "active" "follow"])
|
|
|
|
(assertValueOneOf "ARPValidate" ["none" "active" "backup" "all"])
|
|
|
|
(assertValueOneOf "ARPAllTargets" ["any" "all"])
|
|
|
|
(assertValueOneOf "PrimaryReselectPolicy" ["always" "better" "failure"])
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertInt "ResendIGMP")
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertRange "ResendIGMP" 0 255)
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertInt "PacketsPerSlave")
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertRange "PacketsPerSlave" 0 65535)
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertInt "GratuitousARP")
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertRange "GratuitousARP" 0 255)
|
|
|
|
(assertValueOneOf "AllSlavesActive" boolValues)
|
|
|
|
(assertValueOneOf "DynamicTransmitLoadBalancing" boolValues)
|
|
|
|
(assertInt "MinLinks")
|
|
|
|
(assertMinimum "MinLinks" 0)
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionXfrm = checkUnitConfig "Xfrm" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"InterfaceId"
|
|
|
|
"Independent"
|
|
|
|
])
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertInt "InterfaceId")
|
|
|
|
(assertRange "InterfaceId" 1 4294967295)
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertValueOneOf "Independent" boolValues)
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionVRF = checkUnitConfig "VRF" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Table"
|
|
|
|
])
|
|
|
|
(assertInt "Table")
|
|
|
|
(assertMinimum "Table" 0)
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
network = {
|
|
|
|
|
|
|
|
sectionLink = checkUnitConfig "Link" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"MACAddress"
|
|
|
|
"MTUBytes"
|
|
|
|
"ARP"
|
|
|
|
"Multicast"
|
|
|
|
"AllMulticast"
|
|
|
|
"Unmanaged"
|
|
|
|
"RequiredForOnline"
|
|
|
|
])
|
|
|
|
(assertMacAddress "MACAddress")
|
|
|
|
(assertByteFormat "MTUBytes")
|
|
|
|
(assertValueOneOf "ARP" boolValues)
|
|
|
|
(assertValueOneOf "Multicast" boolValues)
|
|
|
|
(assertValueOneOf "AllMulticast" boolValues)
|
|
|
|
(assertValueOneOf "Unmanaged" boolValues)
|
|
|
|
(assertValueOneOf "RequiredForOnline" (boolValues ++ [
|
|
|
|
"missing"
|
|
|
|
"off"
|
|
|
|
"no-carrier"
|
|
|
|
"dormant"
|
|
|
|
"degraded-carrier"
|
|
|
|
"carrier"
|
|
|
|
"degraded"
|
|
|
|
"enslaved"
|
|
|
|
"routable"
|
|
|
|
]))
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionNetwork = checkUnitConfig "Network" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Description"
|
|
|
|
"DHCP"
|
|
|
|
"DHCPServer"
|
|
|
|
"LinkLocalAddressing"
|
|
|
|
"IPv4LLRoute"
|
|
|
|
"DefaultRouteOnDevice"
|
|
|
|
"IPv6Token"
|
|
|
|
"LLMNR"
|
|
|
|
"MulticastDNS"
|
|
|
|
"DNSOverTLS"
|
|
|
|
"DNSSEC"
|
|
|
|
"DNSSECNegativeTrustAnchors"
|
|
|
|
"LLDP"
|
|
|
|
"EmitLLDP"
|
|
|
|
"BindCarrier"
|
|
|
|
"Address"
|
|
|
|
"Gateway"
|
|
|
|
"DNS"
|
|
|
|
"Domains"
|
|
|
|
"DNSDefaultRoute"
|
|
|
|
"NTP"
|
|
|
|
"IPForward"
|
|
|
|
"IPMasquerade"
|
|
|
|
"IPv6PrivacyExtensions"
|
|
|
|
"IPv6AcceptRA"
|
|
|
|
"IPv6DuplicateAddressDetection"
|
|
|
|
"IPv6HopLimit"
|
|
|
|
"IPv4ProxyARP"
|
|
|
|
"IPv6ProxyNDP"
|
|
|
|
"IPv6ProxyNDPAddress"
|
|
|
|
"IPv6PrefixDelegation"
|
|
|
|
"IPv6MTUBytes"
|
|
|
|
"Bridge"
|
|
|
|
"Bond"
|
|
|
|
"VRF"
|
|
|
|
"VLAN"
|
|
|
|
"IPVLAN"
|
|
|
|
"MACVLAN"
|
|
|
|
"VXLAN"
|
|
|
|
"Tunnel"
|
|
|
|
"MACsec"
|
|
|
|
"ActiveSlave"
|
|
|
|
"PrimarySlave"
|
|
|
|
"ConfigureWithoutCarrier"
|
|
|
|
"IgnoreCarrierLoss"
|
|
|
|
"Xfrm"
|
|
|
|
"KeepConfiguration"
|
|
|
|
])
|
|
|
|
# Note: For DHCP the values both, none, v4, v6 are deprecated
|
|
|
|
(assertValueOneOf "DHCP" ["yes" "no" "ipv4" "ipv6"])
|
|
|
|
(assertValueOneOf "DHCPServer" boolValues)
|
|
|
|
(assertValueOneOf "LinkLocalAddressing" ["yes" "no" "ipv4" "ipv6" "fallback" "ipv4-fallback"])
|
|
|
|
(assertValueOneOf "IPv4LLRoute" boolValues)
|
|
|
|
(assertValueOneOf "DefaultRouteOnDevice" boolValues)
|
|
|
|
(assertValueOneOf "LLMNR" (boolValues ++ ["resolve"]))
|
|
|
|
(assertValueOneOf "MulticastDNS" (boolValues ++ ["resolve"]))
|
|
|
|
(assertValueOneOf "DNSOverTLS" (boolValues ++ ["opportunistic"]))
|
|
|
|
(assertValueOneOf "DNSSEC" (boolValues ++ ["allow-downgrade"]))
|
|
|
|
(assertValueOneOf "LLDP" (boolValues ++ ["routers-only"]))
|
|
|
|
(assertValueOneOf "EmitLLDP" (boolValues ++ ["nearest-bridge" "non-tpmr-bridge" "customer-bridge"]))
|
|
|
|
(assertValueOneOf "DNSDefaultRoute" boolValues)
|
|
|
|
(assertValueOneOf "IPForward" (boolValues ++ ["ipv4" "ipv6"]))
|
|
|
|
(assertValueOneOf "IPMasquerade" boolValues)
|
|
|
|
(assertValueOneOf "IPv6PrivacyExtensions" (boolValues ++ ["prefer-public" "kernel"]))
|
|
|
|
(assertValueOneOf "IPv6AcceptRA" boolValues)
|
|
|
|
(assertInt "IPv6DuplicateAddressDetection")
|
|
|
|
(assertMinimum "IPv6DuplicateAddressDetection" 0)
|
|
|
|
(assertInt "IPv6HopLimit")
|
|
|
|
(assertMinimum "IPv6HopLimit" 0)
|
|
|
|
(assertValueOneOf "IPv4ProxyARP" boolValues)
|
|
|
|
(assertValueOneOf "IPv6ProxyNDP" boolValues)
|
|
|
|
(assertValueOneOf "IPv6PrefixDelegation" ["static" "dhcpv6" "yes" "false"])
|
|
|
|
(assertByteFormat "IPv6MTUBytes")
|
|
|
|
(assertValueOneOf "ActiveSlave" boolValues)
|
|
|
|
(assertValueOneOf "PrimarySlave" boolValues)
|
|
|
|
(assertValueOneOf "ConfigureWithoutCarrier" boolValues)
|
|
|
|
(assertValueOneOf "IgnoreCarrierLoss" boolValues)
|
|
|
|
(assertValueOneOf "KeepConfiguration" (boolValues ++ ["static" "dhcp-on-stop" "dhcp"]))
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionAddress = checkUnitConfig "Address" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Address"
|
|
|
|
"Peer"
|
|
|
|
"Broadcast"
|
|
|
|
"Label"
|
|
|
|
"PreferredLifetime"
|
|
|
|
"Scope"
|
|
|
|
"HomeAddress"
|
|
|
|
"DuplicateAddressDetection"
|
|
|
|
"ManageTemporaryAddress"
|
|
|
|
"AddPrefixRoute"
|
|
|
|
"AutoJoin"
|
|
|
|
])
|
|
|
|
(assertHasField "Address")
|
|
|
|
(assertValueOneOf "PreferredLifetime" ["forever" "infinity" "0" 0])
|
|
|
|
(assertValueOneOf "HomeAddress" boolValues)
|
|
|
|
(assertValueOneOf "DuplicateAddressDetection" ["ipv4" "ipv6" "both" "none"])
|
|
|
|
(assertValueOneOf "ManageTemporaryAddress" boolValues)
|
|
|
|
(assertValueOneOf "AddPrefixRoute" boolValues)
|
|
|
|
(assertValueOneOf "AutoJoin" boolValues)
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionRoutingPolicyRule = checkUnitConfig "RoutingPolicyRule" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"TypeOfService"
|
|
|
|
"From"
|
|
|
|
"To"
|
|
|
|
"FirewallMark"
|
|
|
|
"Table"
|
|
|
|
"Priority"
|
|
|
|
"IncomingInterface"
|
|
|
|
"OutgoingInterface"
|
|
|
|
"SourcePort"
|
|
|
|
"DestinationPort"
|
|
|
|
"IPProtocol"
|
|
|
|
"InvertRule"
|
|
|
|
"Family"
|
|
|
|
"User"
|
|
|
|
"SuppressPrefixLength"
|
|
|
|
])
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertInt "TypeOfService")
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertRange "TypeOfService" 0 255)
|
|
|
|
(assertInt "FirewallMark")
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertRange "FirewallMark" 1 4294967295)
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertInt "Priority")
|
|
|
|
(assertPort "SourcePort")
|
|
|
|
(assertPort "DestinationPort")
|
|
|
|
(assertValueOneOf "InvertRule" boolValues)
|
|
|
|
(assertValueOneOf "Family" ["ipv4" "ipv6" "both"])
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertInt "SuppressPrefixLength")
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertRange "SuppressPrefixLength" 0 128)
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionRoute = checkUnitConfig "Route" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Gateway"
|
|
|
|
"GatewayOnLink"
|
|
|
|
"Destination"
|
|
|
|
"Source"
|
|
|
|
"Metric"
|
|
|
|
"IPv6Preference"
|
|
|
|
"Scope"
|
|
|
|
"PreferredSource"
|
|
|
|
"Table"
|
|
|
|
"Protocol"
|
|
|
|
"Type"
|
|
|
|
"InitialCongestionWindow"
|
|
|
|
"InitialAdvertisedReceiveWindow"
|
|
|
|
"QuickAck"
|
|
|
|
"FastOpenNoCookie"
|
|
|
|
"TTLPropagate"
|
|
|
|
"MTUBytes"
|
|
|
|
"IPServiceType"
|
|
|
|
"MultiPathRoute"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "GatewayOnLink" boolValues)
|
|
|
|
(assertInt "Metric")
|
|
|
|
(assertValueOneOf "IPv6Preference" ["low" "medium" "high"])
|
|
|
|
(assertValueOneOf "Scope" ["global" "site" "link" "host" "nowhere"])
|
|
|
|
(assertValueOneOf "Type" [
|
|
|
|
"unicast"
|
|
|
|
"local"
|
|
|
|
"broadcast"
|
|
|
|
"anycast"
|
|
|
|
"multicast"
|
|
|
|
"blackhole"
|
|
|
|
"unreachable"
|
|
|
|
"prohibit"
|
|
|
|
"throw"
|
|
|
|
"nat"
|
|
|
|
"xresolve"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "QuickAck" boolValues)
|
|
|
|
(assertValueOneOf "FastOpenNoCookie" boolValues)
|
|
|
|
(assertValueOneOf "TTLPropagate" boolValues)
|
|
|
|
(assertByteFormat "MTUBytes")
|
|
|
|
(assertValueOneOf "IPServiceType" ["CS6" "CS4"])
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionDHCPv4 = checkUnitConfig "DHCPv4" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"UseDNS"
|
|
|
|
"RoutesToDNS"
|
|
|
|
"UseNTP"
|
|
|
|
"UseSIP"
|
|
|
|
"UseMTU"
|
|
|
|
"Anonymize"
|
|
|
|
"SendHostname"
|
|
|
|
"UseHostname"
|
|
|
|
"Hostname"
|
|
|
|
"UseDomains"
|
|
|
|
"UseRoutes"
|
|
|
|
"UseTimezone"
|
|
|
|
"ClientIdentifier"
|
|
|
|
"VendorClassIdentifier"
|
|
|
|
"UserClass"
|
|
|
|
"MaxAttempts"
|
|
|
|
"DUIDType"
|
|
|
|
"DUIDRawData"
|
|
|
|
"IAID"
|
|
|
|
"RequestBroadcast"
|
|
|
|
"RouteMetric"
|
|
|
|
"RouteTable"
|
|
|
|
"RouteMTUBytes"
|
|
|
|
"ListenPort"
|
|
|
|
"SendRelease"
|
|
|
|
"SendDecline"
|
|
|
|
"BlackList"
|
|
|
|
"RequestOptions"
|
|
|
|
"SendOption"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "UseDNS" boolValues)
|
|
|
|
(assertValueOneOf "RoutesToDNS" boolValues)
|
|
|
|
(assertValueOneOf "UseNTP" boolValues)
|
|
|
|
(assertValueOneOf "UseSIP" boolValues)
|
|
|
|
(assertValueOneOf "UseMTU" boolValues)
|
|
|
|
(assertValueOneOf "Anonymize" boolValues)
|
|
|
|
(assertValueOneOf "SendHostname" boolValues)
|
|
|
|
(assertValueOneOf "UseHostname" boolValues)
|
|
|
|
(assertValueOneOf "UseDomains" (boolValues ++ ["route"]))
|
|
|
|
(assertValueOneOf "UseRoutes" boolValues)
|
|
|
|
(assertValueOneOf "UseTimezone" boolValues)
|
|
|
|
(assertValueOneOf "ClientIdentifier" ["mac" "duid" "duid-only"])
|
|
|
|
(assertInt "IAID")
|
|
|
|
(assertValueOneOf "RequestBroadcast" boolValues)
|
|
|
|
(assertInt "RouteMetric")
|
|
|
|
(assertInt "RouteTable")
|
2020-07-09 10:12:22 +02:00
|
|
|
(assertRange "RouteTable" 0 4294967295)
|
2020-07-01 18:05:32 +02:00
|
|
|
(assertByteFormat "RouteMTUBytes")
|
|
|
|
(assertPort "ListenPort")
|
|
|
|
(assertValueOneOf "SendRelease" boolValues)
|
|
|
|
(assertValueOneOf "SendDecline" boolValues)
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionDHCPv6 = checkUnitConfig "DHCPv6" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"UseDNS"
|
|
|
|
"UseNTP"
|
|
|
|
"RapidCommit"
|
|
|
|
"ForceDHCPv6PDOtherInformation"
|
|
|
|
"PrefixDelegationHint"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "UseDNS" boolValues)
|
|
|
|
(assertValueOneOf "UseNTP" boolValues)
|
|
|
|
(assertValueOneOf "RapidCommit" boolValues)
|
|
|
|
(assertValueOneOf "ForceDHCPv6PDOtherInformation" boolValues)
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionDHCPServer = checkUnitConfig "DHCPServer" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"PoolOffset"
|
|
|
|
"PoolSize"
|
|
|
|
"DefaultLeaseTimeSec"
|
|
|
|
"MaxLeaseTimeSec"
|
|
|
|
"EmitDNS"
|
|
|
|
"DNS"
|
|
|
|
"EmitNTP"
|
|
|
|
"NTP"
|
|
|
|
"EmitSIP"
|
|
|
|
"SIP"
|
|
|
|
"EmitRouter"
|
|
|
|
"EmitTimezone"
|
|
|
|
"Timezone"
|
|
|
|
"SendOption"
|
|
|
|
])
|
|
|
|
(assertInt "PoolOffset")
|
|
|
|
(assertMinimum "PoolOffset" 0)
|
|
|
|
(assertInt "PoolSize")
|
|
|
|
(assertMinimum "PoolSize" 0)
|
|
|
|
(assertValueOneOf "EmitDNS" boolValues)
|
|
|
|
(assertValueOneOf "EmitNTP" boolValues)
|
|
|
|
(assertValueOneOf "EmitSIP" boolValues)
|
|
|
|
(assertValueOneOf "EmitRouter" boolValues)
|
|
|
|
(assertValueOneOf "EmitTimezone" boolValues)
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionIPv6PrefixDelegation = checkUnitConfig "IPv6PrefixDelegation" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Managed"
|
|
|
|
"OtherInformation"
|
|
|
|
"RouterLifetimeSec"
|
|
|
|
"RouterPreference"
|
|
|
|
"EmitDNS"
|
|
|
|
"DNS"
|
|
|
|
"EmitDomains"
|
|
|
|
"Domains"
|
|
|
|
"DNSLifetimeSec"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "Managed" boolValues)
|
|
|
|
(assertValueOneOf "OtherInformation" boolValues)
|
|
|
|
(assertValueOneOf "RouterPreference" ["high" "medium" "low" "normal" "default"])
|
|
|
|
(assertValueOneOf "EmitDNS" boolValues)
|
|
|
|
(assertValueOneOf "EmitDomains" boolValues)
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionIPv6Prefix = checkUnitConfig "IPv6Prefix" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"AddressAutoconfiguration"
|
|
|
|
"OnLink"
|
|
|
|
"Prefix"
|
|
|
|
"PreferredLifetimeSec"
|
|
|
|
"ValidLifetimeSec"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "AddressAutoconfiguration" boolValues)
|
|
|
|
(assertValueOneOf "OnLink" boolValues)
|
|
|
|
];
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
2017-07-27 19:49:56 +02:00
|
|
|
|
2015-04-19 21:05:12 +02:00
|
|
|
commonNetworkOptions = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
2015-04-30 06:20:54 +02:00
|
|
|
default = true;
|
2015-04-19 21:05:12 +02:00
|
|
|
type = types.bool;
|
|
|
|
description = ''
|
|
|
|
Whether to manage network configuration using <command>systemd-network</command>.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
matchConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Name = "eth0"; };
|
|
|
|
type = types.attrsOf unitOption;
|
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[Match]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.link</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
|
|
|
<citerefentry><refentrytitle>systemd.netdev</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
|
|
|
<citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
|
|
|
for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2016-12-17 12:03:40 +01:00
|
|
|
extraConfig = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.lines;
|
|
|
|
description = "Extra configuration append to unit";
|
|
|
|
};
|
2015-04-19 21:05:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
linkOptions = commonNetworkOptions // {
|
2020-03-11 00:24:50 +01:00
|
|
|
# overwrite enable option from above
|
|
|
|
enable = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
|
|
|
description = ''
|
|
|
|
Whether to enable this .link unit. It's handled by udev no matter if <command>systemd-networkd</command> is enabled or not
|
|
|
|
'';
|
|
|
|
};
|
2015-04-19 21:05:12 +02:00
|
|
|
|
|
|
|
linkConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { MACAddress = "00:ff:ee:aa:cc:dd"; };
|
2020-07-01 18:05:32 +02:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.link.sectionLink;
|
2015-04-19 21:05:12 +02:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[Link]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.link</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-07-01 18:05:32 +02:00
|
|
|
wireguardPeerOptions = {
|
|
|
|
options = {
|
|
|
|
wireguardPeerConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { };
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionWireGuardPeer;
|
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[WireGuardPeer]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-04-19 21:05:12 +02:00
|
|
|
netdevOptions = commonNetworkOptions // {
|
|
|
|
|
|
|
|
netdevConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Name = "mybridge"; Kind = "bridge"; };
|
2020-07-01 18:05:32 +02:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionNetdev;
|
2015-04-19 21:05:12 +02:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[Netdev]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.netdev</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
vlanConfig = mkOption {
|
|
|
|
default = {};
|
2020-07-08 20:43:17 +02:00
|
|
|
example = { Id = 4; };
|
2020-07-01 18:05:32 +02:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionVLAN;
|
2015-04-19 21:05:12 +02:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[VLAN]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.netdev</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
macvlanConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Mode = "private"; };
|
2020-07-01 18:05:32 +02:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionMACVLAN;
|
2015-04-19 21:05:12 +02:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[MACVLAN]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.netdev</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
vxlanConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Id = "4"; };
|
2020-07-01 18:05:32 +02:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionVXLAN;
|
2015-04-19 21:05:12 +02:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[VXLAN]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.netdev</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
tunnelConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Remote = "192.168.1.1"; };
|
2020-07-01 18:05:32 +02:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionTunnel;
|
2015-04-19 21:05:12 +02:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[Tunnel]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.netdev</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
peerConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Name = "veth2"; };
|
2020-07-01 18:05:32 +02:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionPeer;
|
2015-04-19 21:05:12 +02:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[Peer]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.netdev</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
tunConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { User = "openvpn"; };
|
2020-07-01 18:05:32 +02:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionTun;
|
2015-04-19 21:05:12 +02:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[Tun]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.netdev</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
tapConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { User = "openvpn"; };
|
2020-07-01 18:05:32 +02:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionTap;
|
2015-04-19 21:05:12 +02:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[Tap]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.netdev</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-07-01 18:05:32 +02:00
|
|
|
wireguardConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = {
|
|
|
|
PrivateKeyFile = "/etc/wireguard/secret.key";
|
|
|
|
ListenPort = 51820;
|
|
|
|
FwMark = 42;
|
|
|
|
};
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionWireGuard;
|
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[WireGuard]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.netdev</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
Use <literal>PrivateKeyFile</literal> instead of
|
|
|
|
<literal>PrivateKey</literal>: the nix store is
|
|
|
|
world-readable.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
wireguardPeers = mkOption {
|
|
|
|
default = [];
|
|
|
|
example = [ { wireguardPeerConfig={
|
|
|
|
Endpoint = "192.168.1.1:51820";
|
|
|
|
PublicKey = "27s0OvaBBdHoJYkH9osZpjpgSOVNw+RaKfboT/Sfq0g=";
|
|
|
|
PresharedKeyFile = "/etc/wireguard/psk.key";
|
|
|
|
AllowedIPs = [ "10.0.0.1/32" ];
|
|
|
|
PersistentKeepalive = 15;
|
|
|
|
};}];
|
|
|
|
type = with types; listOf (submodule wireguardPeerOptions);
|
|
|
|
description = ''
|
|
|
|
Each item in this array specifies an option in the
|
|
|
|
<literal>[WireGuardPeer]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.netdev</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
Use <literal>PresharedKeyFile</literal> instead of
|
|
|
|
<literal>PresharedKey</literal>: the nix store is
|
|
|
|
world-readable.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-04-19 21:05:12 +02:00
|
|
|
bondConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Mode = "802.3ad"; };
|
2020-07-01 18:05:32 +02:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionBond;
|
2015-04-19 21:05:12 +02:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[Bond]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.netdev</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-01-14 10:37:52 +01:00
|
|
|
xfrmConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { InterfaceId = 1; };
|
2020-07-01 18:05:32 +02:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionXfrm;
|
2020-01-14 10:37:52 +01:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[Xfrm]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.netdev</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-07-01 18:05:32 +02:00
|
|
|
vrfConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Table = 2342; };
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionVRF;
|
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[VRF]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.netdev</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
A detailed explanation about how VRFs work can be found in the
|
|
|
|
<link xlink:href="https://www.kernel.org/doc/Documentation/networking/vrf.txt">kernel
|
|
|
|
docs</link>.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-04-19 21:05:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
addressOptions = {
|
2016-10-03 06:02:42 +02:00
|
|
|
options = {
|
|
|
|
addressConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Address = "192.168.0.100/24"; };
|
2020-07-01 18:05:32 +02:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionAddress;
|
2016-10-03 06:02:42 +02:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[Address]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
2015-04-19 21:05:12 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-02-29 18:17:27 +01:00
|
|
|
routingPolicyRulesOptions = {
|
|
|
|
options = {
|
|
|
|
routingPolicyRuleConfig = mkOption {
|
|
|
|
default = { };
|
2020-02-29 19:34:48 +01:00
|
|
|
example = { routingPolicyRuleConfig = { Table = 10; IncomingInterface = "eth1"; Family = "both"; } ;};
|
2020-07-01 18:05:32 +02:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionRoutingPolicyRule;
|
2020-02-29 18:17:27 +01:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[RoutingPolicyRule]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-04-19 21:05:12 +02:00
|
|
|
routeOptions = {
|
2016-10-03 06:02:42 +02:00
|
|
|
options = {
|
|
|
|
routeConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Gateway = "192.168.0.1"; };
|
2020-07-01 18:05:32 +02:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionRoute;
|
2016-10-03 06:02:42 +02:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[Route]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
2015-04-19 21:05:12 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-03-07 15:06:58 +01:00
|
|
|
ipv6PrefixOptions = {
|
|
|
|
options = {
|
|
|
|
ipv6PrefixConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Prefix = "fd00::/64"; };
|
2020-07-01 18:05:32 +02:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionIPv6Prefix;
|
2020-03-07 15:06:58 +01:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[IPv6Prefix]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-04-19 21:05:12 +02:00
|
|
|
networkOptions = commonNetworkOptions // {
|
|
|
|
|
2020-07-01 18:05:32 +02:00
|
|
|
linkConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Unmanaged = true; };
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionLink;
|
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[Link]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-04-19 21:05:12 +02:00
|
|
|
networkConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Description = "My Network"; };
|
2020-07-01 18:05:32 +02:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionNetwork;
|
2015-04-19 21:05:12 +02:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[Network]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-01-08 20:18:26 +01:00
|
|
|
# systemd.network.networks.*.dhcpConfig has been deprecated in favor of ….dhcpV4Config
|
|
|
|
# Produce a nice warning message so users know it is gone.
|
2015-04-19 21:05:12 +02:00
|
|
|
dhcpConfig = mkOption {
|
2020-01-08 20:18:26 +01:00
|
|
|
visible = false;
|
|
|
|
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.";
|
|
|
|
};
|
|
|
|
|
|
|
|
dhcpV4Config = mkOption {
|
2015-04-19 21:05:12 +02:00
|
|
|
default = {};
|
|
|
|
example = { UseDNS = true; UseRoutes = true; };
|
2020-07-01 18:05:32 +02:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPv4;
|
2015-04-19 21:05:12 +02:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
2020-01-08 20:18:26 +01:00
|
|
|
<literal>[DHCPv4]</literal> section of the unit. See
|
2015-04-19 21:05:12 +02:00
|
|
|
<citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-01-08 20:15:09 +01:00
|
|
|
dhcpV6Config = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { UseDNS = true; UseRoutes = true; };
|
2020-07-01 18:05:32 +02:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPv6;
|
2020-01-08 20:15:09 +01:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
|
|
|
<literal>[DHCPv6]</literal> section of the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-07-01 18:05:32 +02:00
|
|
|
dhcpServerConfig = mkOption {
|
2020-03-07 14:44:46 +01:00
|
|
|
default = {};
|
2020-07-01 18:05:32 +02:00
|
|
|
example = { PoolOffset = 50; EmitDNS = false; };
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPServer;
|
2020-03-07 14:44:46 +01:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
2020-07-01 18:05:32 +02:00
|
|
|
<literal>[DHCPServer]</literal> section of the unit. See
|
2020-03-07 15:06:58 +01:00
|
|
|
<citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-07-01 18:05:32 +02:00
|
|
|
ipv6PrefixDelegationConfig = mkOption {
|
2015-12-23 06:04:39 +01:00
|
|
|
default = {};
|
2020-07-01 18:05:32 +02:00
|
|
|
example = { EmitDNS = true; Managed = true; OtherInformation = true; };
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionIPv6PrefixDelegation;
|
2015-12-23 06:04:39 +01:00
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option in the
|
2020-07-01 18:05:32 +02:00
|
|
|
<literal>[IPv6PrefixDelegation]</literal> section of the unit. See
|
2015-12-23 06:04:39 +01:00
|
|
|
<citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-07-01 18:05:32 +02:00
|
|
|
ipv6Prefixes = mkOption {
|
|
|
|
default = [];
|
|
|
|
example = { AddressAutoconfiguration = true; OnLink = true; };
|
|
|
|
type = with types; listOf (submodule ipv6PrefixOptions);
|
2017-07-27 19:49:56 +02:00
|
|
|
description = ''
|
2020-07-01 18:05:32 +02:00
|
|
|
A list of ipv6Prefix sections to be added to the unit. See
|
2017-07-27 19:49:56 +02:00
|
|
|
<citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-04-19 21:05:12 +02:00
|
|
|
name = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
description = ''
|
|
|
|
The name of the network interface to match against.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
DHCP = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
description = ''
|
|
|
|
Whether to enable DHCP on the interfaces matched.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
domains = mkOption {
|
|
|
|
type = types.nullOr (types.listOf types.str);
|
|
|
|
default = null;
|
|
|
|
description = ''
|
|
|
|
A list of domains to pass to the network config.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
address = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = ''
|
|
|
|
A list of addresses to be added to the network section of the
|
|
|
|
unit. See <citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
gateway = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = ''
|
|
|
|
A list of gateways to be added to the network section of the
|
|
|
|
unit. See <citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dns = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = ''
|
|
|
|
A list of dns servers to be added to the network section of the
|
|
|
|
unit. See <citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
ntp = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = ''
|
|
|
|
A list of ntp servers to be added to the network section of the
|
|
|
|
unit. See <citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-07-30 09:22:33 +02:00
|
|
|
bridge = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = ''
|
|
|
|
A list of bridge interfaces to be added to the network section of the
|
|
|
|
unit. See <citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
bond = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = ''
|
|
|
|
A list of bond interfaces to be added to the network section of the
|
|
|
|
unit. See <citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
vrf = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = ''
|
|
|
|
A list of vrf interfaces to be added to the network section of the
|
|
|
|
unit. See <citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-04-19 21:05:12 +02:00
|
|
|
vlan = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = ''
|
|
|
|
A list of vlan interfaces to be added to the network section of the
|
|
|
|
unit. See <citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
macvlan = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = ''
|
|
|
|
A list of macvlan interfaces to be added to the network section of the
|
|
|
|
unit. See <citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
vxlan = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = ''
|
|
|
|
A list of vxlan interfaces to be added to the network section of the
|
|
|
|
unit. See <citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
tunnel = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = ''
|
|
|
|
A list of tunnel interfaces to be added to the network section of the
|
|
|
|
unit. See <citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-01-14 10:37:52 +01:00
|
|
|
xfrm = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = ''
|
|
|
|
A list of xfrm interfaces to be added to the network section of the
|
|
|
|
unit. See <citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-04-19 21:05:12 +02:00
|
|
|
addresses = mkOption {
|
|
|
|
default = [ ];
|
2016-10-03 06:02:42 +02:00
|
|
|
type = with types; listOf (submodule addressOptions);
|
2015-04-19 21:05:12 +02:00
|
|
|
description = ''
|
|
|
|
A list of address sections to be added to the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-02-29 18:17:27 +01:00
|
|
|
routingPolicyRules = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = with types; listOf (submodule routingPolicyRulesOptions);
|
|
|
|
description = ''
|
|
|
|
A list of routing policy rules sections to be added to the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-04-19 21:05:12 +02:00
|
|
|
routes = mkOption {
|
|
|
|
default = [ ];
|
2016-10-03 06:02:42 +02:00
|
|
|
type = with types; listOf (submodule routeOptions);
|
2015-04-19 21:05:12 +02:00
|
|
|
description = ''
|
|
|
|
A list of route sections to be added to the unit. See
|
|
|
|
<citerefentry><refentrytitle>systemd.network</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-07-20 22:56:59 +02:00
|
|
|
networkConfig = { config, ... }: {
|
2015-04-19 21:05:12 +02:00
|
|
|
config = {
|
|
|
|
matchConfig = optionalAttrs (config.name != null) {
|
|
|
|
Name = config.name;
|
|
|
|
};
|
|
|
|
networkConfig = optionalAttrs (config.DHCP != null) {
|
|
|
|
DHCP = config.DHCP;
|
|
|
|
} // optionalAttrs (config.domains != null) {
|
|
|
|
Domains = concatStringsSep " " config.domains;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-07-01 19:27:49 +02:00
|
|
|
commonMatchText = def: optionalString (def.matchConfig != { }) ''
|
2015-04-30 06:44:25 +02:00
|
|
|
[Match]
|
|
|
|
${attrsToSection def.matchConfig}
|
|
|
|
'';
|
|
|
|
|
2015-04-19 21:05:12 +02:00
|
|
|
linkToUnit = name: def:
|
|
|
|
{ inherit (def) enable;
|
2020-07-01 19:27:49 +02:00
|
|
|
text = commonMatchText def
|
|
|
|
+ ''
|
2015-04-19 21:05:12 +02:00
|
|
|
[Link]
|
|
|
|
${attrsToSection def.linkConfig}
|
2020-07-01 19:27:49 +02:00
|
|
|
''
|
|
|
|
+ def.extraConfig;
|
2015-04-19 21:05:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
netdevToUnit = name: def:
|
|
|
|
{ inherit (def) enable;
|
2020-07-01 19:27:49 +02:00
|
|
|
text = commonMatchText def
|
|
|
|
+ ''
|
2015-04-19 21:05:12 +02:00
|
|
|
[NetDev]
|
|
|
|
${attrsToSection def.netdevConfig}
|
2020-07-01 19:27:49 +02:00
|
|
|
''
|
|
|
|
+ optionalString (def.vlanConfig != { }) ''
|
|
|
|
[VLAN]
|
|
|
|
${attrsToSection def.vlanConfig}
|
|
|
|
''
|
|
|
|
+ optionalString (def.macvlanConfig != { }) ''
|
|
|
|
[MACVLAN]
|
|
|
|
${attrsToSection def.macvlanConfig}
|
|
|
|
''
|
|
|
|
+ optionalString (def.vxlanConfig != { }) ''
|
|
|
|
[VXLAN]
|
|
|
|
${attrsToSection def.vxlanConfig}
|
|
|
|
''
|
|
|
|
+ optionalString (def.tunnelConfig != { }) ''
|
|
|
|
[Tunnel]
|
|
|
|
${attrsToSection def.tunnelConfig}
|
|
|
|
''
|
|
|
|
+ optionalString (def.peerConfig != { }) ''
|
|
|
|
[Peer]
|
|
|
|
${attrsToSection def.peerConfig}
|
|
|
|
''
|
|
|
|
+ optionalString (def.tunConfig != { }) ''
|
|
|
|
[Tun]
|
|
|
|
${attrsToSection def.tunConfig}
|
|
|
|
''
|
|
|
|
+ optionalString (def.tapConfig != { }) ''
|
|
|
|
[Tap]
|
|
|
|
${attrsToSection def.tapConfig}
|
|
|
|
''
|
|
|
|
+ optionalString (def.wireguardConfig != { }) ''
|
|
|
|
[WireGuard]
|
|
|
|
${attrsToSection def.wireguardConfig}
|
|
|
|
''
|
|
|
|
+ flip concatMapStrings def.wireguardPeers (x: ''
|
|
|
|
[WireGuardPeer]
|
|
|
|
${attrsToSection x.wireguardPeerConfig}
|
|
|
|
'')
|
|
|
|
+ optionalString (def.bondConfig != { }) ''
|
|
|
|
[Bond]
|
|
|
|
${attrsToSection def.bondConfig}
|
|
|
|
''
|
|
|
|
+ optionalString (def.xfrmConfig != { }) ''
|
|
|
|
[Xfrm]
|
|
|
|
${attrsToSection def.xfrmConfig}
|
|
|
|
''
|
|
|
|
+ optionalString (def.vrfConfig != { }) ''
|
|
|
|
[VRF]
|
|
|
|
${attrsToSection def.vrfConfig}
|
|
|
|
''
|
|
|
|
+ def.extraConfig;
|
2015-04-19 21:05:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
networkToUnit = name: def:
|
|
|
|
{ inherit (def) enable;
|
2020-07-01 19:27:49 +02:00
|
|
|
text = commonMatchText def
|
|
|
|
+ optionalString (def.linkConfig != { }) ''
|
|
|
|
[Link]
|
|
|
|
${attrsToSection def.linkConfig}
|
2015-04-19 21:05:12 +02:00
|
|
|
''
|
2020-07-01 19:27:49 +02:00
|
|
|
+ ''
|
2015-04-19 21:05:12 +02:00
|
|
|
[Network]
|
2020-07-01 19:27:49 +02:00
|
|
|
''
|
|
|
|
+ attrsToSection def.networkConfig
|
|
|
|
+ optionalString (def.address != [ ]) ''
|
2015-04-19 21:05:12 +02:00
|
|
|
${concatStringsSep "\n" (map (s: "Address=${s}") def.address)}
|
2020-07-01 19:27:49 +02:00
|
|
|
''
|
|
|
|
+ optionalString (def.gateway != [ ]) ''
|
2015-04-19 21:05:12 +02:00
|
|
|
${concatStringsSep "\n" (map (s: "Gateway=${s}") def.gateway)}
|
2020-07-01 19:27:49 +02:00
|
|
|
''
|
|
|
|
+ optionalString (def.dns != [ ]) ''
|
2015-04-19 21:05:12 +02:00
|
|
|
${concatStringsSep "\n" (map (s: "DNS=${s}") def.dns)}
|
2020-07-01 19:27:49 +02:00
|
|
|
''
|
|
|
|
+ optionalString (def.ntp != [ ]) ''
|
2015-04-19 21:05:12 +02:00
|
|
|
${concatStringsSep "\n" (map (s: "NTP=${s}") def.ntp)}
|
2020-07-01 19:27:49 +02:00
|
|
|
''
|
|
|
|
+ optionalString (def.bridge != [ ]) ''
|
2018-07-30 09:22:33 +02:00
|
|
|
${concatStringsSep "\n" (map (s: "Bridge=${s}") def.bridge)}
|
2020-07-01 19:27:49 +02:00
|
|
|
''
|
|
|
|
+ optionalString (def.bond != [ ]) ''
|
2018-07-30 09:22:33 +02:00
|
|
|
${concatStringsSep "\n" (map (s: "Bond=${s}") def.bond)}
|
2020-07-01 19:27:49 +02:00
|
|
|
''
|
|
|
|
+ optionalString (def.vrf != [ ]) ''
|
2018-07-30 09:22:33 +02:00
|
|
|
${concatStringsSep "\n" (map (s: "VRF=${s}") def.vrf)}
|
2020-07-01 19:27:49 +02:00
|
|
|
''
|
|
|
|
+ optionalString (def.vlan != [ ]) ''
|
2015-04-19 21:05:12 +02:00
|
|
|
${concatStringsSep "\n" (map (s: "VLAN=${s}") def.vlan)}
|
2020-07-01 19:27:49 +02:00
|
|
|
''
|
|
|
|
+ optionalString (def.macvlan != [ ]) ''
|
2015-04-19 21:05:12 +02:00
|
|
|
${concatStringsSep "\n" (map (s: "MACVLAN=${s}") def.macvlan)}
|
2020-07-01 19:27:49 +02:00
|
|
|
''
|
|
|
|
+ optionalString (def.vxlan != [ ]) ''
|
2015-04-19 21:05:12 +02:00
|
|
|
${concatStringsSep "\n" (map (s: "VXLAN=${s}") def.vxlan)}
|
2020-07-01 19:27:49 +02:00
|
|
|
''
|
|
|
|
+ optionalString (def.tunnel != [ ]) ''
|
2015-04-19 21:05:12 +02:00
|
|
|
${concatStringsSep "\n" (map (s: "Tunnel=${s}") def.tunnel)}
|
2020-07-01 19:27:49 +02:00
|
|
|
''
|
|
|
|
+ optionalString (def.xfrm != [ ]) ''
|
2020-01-14 10:37:52 +01:00
|
|
|
${concatStringsSep "\n" (map (s: "Xfrm=${s}") def.xfrm)}
|
2020-07-01 19:27:49 +02:00
|
|
|
''
|
|
|
|
+ ''
|
2015-04-19 21:05:12 +02:00
|
|
|
|
2020-07-01 19:27:49 +02:00
|
|
|
''
|
|
|
|
+ flip concatMapStrings def.addresses (x: ''
|
|
|
|
[Address]
|
|
|
|
${attrsToSection x.addressConfig}
|
|
|
|
'')
|
|
|
|
+ flip concatMapStrings def.routingPolicyRules (x: ''
|
|
|
|
[RoutingPolicyRule]
|
|
|
|
${attrsToSection x.routingPolicyRuleConfig}
|
|
|
|
'')
|
|
|
|
+ flip concatMapStrings def.routes (x: ''
|
|
|
|
[Route]
|
|
|
|
${attrsToSection x.routeConfig}
|
|
|
|
'')
|
|
|
|
+ optionalString (def.dhcpV4Config != { }) ''
|
|
|
|
[DHCPv4]
|
|
|
|
${attrsToSection def.dhcpV4Config}
|
|
|
|
''
|
|
|
|
+ optionalString (def.dhcpV6Config != { }) ''
|
|
|
|
[DHCPv6]
|
|
|
|
${attrsToSection def.dhcpV6Config}
|
|
|
|
''
|
|
|
|
+ optionalString (def.dhcpServerConfig != { }) ''
|
|
|
|
[DHCPServer]
|
|
|
|
${attrsToSection def.dhcpServerConfig}
|
|
|
|
''
|
|
|
|
+ optionalString (def.ipv6PrefixDelegationConfig != { }) ''
|
|
|
|
[IPv6PrefixDelegation]
|
|
|
|
${attrsToSection def.ipv6PrefixDelegationConfig}
|
|
|
|
''
|
|
|
|
+ flip concatMapStrings def.ipv6Prefixes (x: ''
|
|
|
|
[IPv6Prefix]
|
|
|
|
${attrsToSection x.ipv6PrefixConfig}
|
|
|
|
'')
|
|
|
|
+ def.extraConfig;
|
2015-04-19 21:05:12 +02:00
|
|
|
};
|
|
|
|
|
2019-09-14 19:51:29 +02:00
|
|
|
unitFiles = listToAttrs (map (name: {
|
|
|
|
name = "systemd/network/${name}";
|
|
|
|
value.source = "${cfg.units.${name}.unit}/${name}";
|
|
|
|
}) (attrNames cfg.units));
|
2015-04-19 21:05:12 +02:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
systemd.network.enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
description = ''
|
|
|
|
Whether to enable networkd or not.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.network.links = mkOption {
|
|
|
|
default = {};
|
2016-10-03 06:02:42 +02:00
|
|
|
type = with types; attrsOf (submodule [ { options = linkOptions; } ]);
|
2015-04-19 21:05:12 +02:00
|
|
|
description = "Definition of systemd network links.";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.network.netdevs = mkOption {
|
|
|
|
default = {};
|
2016-10-03 06:02:42 +02:00
|
|
|
type = with types; attrsOf (submodule [ { options = netdevOptions; } ]);
|
2015-04-19 21:05:12 +02:00
|
|
|
description = "Definition of systemd network devices.";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.network.networks = mkOption {
|
|
|
|
default = {};
|
2016-10-03 06:02:42 +02:00
|
|
|
type = with types; attrsOf (submodule [ { options = networkOptions; } networkConfig ]);
|
2015-04-19 21:05:12 +02:00
|
|
|
description = "Definition of systemd networks.";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.network.units = mkOption {
|
|
|
|
description = "Definition of networkd units.";
|
|
|
|
default = {};
|
2019-11-29 12:50:51 +01:00
|
|
|
internal = true;
|
2016-09-13 05:56:05 +02:00
|
|
|
type = with types; attrsOf (submodule (
|
|
|
|
{ name, config, ... }:
|
2019-11-29 12:50:51 +01:00
|
|
|
{ options = mapAttrs (_: x: x // { internal = true; }) concreteUnitOptions;
|
2015-04-19 21:05:12 +02:00
|
|
|
config = {
|
|
|
|
unit = mkDefault (makeUnit name config);
|
|
|
|
};
|
2016-09-13 05:56:05 +02:00
|
|
|
}));
|
2015-04-19 21:05:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-03-11 00:24:50 +01:00
|
|
|
config = mkMerge [
|
2020-01-08 20:18:26 +01:00
|
|
|
|
2020-03-11 00:24:50 +01:00
|
|
|
# .link units are honored by udev, no matter if systemd-networkd is enabled or not.
|
|
|
|
{
|
|
|
|
systemd.network.units = mapAttrs' (n: v: nameValuePair "${n}.link" (linkToUnit n v)) cfg.links;
|
|
|
|
environment.etc = unitFiles;
|
|
|
|
}
|
2015-04-19 21:05:12 +02:00
|
|
|
|
2020-03-11 00:24:50 +01:00
|
|
|
(mkIf config.systemd.network.enable {
|
2019-11-24 22:45:39 +01:00
|
|
|
|
2020-03-11 00:24:50 +01:00
|
|
|
users.users.systemd-network.group = "systemd-network";
|
2015-04-19 21:11:14 +02:00
|
|
|
|
2020-03-11 00:24:50 +01:00
|
|
|
systemd.additionalUpstreamSystemUnits = [
|
2020-05-19 11:04:14 +02:00
|
|
|
"systemd-networkd-wait-online.service"
|
|
|
|
"systemd-networkd.service"
|
|
|
|
"systemd-networkd.socket"
|
2020-03-11 00:24:50 +01:00
|
|
|
];
|
2015-04-19 21:05:12 +02:00
|
|
|
|
2020-03-11 00:24:50 +01:00
|
|
|
systemd.network.units = mapAttrs' (n: v: nameValuePair "${n}.netdev" (netdevToUnit n v)) cfg.netdevs
|
|
|
|
// mapAttrs' (n: v: nameValuePair "${n}.network" (networkToUnit n v)) cfg.networks;
|
2015-04-20 11:31:17 +02:00
|
|
|
|
2020-05-19 11:04:14 +02:00
|
|
|
# systemd-networkd is socket-activated by kernel netlink route change
|
|
|
|
# messages. It is important to have systemd buffer those on behalf of
|
|
|
|
# networkd.
|
|
|
|
systemd.sockets.systemd-networkd.wantedBy = [ "sockets.target" ];
|
|
|
|
|
2020-03-11 00:24:50 +01:00
|
|
|
systemd.services.systemd-networkd = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2020-05-19 11:04:14 +02:00
|
|
|
aliases = [ "dbus-org.freedesktop.network1.service" ];
|
2020-04-22 23:31:43 +02:00
|
|
|
restartTriggers = map (x: x.source) (attrValues unitFiles);
|
2020-03-11 00:24:50 +01:00
|
|
|
# prevent race condition with interface renaming (#39069)
|
|
|
|
requires = [ "systemd-udev-settle.service" ];
|
|
|
|
after = [ "systemd-udev-settle.service" ];
|
|
|
|
};
|
2015-04-19 21:05:12 +02:00
|
|
|
|
2020-03-11 00:24:50 +01:00
|
|
|
systemd.services.systemd-networkd-wait-online = {
|
|
|
|
wantedBy = [ "network-online.target" ];
|
|
|
|
};
|
2015-04-19 21:05:12 +02:00
|
|
|
|
2020-03-11 00:24:50 +01:00
|
|
|
systemd.services."systemd-network-wait-online@" = {
|
|
|
|
description = "Wait for Network Interface %I to be Configured";
|
|
|
|
conflicts = [ "shutdown.target" ];
|
|
|
|
requisite = [ "systemd-networkd.service" ];
|
|
|
|
after = [ "systemd-networkd.service" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = true;
|
|
|
|
ExecStart = "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online -i %I";
|
|
|
|
};
|
2015-04-19 21:05:12 +02:00
|
|
|
};
|
|
|
|
|
2020-03-11 00:24:50 +01:00
|
|
|
services.resolved.enable = mkDefault true;
|
|
|
|
})
|
|
|
|
];
|
2015-04-19 21:05:12 +02:00
|
|
|
}
|