@@ -46,6 +46,23 @@ in
4646 systemd.services =
4747 let
4848
49+ deviceDependency = dev:
50+ if (config.boot.isContainer == false)
51+ then
52+ # Trust udev when not in the container
53+ [ (subsystemDevice dev) ]
54+ else
55+ # When in the container, check whether the interface is built from other definitions
56+ if (hasAttr dev cfg.bridges) ||
57+ (hasAttr dev cfg.bonds) ||
58+ (hasAttr dev cfg.macvlans) ||
59+ (hasAttr dev cfg.sits) ||
60+ (hasAttr dev cfg.vlans) ||
61+ (hasAttr dev cfg.vswitches) ||
62+ (hasAttr dev cfg.wlanInterfaces)
63+ then [ "${dev}-netdev.service" ]
64+ else [];
65+
4966 networkLocalCommands = {
5067 after = [ "network-setup.service" ];
5168 bindsTo = [ "network-setup.service" ];
@@ -120,8 +137,8 @@ in
120137 # order before network-setup because the routes that are configured
121138 # there may need ip addresses configured
122139 before = [ "network-setup.service" ];
123− bindsTo = [ (subsystemDevice i.name) ];
124− after = [ (subsystemDevice i.name) "network-pre.target" ];
140+ bindsTo = deviceDependency i.name;
141+ after = [ "network-pre.target" ] ++ (deviceDependency i.name);
125142 serviceConfig.Type = "oneshot";
126143 serviceConfig.RemainAfterExit = true;
127144 path = [ pkgs.iproute ];
@@ -179,7 +196,7 @@ in
179196
180197 createBridgeDevice = n: v: nameValuePair "${n}-netdev"
181198 (let
182− deps = map subsystemDevice v.interfaces;
199+ deps = if config.boot.isContainer then [] else map subsystemDevice v.interfaces;
183200 in
184201 { description = "Bridge Interface ${n}";
185202 wantedBy = [ "network-setup.service" (subsystemDevice n) ];
@@ -220,7 +237,7 @@ in
220237
221238 createVswitchDevice = n: v: nameValuePair "${n}-netdev"
222239 (let
223− deps = map subsystemDevice v.interfaces;
240+ deps = if config.boot.isContainer then [] else map subsystemDevice v.interfaces;
224241 ofRules = pkgs.writeText "vswitch-${n}-openFlowRules" v.openFlowRules;
225242 in
226243 { description = "Open vSwitch Interface ${n}";
@@ -253,7 +270,7 @@ in
253270
254271 createBondDevice = n: v: nameValuePair "${n}-netdev"
255272 (let
256− deps = map subsystemDevice v.interfaces;
273+ deps = if config.boot.isContainer then [] else map subsystemDevice v.interfaces;
257274 in
258275 { description = "Bond Interface ${n}";
259276 wantedBy = [ "network-setup.service" (subsystemDevice n) ];
@@ -291,7 +308,7 @@ in
291308
292309 createMacvlanDevice = n: v: nameValuePair "${n}-netdev"
293310 (let
294− deps = [ (subsystemDevice v.interface) ];
311+ deps = deviceDependency v.interface;
295312 in
296313 { description = "Vlan Interface ${n}";
297314 wantedBy = [ "network-setup.service" (subsystemDevice n) ];
@@ -316,7 +333,7 @@ in
316333
317334 createSitDevice = n: v: nameValuePair "${n}-netdev"
318335 (let
319− deps = optional (v.dev != null) (subsystemDevice v.dev);
336+ deps = optional (v.dev != null) (deviceDependency v.dev);
320337 in
321338 { description = "6-to-4 Tunnel Interface ${n}";
322339 wantedBy = [ "network-setup.service" (subsystemDevice n) ];
@@ -344,7 +361,7 @@ in
344361
345362 createVlanDevice = n: v: nameValuePair "${n}-netdev"
346363 (let
347− deps = [ (subsystemDevice v.interface) ];
364+ deps = deviceDependency v.interface;
348365 in
349366 { description = "Vlan Interface ${n}";
350367 wantedBy = [ "network-setup.service" (subsystemDevice n) ];