diff options
author | William A. Kennington III <william@wkennington.com> | 2014-08-24 15:16:47 -0700 |
---|---|---|
committer | William A. Kennington III <william@wkennington.com> | 2014-08-30 08:20:14 -0700 |
commit | ed6040fc8dd833c31c67fadb54de320934e9668c (patch) | |
tree | d0fff0a08dd8d21fc7d6cdf51fb2fe7e01401ce5 /nixos/modules/tasks/network-interfaces.nix | |
parent | 1c08efb8ab258856c6b2cb8794bdc03c96c2b8c9 (diff) | |
download | nixlib-ed6040fc8dd833c31c67fadb54de320934e9668c.tar nixlib-ed6040fc8dd833c31c67fadb54de320934e9668c.tar.gz nixlib-ed6040fc8dd833c31c67fadb54de320934e9668c.tar.bz2 nixlib-ed6040fc8dd833c31c67fadb54de320934e9668c.tar.lz nixlib-ed6040fc8dd833c31c67fadb54de320934e9668c.tar.xz nixlib-ed6040fc8dd833c31c67fadb54de320934e9668c.tar.zst nixlib-ed6040fc8dd833c31c67fadb54de320934e9668c.zip |
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.
Diffstat (limited to 'nixos/modules/tasks/network-interfaces.nix')
-rw-r--r-- | nixos/modules/tasks/network-interfaces.nix | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix index 985e76cd7086..14bf96ced7a3 100644 --- a/nixos/modules/tasks/network-interfaces.nix +++ b/nixos/modules/tasks/network-interfaces.nix @@ -680,7 +680,7 @@ in ''); }; - createTunDevice = i: nameValuePair "${i.name}-tun" + createTunDevice = i: nameValuePair "${i.name}-netdev" { description = "Virtual Network Interface ${i.name}"; requires = [ "dev-net-tun.device" ]; after = [ "dev-net-tun.device" ]; @@ -701,8 +701,8 @@ in ''; }; - createBridgeDevice = n: v: - let + createBridgeDevice = n: v: nameValuePair "${n}-netdev" + (let deps = map (i: "sys-subsystem-net-devices-${i}.device") v.interfaces; in { description = "Bridge Interface ${n}"; @@ -739,10 +739,10 @@ in ip link set "${n}" down brctl delbr "${n}" ''; - }; + }); - createBondDevice = n: v: - let + createBondDevice = n: v: nameValuePair "${n}-netdev" + (let deps = map (i: "sys-subsystem-net-devices-${i}.device") v.interfaces; in { description = "Bond Interface ${n}"; @@ -778,10 +778,10 @@ in ifenslave -d "${n}" ip link delete "${n}" ''; - }; + }); - createSitDevice = n: v: - let + createSitDevice = n: v: nameValuePair "${n}-netdev" + (let deps = optional (v.dev != null) "sys-subsystem-net-devices-${v.dev}.device"; in { description = "6-to-4 Tunnel Interface ${n}"; @@ -804,10 +804,10 @@ in postStop = '' ip link delete "${n}" ''; - }; + }); - createVlanDevice = n: v: - let + createVlanDevice = n: v: nameValuePair "${n}-netdev" + (let deps = [ "sys-subsystem-net-devices-${v.interface}.device" ]; in { description = "Vlan Interface ${n}"; @@ -826,15 +826,15 @@ in postStop = '' ip link delete "${n}" ''; - }; + }); in listToAttrs ( map configureInterface interfaces ++ map createTunDevice (filter (i: i.virtual) interfaces)) - // mapAttrs createBridgeDevice cfg.bridges - // mapAttrs createBondDevice cfg.bonds - // mapAttrs createSitDevice cfg.sits - // mapAttrs createVlanDevice cfg.vlans + // mapAttrs' createBridgeDevice cfg.bridges + // mapAttrs' createBondDevice cfg.bonds + // mapAttrs' createSitDevice cfg.sits + // mapAttrs' createVlanDevice cfg.vlans // { "network-setup" = networkSetup; }; # Set the host and domain names in the activation script. Don't |