Skip to content

Commit

Permalink
nixos/network-interfaces: fix implicit dependency on underlying device
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sinanmohd committed Jan 2, 2024
1 parent 63143ac commit 8314af1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nixos/modules/tasks/network-interfaces-scripted.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,16 @@ 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) ||
(hasAttr dev cfg.sits) ||
(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 != "");
Expand Down

0 comments on commit 8314af1

Please sign in to comment.