···5959 # Use the list of allowed interfaces if specified
6060 ${optionalString (allowInterfaces != null) "allowinterfaces ${toString allowInterfaces}"}
61616262+ # Immediately fork to background if specified, otherwise wait for IP address to be assigned
6363+ ${{
6464+ background = "background";
6565+ any = "waitip";
6666+ ipv4 = "waitip 4";
6767+ ipv6 = "waitip 6";
6868+ both = "waitip 4\nwaitip 6";
6969+ if-carrier-up = "";
7070+ }.${cfg.wait}}
7171+6272 ${cfg.extraConfig}
6373 '';
6474···146156 '';
147157 };
148158159159+ networking.dhcpcd.wait = mkOption {
160160+ type = types.enum [ "background" "any" "ipv4" "ipv6" "both" "if-carrier-up" ];
161161+ default = "any";
162162+ description = ''
163163+ This option specifies when the dhcpcd service will fork to background.
164164+ If set to "background", dhcpcd will fork to background immediately.
165165+ If set to "ipv4" or "ipv6", dhcpcd will wait for the corresponding IP
166166+ address to be assigned. If set to "any", dhcpcd will wait for any type
167167+ (IPv4 or IPv6) to be assigned. If set to "both", dhcpcd will wait for
168168+ both an IPv4 and an IPv6 address before forking.
169169+ The option "if-carrier-up" is equivalent to "any" if either ethernet
170170+ is plugged nor WiFi is powered, and to "background" otherwise.
171171+ '';
172172+ };
173173+149174 };
150175151176···177202 serviceConfig =
178203 { Type = "forking";
179204 PIDFile = "/run/dhcpcd.pid";
180180- ExecStart = "@${dhcpcd}/sbin/dhcpcd dhcpcd -w --quiet ${optionalString cfg.persistent "--persistent"} --config ${dhcpcdConf}";
205205+ ExecStart = "@${dhcpcd}/sbin/dhcpcd dhcpcd --quiet ${optionalString cfg.persistent "--persistent"} --config ${dhcpcdConf}";
181206 ExecReload = "${dhcpcd}/sbin/dhcpcd --rebind";
182207 Restart = "always";
183208 };