nixos/network-interfaces-systemd: add bridge interfaces in systemd-initrd

This commit is contained in:
Majiir Paktu 2023-08-25 13:11:40 -04:00
parent a3211ceb47
commit 1f34babe84

View file

@ -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: { vlanNetworks = mkMerge (flip mapAttrsToList cfg.vlans (name: vlan: {
netdevs."40-${name}" = { netdevs."40-${name}" = {
netdevConfig = { netdevConfig = {
@ -198,9 +212,11 @@ in
boot.initrd.systemd.network = mkMerge [ boot.initrd.systemd.network = mkMerge [
(genericDhcpNetworks true) (genericDhcpNetworks true)
interfaceNetworks interfaceNetworks
bridgeNetworks
vlanNetworks vlanNetworks
]; ];
boot.initrd.availableKernelModules = boot.initrd.availableKernelModules =
optional (cfg.bridges != {}) "bridge" ++
optional (cfg.vlans != {}) "8021q"; optional (cfg.vlans != {}) "8021q";
}) })
@ -231,19 +247,7 @@ in
} }
(genericDhcpNetworks false) (genericDhcpNetworks false)
interfaceNetworks interfaceNetworks
(mkMerge (flip mapAttrsToList cfg.bridges (name: bridge: { bridgeNetworks
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;
} ])));
})))
(mkMerge (flip mapAttrsToList cfg.bonds (name: bond: { (mkMerge (flip mapAttrsToList cfg.bonds (name: bond: {
netdevs."40-${name}" = { netdevs."40-${name}" = {
netdevConfig = { netdevConfig = {