diff options
author | Andreas Rammhold <andreas@rammhold.de> | 2020-01-08 20:18:26 +0100 |
---|---|---|
committer | Andreas Rammhold <andreas@rammhold.de> | 2020-05-01 13:33:54 +0200 |
commit | 819e8bb35f4a8371ee6af77dba9b8860041956b6 (patch) | |
tree | b2f03dda5a0b71391e6dd1e68019db71241044b7 /nixos/modules/system/boot/networkd.nix | |
parent | bb9b61e2b7d1dd14d9685bb188d13f45cdf21ad5 (diff) | |
download | nixpkgs-819e8bb35f4a8371ee6af77dba9b8860041956b6.tar nixpkgs-819e8bb35f4a8371ee6af77dba9b8860041956b6.tar.gz nixpkgs-819e8bb35f4a8371ee6af77dba9b8860041956b6.tar.bz2 nixpkgs-819e8bb35f4a8371ee6af77dba9b8860041956b6.tar.lz nixpkgs-819e8bb35f4a8371ee6af77dba9b8860041956b6.tar.xz nixpkgs-819e8bb35f4a8371ee6af77dba9b8860041956b6.tar.zst nixpkgs-819e8bb35f4a8371ee6af77dba9b8860041956b6.zip |
nixos/networkd: rename the networkd dhcpConfig option to dhcpV4Config
This follows upstreams change in documentation. While the `[DHCP]` section might still work it is undocumented and we should probably not be using it anymore. Users can just upgrade to the new option without much hassle. I had to create a bit of custom module deprecation code since the usual approach doesn't support wildcards in the path.
Diffstat (limited to 'nixos/modules/system/boot/networkd.nix')
-rw-r--r-- | nixos/modules/system/boot/networkd.nix | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix index c4790f59dff..887d1de95ff 100644 --- a/nixos/modules/system/boot/networkd.nix +++ b/nixos/modules/system/boot/networkd.nix @@ -275,13 +275,13 @@ let ]) ]; - checkDhcp = checkUnitConfig "DHCP" [ + checkDhcpV4 = checkUnitConfig "DHCPv4" [ (assertOnlyFields [ "UseDNS" "RoutesToDNS" "UseNTP" "UseMTU" "Anonymize" "SendHostname" "UseHostname" "Hostname" "UseDomains" "UseRoutes" "UseTimezone" "ClientIdentifier" "VendorClassIdentifier" "UserClass" "MaxAttempts" "DUIDType" "DUIDRawData" "IAID" "RequestBroadcast" "RouteMetric" "RouteTable" - "ListenPort" "SendRelease" "RapidCommit" + "ListenPort" "SendRelease" ]) (assertValueOneOf "UseDNS" boolValues) (assertValueOneOf "RoutesToDNS" boolValues) @@ -298,7 +298,6 @@ let (assertInt "RouteTable") (assertMinimum "RouteTable" 0) (assertValueOneOf "SendRelease" boolValues) - (assertValueOneOf "RapidCommit" boolValues) ]; checkDhcpV6 = checkUnitConfig "DHCPv6" [ @@ -649,13 +648,20 @@ let ''; }; + # systemd.network.networks.*.dhcpConfig has been deprecated in favor of ….dhcpV4Config + # Produce a nice warning message so users know it is gone. dhcpConfig = mkOption { + 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 { default = {}; example = { UseDNS = true; UseRoutes = true; }; - type = types.addCheck (types.attrsOf unitOption) checkDhcp; + type = types.addCheck (types.attrsOf unitOption) checkDhcpV4; description = '' Each attribute in this set specifies an option in the - <literal>[DHCP]</literal> section of the unit. See + <literal>[DHCPv4]</literal> section of the unit. See <citerefentry><refentrytitle>systemd.network</refentrytitle> <manvolnum>5</manvolnum></citerefentry> for details. ''; @@ -998,9 +1004,9 @@ let ${concatStringsSep "\n" (map (s: "Tunnel=${s}") def.tunnel)} ${concatStringsSep "\n" (map (s: "Xfrm=${s}") def.xfrm)} - ${optionalString (def.dhcpConfig != { }) '' - [DHCP] - ${attrsToSection def.dhcpConfig} + ${optionalString (def.dhcpV4Config != { }) '' + [DHCPv4] + ${attrsToSection def.dhcpV4Config} ''} ${optionalString (def.dhcpV6Config != {}) '' @@ -1084,6 +1090,7 @@ in }; config = mkMerge [ + # .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; |