From 8f21e089a8de9eaa2512af25191d17077eca223a Mon Sep 17 00:00:00 2001 From: Peter Hoeg Date: Fri, 14 Apr 2017 11:10:49 +0800 Subject: [PATCH] networkd: only wait for network to be online if configured to do so --- nixos/modules/system/boot/networkd.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix index 9d2cea3ad16..85e5aa478f1 100644 --- a/nixos/modules/system/boot/networkd.nix +++ b/nixos/modules/system/boot/networkd.nix @@ -8,6 +8,8 @@ let cfg = config.systemd.network; + waitOnline = config.networking.waitForOnline; + checkLink = checkUnitConfig "Link" [ (assertOnlyFields [ "Description" "Alias" "MACAddressPolicy" "MACAddress" "NamePolicy" "Name" @@ -699,9 +701,9 @@ in config = mkIf config.systemd.network.enable { systemd.additionalUpstreamSystemUnits = [ - "systemd-networkd.service" "systemd-networkd-wait-online.service" "org.freedesktop.network1.busname" - ]; + "systemd-networkd.service" + ] ++ optional waitOnline "systemd-networkd-wait-online.service"; systemd.network.units = mapAttrs' (n: v: nameValuePair "${n}.link" (linkToUnit n v)) cfg.links // mapAttrs' (n: v: nameValuePair "${n}.netdev" (netdevToUnit n v)) cfg.netdevs @@ -714,11 +716,11 @@ in restartTriggers = map (f: f.source) (unitFiles); }; - systemd.services.systemd-networkd-wait-online = { + systemd.services.systemd-networkd-wait-online = lib.mkIf waitOnline { wantedBy = [ "network-online.target" ]; }; - systemd.services."systemd-network-wait-online@" = { + systemd.services."systemd-network-wait-online@" = lib.mkIf waitOnline { description = "Wait for Network Interface %I to be Configured"; conflicts = [ "shutdown.target" ]; requisite = [ "systemd-networkd.service" ];