infrastructure/hive.nix

45 lines
1.1 KiB
Nix

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"
];
# Include default secrets
dgn-secrets.sources = [ ./machines/${node}/secrets ];
# 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 = {
nodeNixpkgs = lib.mapSingleFuse mkNixpkgs nodes;
specialArgs = { inherit sources; meta = metadata; };
nodeSpecialArgs = lib.mapSingleFuse mkArgs nodes;
# TODO: Add remote builders (`machinesFile` option)
};
defaults = { ... }: {
# Import the default modules
imports = [ ./modules ];
};
} // (lib.mapSingleFuse mkNode nodes)