From 12f553550f8fa63fb0e18d00ce769a4860ab4334 Mon Sep 17 00:00:00 2001 From: x7c2d Date: Sat, 25 Apr 2026 23:06:57 +0000 Subject: [PATCH] nixos/systemd-networkd: add new options for v260 systemd 260 introduces some new linkConfig options to configure ethernet devices and a new [MobileNetwork] section (and options) to configure cellular network connections using a new integration with ModemManager. - https://github.com/systemd/systemd/releases/tag/v260 --- nixos/lib/systemd-network-units.nix | 4 ++ nixos/modules/system/boot/networkd.nix | 58 ++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/nixos/lib/systemd-network-units.nix b/nixos/lib/systemd-network-units.nix index 5d3e9b3c9351..ada010e2c58d 100644 --- a/nixos/lib/systemd-network-units.nix +++ b/nixos/lib/systemd-network-units.nix @@ -413,6 +413,10 @@ in [QuickFairQueueingClass] ${attrsToSection def.quickFairQueueingConfigClass} '' + + optionalString (def.mobileNetworkConfig != { }) '' + [MobileNetwork] + ${attrsToSection def.mobileNetworkConfig} + '' + flip concatMapStrings def.bridgeVLANs (x: '' [BridgeVLAN] ${attrsToSection x} diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix index 0c74115c15a4..177478f28ac8 100644 --- a/nixos/modules/system/boot/networkd.nix +++ b/nixos/modules/system/boot/networkd.nix @@ -180,6 +180,12 @@ let "StatisticsBlockCoalesceSec" "MDI" "SR-IOVVirtualFunctions" + "ScatterGather" + "ScatterGatherFragmentList" + "TCPECNSegmentationOffload" + "TCPMangleIdSegmentationOffload" + "GenericReceiveOffloadList" + "GenericReceiveOffloadUDPForwarding" ]) (assertValueOneOf "MACAddressPolicy" [ "persistent" @@ -271,6 +277,12 @@ let "auto" ]) (assertRange "SR-IOVVirtualFunctions" 0 2147483647) + (assertValueOneOf "ScatterGather" boolValues) + (assertValueOneOf "ScatterGatherFragmentList" boolValues) + (assertValueOneOf "TCPECNSegmentationOffload" boolValues) + (assertValueOneOf "TCPMangleIdSegmentationOffload" boolValues) + (assertValueOneOf "GenericReceiveOffloadList" boolValues) + (assertValueOneOf "GenericReceiveOffloadUDPForwarding" boolValues) ]; sectionSR-IOV = checkUnitConfig "SR-IOV" [ @@ -2413,6 +2425,38 @@ let (assertInt "PVID") (assertRange "PVID" 0 4094) ]; + + sectionMobileNetwork = checkUnitConfig "MobileNetwork" [ + (assertOnlyFields [ + "APN" + "AllowedAuthenticationMechanisms" + "User" + "Password" + "IPFamily" + "AllowRoaming" + "PIN" + "OperatorId" + "RouteMetric" + "UseGateway" + ]) + (assertValuesSomeOfOr "AllowedAuthenticationMechanisms" [ + "none" + "pap" + "chap" + "mschap" + "mschapv2" + "eap" + ] "") + (assertValueOneOf "IPFamily" [ + "ipv4" + "ipv6" + "both" + "any" + ]) + (assertValueOneOf "AllowRoaming" boolValues) + (assertRange "RouteMetric" 0 4294967295) + (assertValueOneOf "UseGateway" boolValues) + ]; }; }; @@ -3747,6 +3791,20 @@ let ''; }; + mobileNetworkConfig = mkOption { + default = { }; + example = { + APN = "access-point-name"; + AllowRoaming = false; + }; + type = types.addCheck (types.attrsOf unitOption) check.network.sectionMobileNetwork; + description = '' + Each attribute in this set specifies an option in the + `[MobileNetwork]` section of the unit. See + {manpage}`systemd.network(5)` for details. + ''; + }; + name = mkOption { type = types.nullOr types.str; default = null;