lol

Merge pull request #78745 from bene1618/dhcpcd

nixos/dhcpcd: Add option for dhcpcd waiting behaviour

authored by

worldofpeace and committed by
GitHub
c693bd14 af9bb2af

+26 -1
+26 -1
nixos/modules/services/networking/dhcpcd.nix
··· 59 59 # Use the list of allowed interfaces if specified 60 60 ${optionalString (allowInterfaces != null) "allowinterfaces ${toString allowInterfaces}"} 61 61 62 + # Immediately fork to background if specified, otherwise wait for IP address to be assigned 63 + ${{ 64 + background = "background"; 65 + any = "waitip"; 66 + ipv4 = "waitip 4"; 67 + ipv6 = "waitip 6"; 68 + both = "waitip 4\nwaitip 6"; 69 + if-carrier-up = ""; 70 + }.${cfg.wait}} 71 + 62 72 ${cfg.extraConfig} 63 73 ''; 64 74 ··· 146 156 ''; 147 157 }; 148 158 159 + networking.dhcpcd.wait = mkOption { 160 + type = types.enum [ "background" "any" "ipv4" "ipv6" "both" "if-carrier-up" ]; 161 + default = "any"; 162 + description = '' 163 + This option specifies when the dhcpcd service will fork to background. 164 + If set to "background", dhcpcd will fork to background immediately. 165 + If set to "ipv4" or "ipv6", dhcpcd will wait for the corresponding IP 166 + address to be assigned. If set to "any", dhcpcd will wait for any type 167 + (IPv4 or IPv6) to be assigned. If set to "both", dhcpcd will wait for 168 + both an IPv4 and an IPv6 address before forking. 169 + The option "if-carrier-up" is equivalent to "any" if either ethernet 170 + is plugged nor WiFi is powered, and to "background" otherwise. 171 + ''; 172 + }; 173 + 149 174 }; 150 175 151 176 ··· 177 202 serviceConfig = 178 203 { Type = "forking"; 179 204 PIDFile = "/run/dhcpcd.pid"; 180 - ExecStart = "@${dhcpcd}/sbin/dhcpcd dhcpcd -w --quiet ${optionalString cfg.persistent "--persistent"} --config ${dhcpcdConf}"; 205 + ExecStart = "@${dhcpcd}/sbin/dhcpcd dhcpcd --quiet ${optionalString cfg.persistent "--persistent"} --config ${dhcpcdConf}"; 181 206 ExecReload = "${dhcpcd}/sbin/dhcpcd --rebind"; 182 207 Restart = "always"; 183 208 };