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

This commit is contained in:
Majiir Paktu 2023-08-25 10:44:43 -04:00
parent 1f845ebc34
commit 2cb4671ebc

View file

@ -173,6 +173,19 @@ let
}]; }];
})); }));
vlanNetworks = mkMerge (flip mapAttrsToList cfg.vlans (name: vlan: {
netdevs."40-${name}" = {
netdevConfig = {
Name = name;
Kind = "vlan";
};
vlanConfig.Id = vlan.id;
};
networks."40-${vlan.interface}" = (mkMerge [ (genericNetwork (mkOverride 999)) {
vlan = [ name ];
} ]);
}));
in in
{ {
@ -182,7 +195,13 @@ in
# Note this is if initrd.network.enable, not if # Note this is if initrd.network.enable, not if
# initrd.systemd.network.enable. By setting the latter and not the # initrd.systemd.network.enable. By setting the latter and not the
# former, the user retains full control over the configuration. # former, the user retains full control over the configuration.
boot.initrd.systemd.network = mkMerge [(genericDhcpNetworks true) interfaceNetworks]; boot.initrd.systemd.network = mkMerge [
(genericDhcpNetworks true)
interfaceNetworks
vlanNetworks
];
boot.initrd.availableKernelModules =
optional (cfg.vlans != {}) "8021q";
}) })
(mkIf cfg.useNetworkd { (mkIf cfg.useNetworkd {
@ -377,18 +396,7 @@ in
} ]); } ]);
}; };
}))) })))
(mkMerge (flip mapAttrsToList cfg.vlans (name: vlan: { vlanNetworks
netdevs."40-${name}" = {
netdevConfig = {
Name = name;
Kind = "vlan";
};
vlanConfig.Id = vlan.id;
};
networks."40-${vlan.interface}" = (mkMerge [ (genericNetwork (mkOverride 999)) {
vlan = [ name ];
} ]);
})))
]; ];
# We need to prefill the slaved devices with networking options # We need to prefill the slaved devices with networking options