From 54ad1864617eb2a66b762e67d9a6ea06641bcbbf Mon Sep 17 00:00:00 2001 From: Justin Humm Date: Sat, 4 Apr 2020 00:47:21 +0200 Subject: [PATCH] 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..useDHCP set or not. [0] https://roy.marples.name/archives/dhcpcd-discuss/0002621.html --- nixos/modules/tasks/network-interfaces.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix index cef9c38c2e30..19bb0655af21 100644 --- a/nixos/modules/tasks/network-interfaces.nix +++ b/nixos/modules/tasks/network-interfaces.nix @@ -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..useDHCP = true`. + ''; + } + ] ++ [ { assertion = cfg.hostId == null || (stringLength cfg.hostId == 8 && isHexString cfg.hostId); message = "Invalid value given to the networking.hostId option.";