From 58b0058419e9caebfdb9628b8ac89413c22b6973 Mon Sep 17 00:00:00 2001 From: aszlig Date: Tue, 3 May 2016 02:28:23 +0200 Subject: lib/call-network: Pass nodes attribute to modules On NixOps as well as for NixOS test networks, there is a nodes attribute which allows to reference configuration definitions from other modules. Currently this isn't used at all but might come in handy if we want to cross-reference machine configurations (for example referencing IP addresses in a static network configuration). Signed-off-by: aszlig --- lib/call-network.nix | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/call-network.nix b/lib/call-network.nix index dac125e7..d9e073f1 100644 --- a/lib/call-network.nix +++ b/lib/call-network.nix @@ -1,15 +1,21 @@ path: args: -with builtins; +with import "${import ../nixpkgs-path.nix}/lib"; let - machines = import path; -in listToAttrs (map (name: { - inherit name; - value = import ./call-machine.nix machines.${name} ({ - extraConfig = { lib, ... }: { - imports = lib.singleton (args.extraConfig or {}); - networking.hostName = lib.mkOverride 900 name; - }; - } // removeAttrs args [ "extraConfig" ]); -}) (attrNames machines)) + machineAttrs = import path; + + mkMachine = name: { + inherit name; + value = import ./call-machine.nix machineAttrs.${name} ({ + extraConfig = { lib, ... }: { + imports = lib.singleton (args.extraConfig or {}); + networking.hostName = lib.mkOverride 900 name; + _module.args.nodes = mapAttrs (const (m: m ? eval)) machines; + }; + } // removeAttrs args [ "extraConfig" ]); + }; + + machines = listToAttrs (map mkMachine (attrNames machineAttrs)); + +in machines -- cgit 1.4.1