diff --git a/hive.nix b/hive.nix index c849d44..6de1f2c 100644 --- a/hive.nix +++ b/hive.nix @@ -1,21 +1,42 @@ let sources = import ./npins; + metadata = import ./meta; + + lib = import ./lib/trivial.nix; + + mkNode = node: { name, nodes, ... }: { + # Import the base configuration for each node + imports = builtins.map (lib.mkRel ./machines/${node}) [ + "_configuration.nix" + "_hardware-configuration.nix" + ]; + + # Deployment config is specified in meta.nodes.${node}.deployment + inherit (metadata.nodes.${node}) deployment; + }; + + mkNixpkgs = node: import sources."nixos-${metadata.nodes.${node}.nixpkgs}" { }; + + mkArgs = node: { + dgn-lib = import ./lib { inherit ((mkNixpkgs node)) lib; }; + }; + + nodes = builtins.attrNames metadata.nodes; in + { meta = { - nixpkgs = import sources.nixpkgs; + nodeNixpkgs = lib.mapSingleFuse mkNixpkgs nodes; - nodeNixpkgs = { - }; + specialArgs = { meta = metadata; }; + + nodeSpecialArgs = lib.mapSingleFuse mkArgs nodes; # TODO: Add remote builders (`machinesFile` option) }; - web-01 = { name, nodes, ... }: { - imports = [ ./machines/${name}/configuration.nix ]; - deployment = { - targetUser = "root"; - targetHost = "129.199.129.200"; - }; + defaults = { ... }: { + # Import the default modules + imports = [ ./modules ]; }; -} +} // (lib.mapSingleFuse mkNode nodes)