diff options
author | Franz Pletz <fpletz@fnordicwalking.de> | 2017-09-18 14:46:37 +0200 |
---|---|---|
committer | Franz Pletz <fpletz@fnordicwalking.de> | 2017-09-18 14:51:38 +0200 |
commit | b1799084147b0b862eeffd7b4bb526de09fd34a5 (patch) | |
tree | 8b419be010a501c573f120bec9c590ff7041b11d /nixos/modules/services/networking/dhcpcd.nix | |
parent | a40533f70aa7cfe93a6a440150453ac296b249e3 (diff) |
nixos/networking: network is online if default gw set
Previously services depending on network-online.target would wait until
dhcpcd times out if it was enabled and a static network address
configuration was used. Setting the default gateway statically is enough
for the networking to be considered online.
This also adjusts the relevant networking tests to wait for
network-online.target instead of just network.target.
Diffstat (limited to 'nixos/modules/services/networking/dhcpcd.nix')
-rw-r--r-- | nixos/modules/services/networking/dhcpcd.nix | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/nixos/modules/services/networking/dhcpcd.nix b/nixos/modules/services/networking/dhcpcd.nix index cdba14be21f0..d283c7624335 100644 --- a/nixos/modules/services/networking/dhcpcd.nix +++ b/nixos/modules/services/networking/dhcpcd.nix @@ -153,10 +153,14 @@ in config = mkIf enableDHCP { - systemd.services.dhcpcd = + systemd.services.dhcpcd = let + cfgN = config.networking; + hasDefaultGatewaySet = (cfgN.defaultGateway != null && cfgN.defaultGateway.address != "") + || (cfgN.defaultGateway6 != null && cfgN.defaultGateway6.address != ""); + in { description = "DHCP Client"; - wantedBy = [ "network-online.target" ]; + wantedBy = optional (!hasDefaultGatewaySet) "network-online.target"; after = [ "network.target" ]; wants = [ "network.target" ]; |