diff --git a/modules/tasks/network-interfaces.nix b/modules/tasks/network-interfaces.nix index 28372450f24..836950f42a6 100644 --- a/modules/tasks/network-interfaces.nix +++ b/modules/tasks/network-interfaces.nix @@ -117,6 +117,16 @@ in }; + networking.ifaces = mkOption { + default = listToAttrs + (map (iface: { name = iface.name; value = iface; }) config.networking.interfaces); + internal = true; + description = '' + The network interfaces in + as an attribute set keyed on the interface name. + ''; + }; + }; diff --git a/tests/bittorrent.nix b/tests/bittorrent.nix index 26b7f106865..ac42fb33a85 100644 --- a/tests/bittorrent.nix +++ b/tests/bittorrent.nix @@ -42,10 +42,11 @@ in }; client1 = - { config, pkgs, ... }: + { config, pkgs, nodes, ... }: { environment.systemPackages = [ pkgs.transmission ]; virtualisation.vlans = [ 2 ]; - networking.defaultGateway = "192.168.2.3"; # !!! ugly + networking.defaultGateway = + nodes.router.config.networking.ifaces.eth2.ipAddress; }; client2 = diff --git a/tests/nat.nix b/tests/nat.nix index 611a4ff1325..7f2d8c6432f 100644 --- a/tests/nat.nix +++ b/tests/nat.nix @@ -10,9 +10,10 @@ nodes = { client = - { config, pkgs, ... }: + { config, pkgs, nodes, ... }: { virtualisation.vlans = [ 1 ]; - networking.defaultGateway = "192.168.1.2"; # !!! ugly + networking.defaultGateway = + nodes.router.config.networking.ifaces.eth2.ipAddress; }; router =