From 1f34babe84854576c936969f8a879403be9f2515 Mon Sep 17 00:00:00 2001 From: Majiir Paktu Date: Fri, 25 Aug 2023 13:11:40 -0400 Subject: [PATCH] nixos/network-interfaces-systemd: add bridge interfaces in systemd-initrd --- .../tasks/network-interfaces-systemd.nix | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/nixos/modules/tasks/network-interfaces-systemd.nix b/nixos/modules/tasks/network-interfaces-systemd.nix index adbc7c80c418..679567cbb730 100644 --- a/nixos/modules/tasks/network-interfaces-systemd.nix +++ b/nixos/modules/tasks/network-interfaces-systemd.nix @@ -173,6 +173,20 @@ let }]; })); + bridgeNetworks = mkMerge (flip mapAttrsToList cfg.bridges (name: bridge: { + netdevs."40-${name}" = { + netdevConfig = { + Name = name; + Kind = "bridge"; + }; + }; + networks = listToAttrs (forEach bridge.interfaces (bi: + nameValuePair "40-${bi}" (mkMerge [ (genericNetwork (mkOverride 999)) { + DHCP = mkOverride 0 (dhcpStr false); + networkConfig.Bridge = name; + } ]))); + })); + vlanNetworks = mkMerge (flip mapAttrsToList cfg.vlans (name: vlan: { netdevs."40-${name}" = { netdevConfig = { @@ -198,9 +212,11 @@ in boot.initrd.systemd.network = mkMerge [ (genericDhcpNetworks true) interfaceNetworks + bridgeNetworks vlanNetworks ]; boot.initrd.availableKernelModules = + optional (cfg.bridges != {}) "bridge" ++ optional (cfg.vlans != {}) "8021q"; }) @@ -231,19 +247,7 @@ in } (genericDhcpNetworks false) interfaceNetworks - (mkMerge (flip mapAttrsToList cfg.bridges (name: bridge: { - netdevs."40-${name}" = { - netdevConfig = { - Name = name; - Kind = "bridge"; - }; - }; - networks = listToAttrs (forEach bridge.interfaces (bi: - nameValuePair "40-${bi}" (mkMerge [ (genericNetwork (mkOverride 999)) { - DHCP = mkOverride 0 (dhcpStr false); - networkConfig.Bridge = name; - } ]))); - }))) + bridgeNetworks (mkMerge (flip mapAttrsToList cfg.bonds (name: bond: { netdevs."40-${name}" = { netdevConfig = {