nixos/network-interfaces: assertion for DHCP on bridges

Assert that the user doesn't have a bridge configured while
networking.useDHCP is true. Due to new behaviour of dhcpcd [0], this
would result in the bridge not getting an address via DHCP, regardless
of wether it has networking.interfaces.<name?>.useDHCP set or not.

[0] https://roy.marples.name/archives/dhcpcd-discuss/0002621.html
This commit is contained in:
Justin Humm
2020-04-04 00:47:21 +02:00
parent c2d5fe8586
commit 54ad186461

View File

@@ -976,6 +976,17 @@ in
Temporary addresses are only needed when IPv6 is enabled.
'';
})) ++ [
{
assertion = cfg.useDHCP -> cfg.bridges == {};
message = ''
There are the bridges [ ${builtins.toString (builtins.attrNames cfg.bridges)} ] configured while `networking.useDHCP` is enabled.
dhcpcd doesn't give IPv4 addresses to bridges by default anymore,
so you have to set `networking.useDHCP = false` and then whitelist
every interface you need DHCP on with
`networking.interfaces.<name?>.useDHCP = true`.
'';
}
] ++ [
{
assertion = cfg.hostId == null || (stringLength cfg.hostId == 8 && isHexString cfg.hostId);
message = "Invalid value given to the networking.hostId option.";