summaryrefslogtreecommitdiffstats
path: root/nixos/modules/tasks/network-interfaces-scripted.nix
diff options
context:
space:
mode:
authorFranz Pletz <fpletz@fnordicwalking.de>2017-09-18 14:46:37 +0200
committerFranz Pletz <fpletz@fnordicwalking.de>2017-09-18 14:51:38 +0200
commitb1799084147b0b862eeffd7b4bb526de09fd34a5 (patch)
tree8b419be010a501c573f120bec9c590ff7041b11d /nixos/modules/tasks/network-interfaces-scripted.nix
parenta40533f70aa7cfe93a6a440150453ac296b249e3 (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/tasks/network-interfaces-scripted.nix')
-rw-r--r--nixos/modules/tasks/network-interfaces-scripted.nix5
1 files changed, 4 insertions, 1 deletions
diff --git a/nixos/modules/tasks/network-interfaces-scripted.nix b/nixos/modules/tasks/network-interfaces-scripted.nix
index 15b36cfcb113..7ede8752bcc3 100644
--- a/nixos/modules/tasks/network-interfaces-scripted.nix
+++ b/nixos/modules/tasks/network-interfaces-scripted.nix
@@ -73,6 +73,9 @@ let
then [ "${dev}-netdev.service" ]
else optional (dev != null && dev != "lo" && !config.boot.isContainer) (subsystemDevice dev);
+ hasDefaultGatewaySet = (cfg.defaultGateway != null && cfg.defaultGateway.address != "")
+ || (cfg.defaultGateway6 != null && cfg.defaultGateway6.address != "");
+
networkLocalCommands = {
after = [ "network-setup.service" ];
bindsTo = [ "network-setup.service" ];
@@ -85,7 +88,7 @@ let
before = [ "network.target" "shutdown.target" ];
wants = [ "network.target" ];
conflicts = [ "shutdown.target" ];
- wantedBy = [ "multi-user.target" ];
+ wantedBy = [ "multi-user.target" ] ++ optional hasDefaultGatewaySet "network-online.target";
unitConfig.ConditionCapability = "CAP_NET_ADMIN";