about summary refs log tree commit diff
path: root/machines/default.nix
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2016-05-03 01:03:47 +0200
committeraszlig <aszlig@redmoonstudios.org>2016-05-03 02:48:54 +0200
commit075067bfa2a59c39e960aba92f798cd626cd073d (patch)
treed1d1dc7b3130296246118eb6c80347f96fddbb89 /machines/default.nix
parent23a12bf4ba8cd9ac145a548cd8eb58a39b5abad8 (diff)
machines: Add a new callMachines function
This is particularly needed for the Labtops and it allows to call a full
attribute set of machines to be incorporated into a single file as one
big attribute set.

Its functionality is kind of similar to the NixOps network expressions
by providing default hostnames (in our case with a priority of 900 to
still make it overridable without pain).

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'machines/default.nix')
-rw-r--r--machines/default.nix11
1 files changed, 11 insertions, 0 deletions
diff --git a/machines/default.nix b/machines/default.nix
index 0f972829..11335a14 100644
--- a/machines/default.nix
+++ b/machines/default.nix
@@ -2,6 +2,17 @@
 
 let
   callMachine = import ../lib/call-machine.nix;
+  callMachines = path: args: let
+    machines = import path;
+  in with builtins; listToAttrs (map (name: {
+    inherit name;
+    value = callMachine machines.${name} ({
+      extraConfig = { lib, ... }: {
+        imports = lib.singleton (args.extraConfig or {});
+        networking.hostName = lib.mkOverride 900 name;
+      };
+    } // removeAttrs args [ "extraConfig" ]);
+  }) (attrNames machines));
   nixpkgs = import (import ../nixpkgs-path.nix) {};
 in {
   aszlig = {