From fa183e54723e62f015813b01f848e855297d1538 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 21 May 2010 14:12:03 +0000 Subject: [PATCH] * Expose networking.interfaces as an attribute set keyed on the interface name through the derived option networking.ifaces. This makes it easier to get information about specific interfaces (e.g. `nodes.router.config.networking.ifaces.eth2.ipAddress'). Really networking.interfaces should be an attribute set. svn path=/nixos/trunk/; revision=21938 --- modules/tasks/network-interfaces.nix | 10 ++++++++++ tests/bittorrent.nix | 5 +++-- tests/nat.nix | 5 +++-- 3 files changed, 16 insertions(+), 4 deletions(-) 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 =