diff --git a/nixos/modules/tasks/network-interfaces-systemd.nix b/nixos/modules/tasks/network-interfaces-systemd.nix index 60aa66347e3a..ed903bf9994a 100644 --- a/nixos/modules/tasks/network-interfaces-systemd.nix +++ b/nixos/modules/tasks/network-interfaces-systemd.nix @@ -53,28 +53,26 @@ let ) ); - genericDhcpNetworks = - initrd: - mkIf cfg.useDHCP { - networks."99-ethernet-default-dhcp" = { - matchConfig = { - Type = "ether"; - Kind = "!*"; # physical interfaces have no kind - }; - DHCP = "yes"; - networkConfig.IPv6PrivacyExtensions = "kernel"; - }; - networks."99-wireless-client-dhcp" = { - matchConfig.WLANInterfaceType = "station"; - DHCP = "yes"; - networkConfig.IPv6PrivacyExtensions = "kernel"; - # We also set the route metric to one more than the default - # of 1024, so that Ethernet is preferred if both are - # available. - dhcpV4Config.RouteMetric = 1025; - ipv6AcceptRAConfig.RouteMetric = 1025; + genericDhcpNetworks = mkIf cfg.useDHCP { + networks."99-ethernet-default-dhcp" = { + matchConfig = { + Type = "ether"; + Kind = "!*"; # physical interfaces have no kind }; + DHCP = "yes"; + networkConfig.IPv6PrivacyExtensions = "kernel"; }; + networks."99-wireless-client-dhcp" = { + matchConfig.WLANInterfaceType = "station"; + DHCP = "yes"; + networkConfig.IPv6PrivacyExtensions = "kernel"; + # We also set the route metric to one more than the default + # of 1024, so that Ethernet is preferred if both are + # available. + dhcpV4Config.RouteMetric = 1025; + ipv6AcceptRAConfig.RouteMetric = 1025; + }; + }; interfaceNetworks = mkMerge ( forEach interfaces (i: { @@ -220,7 +218,7 @@ in # former, the user retains full control over the configuration. boot.initrd.systemd.network = mkMerge [ defaultGateways - (genericDhcpNetworks true) + genericDhcpNetworks interfaceNetworks bridgeNetworks vlanNetworks @@ -271,7 +269,7 @@ in enable = true; } defaultGateways - (genericDhcpNetworks false) + genericDhcpNetworks interfaceNetworks bridgeNetworks (mkMerge (