nixos/network-interface: Append -netdev for all device units
Currently, device units are named directly after the name the user specifies for the device. A bridge device named lan will be defined within lan.service. This becomes a problem if you want your interface named nginx but also want to run the nginx service. This patch fixes the issue by appending netdev to all virtually created network device units. Therefore, the lan bridge -> lan-netdev.service. This naming convention is used for all types of network devices in order to ensure that all network devices are unique.
This commit is contained in:
parent
1c08efb8ab
commit
ed6040fc8d
@ -680,7 +680,7 @@ in
|
|||||||
'');
|
'');
|
||||||
};
|
};
|
||||||
|
|
||||||
createTunDevice = i: nameValuePair "${i.name}-tun"
|
createTunDevice = i: nameValuePair "${i.name}-netdev"
|
||||||
{ description = "Virtual Network Interface ${i.name}";
|
{ description = "Virtual Network Interface ${i.name}";
|
||||||
requires = [ "dev-net-tun.device" ];
|
requires = [ "dev-net-tun.device" ];
|
||||||
after = [ "dev-net-tun.device" ];
|
after = [ "dev-net-tun.device" ];
|
||||||
@ -701,8 +701,8 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
createBridgeDevice = n: v:
|
createBridgeDevice = n: v: nameValuePair "${n}-netdev"
|
||||||
let
|
(let
|
||||||
deps = map (i: "sys-subsystem-net-devices-${i}.device") v.interfaces;
|
deps = map (i: "sys-subsystem-net-devices-${i}.device") v.interfaces;
|
||||||
in
|
in
|
||||||
{ description = "Bridge Interface ${n}";
|
{ description = "Bridge Interface ${n}";
|
||||||
@ -739,10 +739,10 @@ in
|
|||||||
ip link set "${n}" down
|
ip link set "${n}" down
|
||||||
brctl delbr "${n}"
|
brctl delbr "${n}"
|
||||||
'';
|
'';
|
||||||
};
|
});
|
||||||
|
|
||||||
createBondDevice = n: v:
|
createBondDevice = n: v: nameValuePair "${n}-netdev"
|
||||||
let
|
(let
|
||||||
deps = map (i: "sys-subsystem-net-devices-${i}.device") v.interfaces;
|
deps = map (i: "sys-subsystem-net-devices-${i}.device") v.interfaces;
|
||||||
in
|
in
|
||||||
{ description = "Bond Interface ${n}";
|
{ description = "Bond Interface ${n}";
|
||||||
@ -778,10 +778,10 @@ in
|
|||||||
ifenslave -d "${n}"
|
ifenslave -d "${n}"
|
||||||
ip link delete "${n}"
|
ip link delete "${n}"
|
||||||
'';
|
'';
|
||||||
};
|
});
|
||||||
|
|
||||||
createSitDevice = n: v:
|
createSitDevice = n: v: nameValuePair "${n}-netdev"
|
||||||
let
|
(let
|
||||||
deps = optional (v.dev != null) "sys-subsystem-net-devices-${v.dev}.device";
|
deps = optional (v.dev != null) "sys-subsystem-net-devices-${v.dev}.device";
|
||||||
in
|
in
|
||||||
{ description = "6-to-4 Tunnel Interface ${n}";
|
{ description = "6-to-4 Tunnel Interface ${n}";
|
||||||
@ -804,10 +804,10 @@ in
|
|||||||
postStop = ''
|
postStop = ''
|
||||||
ip link delete "${n}"
|
ip link delete "${n}"
|
||||||
'';
|
'';
|
||||||
};
|
});
|
||||||
|
|
||||||
createVlanDevice = n: v:
|
createVlanDevice = n: v: nameValuePair "${n}-netdev"
|
||||||
let
|
(let
|
||||||
deps = [ "sys-subsystem-net-devices-${v.interface}.device" ];
|
deps = [ "sys-subsystem-net-devices-${v.interface}.device" ];
|
||||||
in
|
in
|
||||||
{ description = "Vlan Interface ${n}";
|
{ description = "Vlan Interface ${n}";
|
||||||
@ -826,15 +826,15 @@ in
|
|||||||
postStop = ''
|
postStop = ''
|
||||||
ip link delete "${n}"
|
ip link delete "${n}"
|
||||||
'';
|
'';
|
||||||
};
|
});
|
||||||
|
|
||||||
in listToAttrs (
|
in listToAttrs (
|
||||||
map configureInterface interfaces ++
|
map configureInterface interfaces ++
|
||||||
map createTunDevice (filter (i: i.virtual) interfaces))
|
map createTunDevice (filter (i: i.virtual) interfaces))
|
||||||
// mapAttrs createBridgeDevice cfg.bridges
|
// mapAttrs' createBridgeDevice cfg.bridges
|
||||||
// mapAttrs createBondDevice cfg.bonds
|
// mapAttrs' createBondDevice cfg.bonds
|
||||||
// mapAttrs createSitDevice cfg.sits
|
// mapAttrs' createSitDevice cfg.sits
|
||||||
// mapAttrs createVlanDevice cfg.vlans
|
// mapAttrs' createVlanDevice cfg.vlans
|
||||||
// { "network-setup" = networkSetup; };
|
// { "network-setup" = networkSetup; };
|
||||||
|
|
||||||
# Set the host and domain names in the activation script. Don't
|
# Set the host and domain names in the activation script. Don't
|
||||||
|
Loading…
x
Reference in New Issue
Block a user