aboutsummaryrefslogtreecommitdiff
path: root/nixos/modules/tasks
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2020-04-13 15:22:22 +0200
committerFlorian Klink <flokli@flokli.de>2020-04-13 22:03:35 +0200
commit532528190bdd739fda866645ba0078df28abc025 (patch)
tree69ee4625de6aac54d9d81f704fd01b10bdd84468 /nixos/modules/tasks
parentca391c8a4fcbdeae747fc1e0fe9858c651f47502 (diff)
nixos/networking: move network-link-${i.name} to scripted networking
The unit sets MTU and MAC Address even with networkd enabled, which isn't necessary anymore, as networkd handles this by itself.
Diffstat (limited to 'nixos/modules/tasks')
-rw-r--r--nixos/modules/tasks/network-interfaces-scripted.nix33
-rw-r--r--nixos/modules/tasks/network-interfaces.nix33
2 files changed, 34 insertions, 32 deletions
diff --git a/nixos/modules/tasks/network-interfaces-scripted.nix b/nixos/modules/tasks/network-interfaces-scripted.nix
index 98bae444df0d..9720d90217c6 100644
--- a/nixos/modules/tasks/network-interfaces-scripted.nix
+++ b/nixos/modules/tasks/network-interfaces-scripted.nix
@@ -237,6 +237,38 @@ let
'';
};
+ createNetworkLink = i:
+ let
+ deviceDependency = if (config.boot.isContainer || i.name == "lo")
+ then []
+ else [ (subsystemDevice i.name) ];
+ in
+ nameValuePair "network-link-${i.name}"
+ { description = "Link configuration of ${i.name}";
+ wantedBy = [ "network-interfaces.target" ];
+ before = [ "network-interfaces.target" ];
+ bindsTo = deviceDependency;
+ after = [ "network-pre.target" ] ++ deviceDependency;
+ path = [ pkgs.iproute ];
+ serviceConfig = {
+ Type = "oneshot";
+ RemainAfterExit = true;
+ };
+ script =
+ ''
+ echo "Configuring link..."
+ '' + optionalString (i.macAddress != null) ''
+ echo "setting MAC address to ${i.macAddress}..."
+ ip link set "${i.name}" address "${i.macAddress}"
+ '' + optionalString (i.mtu != null) ''
+ echo "setting MTU to ${toString i.mtu}..."
+ ip link set "${i.name}" mtu "${toString i.mtu}"
+ '' + ''
+ echo -n "bringing up interface... "
+ ip link set "${i.name}" up && echo "done" || (echo "failed"; exit 1)
+ '';
+ };
+
createTunDevice = i: nameValuePair "${i.name}-netdev"
{ description = "Virtual Network Interface ${i.name}";
bindsTo = [ "dev-net-tun.device" ];
@@ -508,6 +540,7 @@ let
});
in listToAttrs (
+ map createNetworkLink interfaces ++
map configureAddrs interfaces ++
map createTunDevice (filter (i: i.virtual) interfaces))
// mapAttrs' createBridgeDevice cfg.bridges
diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix
index 53430b0a9349..44677d417ead 100644
--- a/nixos/modules/tasks/network-interfaces.nix
+++ b/nixos/modules/tasks/network-interfaces.nix
@@ -1145,38 +1145,7 @@ in
${cfg.localCommands}
'';
};
- } // (listToAttrs (forEach interfaces (i:
- let
- deviceDependency = if (config.boot.isContainer || i.name == "lo")
- then []
- else [ (subsystemDevice i.name) ];
- in
- nameValuePair "network-link-${i.name}"
- { description = "Link configuration of ${i.name}";
- wantedBy = [ "network-interfaces.target" ];
- before = [ "network-interfaces.target" ];
- bindsTo = deviceDependency;
- after = [ "network-pre.target" ] ++ deviceDependency;
- path = [ pkgs.iproute ];
- serviceConfig = {
- Type = "oneshot";
- RemainAfterExit = true;
- };
- script =
- ''
- echo "Configuring link..."
- '' + optionalString (i.macAddress != null) ''
- echo "setting MAC address to ${i.macAddress}..."
- ip link set "${i.name}" address "${i.macAddress}"
- '' + optionalString (i.mtu != null) ''
- echo "setting MTU to ${toString i.mtu}..."
- ip link set "${i.name}" mtu "${toString i.mtu}"
- '' + ''
- echo -n "bringing up interface... "
- ip link set "${i.name}" up && echo "done" || (echo "failed"; exit 1)
- '';
- })));
-
+ };
services.mstpd = mkIf needsMstpd { enable = true; };
virtualisation.vswitch = mkIf (cfg.vswitches != { }) { enable = true; };