git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #78745 from bene1618/dhcpcd

nixos/dhcpcd: Add option for dhcpcd waiting behaviour

commitc693bd142c1ad6ecfb2e432c93d2e7d3f22c4154 authorworldofpeace <worldofpeace@protonmail.ch> dateWed 29 Jan 2020, 18:08 (7 years ago) parentaf9bb2a0767de3
1 file changed+26−1
nixos/modules/services/networking/dhcpcd.nix+26−1
nixos/modules/services/networking/dhcpcd.nix+26−1
@@ -59,6 +59,16 @@ let
5959 # Use the list of allowed interfaces if specified
6060 ${optionalString (allowInterfaces != null) "allowinterfaces ${toString allowInterfaces}"}
6161
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+
6272 ${cfg.extraConfig}
6373 '';
6474
@@ -146,6 +156,21 @@ in
146156 '';
147157 };
148158
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+
149174 };
150175
151176
@@ -177,7 +202,7 @@ in
177202 serviceConfig =
178203 { Type = "forking";
179204 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}";
181206 ExecReload = "${dhcpcd}/sbin/dhcpcd --rebind";
182207 Restart = "always";
183208 };