about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-01-02 08:02:50 +0530
committergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2024-01-16 18:50:15 +0000
commit8ee02c665c4da02359a2ea5b3bdec59b91143bc8 (patch)
treee4c123f4d17c9f0d6dd4119e19248805866dd7fc
parentfc4e67c811b7681e72a0324be0144d627005ab3d (diff)
nixos/network-interfaces: fix implicit dependency on underlying device
the bug causes a hard dependency on an underlying device which might not be
valid for all interfaces, also broke the example for networking.sits. this is
due to calling hasAttr first and checking for null afterwards, the bug was
made more apparent in commit 76a3c30

(cherry picked from commit 8314af158f26563abf1f3ff4b95812afe8521a37)
-rw-r--r--nixos/modules/tasks/network-interfaces-scripted.nix5
1 files changed, 3 insertions, 2 deletions
diff --git a/nixos/modules/tasks/network-interfaces-scripted.nix b/nixos/modules/tasks/network-interfaces-scripted.nix
index e1ac7f24cb320..2f2d282fbefb4 100644
--- a/nixos/modules/tasks/network-interfaces-scripted.nix
+++ b/nixos/modules/tasks/network-interfaces-scripted.nix
@@ -70,7 +70,8 @@ let
         deviceDependency = dev:
           # Use systemd service if we manage device creation, else
           # trust udev when not in a container
-          if (hasAttr dev (filterAttrs (k: v: v.virtual) cfg.interfaces)) ||
+          if (dev == null || dev == "lo") then []
+          else if (hasAttr dev (filterAttrs (k: v: v.virtual) cfg.interfaces)) ||
              (hasAttr dev cfg.bridges) ||
              (hasAttr dev cfg.bonds) ||
              (hasAttr dev cfg.macvlans) ||
@@ -78,7 +79,7 @@ let
              (hasAttr dev cfg.vlans) ||
              (hasAttr dev cfg.vswitches)
           then [ "${dev}-netdev.service" ]
-          else optional (dev != null && dev != "lo" && !config.boot.isContainer) (subsystemDevice dev);
+          else optional (!config.boot.isContainer) (subsystemDevice dev);
 
         hasDefaultGatewaySet = (cfg.defaultGateway != null && cfg.defaultGateway.address != "")
                             || (cfg.enableIPv6 && cfg.defaultGateway6 != null && cfg.defaultGateway6.address != "");