infrastructure/hive.nix

43 lines
1,018 B
Nix
Raw Normal View History

2023-05-16 23:50:06 +02:00
let
sources = import ./npins;
2023-05-22 15:08:33 +02:00
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;
2023-05-16 23:50:06 +02:00
in
2023-05-22 15:08:33 +02:00
2023-05-16 23:50:06 +02:00
{
meta = {
2023-05-22 15:08:33 +02:00
nodeNixpkgs = lib.mapSingleFuse mkNixpkgs nodes;
specialArgs = { meta = metadata; };
2023-05-16 23:50:06 +02:00
2023-05-22 15:08:33 +02:00
nodeSpecialArgs = lib.mapSingleFuse mkArgs nodes;
2023-05-16 23:50:06 +02:00
# TODO: Add remote builders (`machinesFile` option)
};
2023-05-22 15:08:33 +02:00
defaults = { ... }: {
# Import the default modules
imports = [ ./modules ];
2023-05-16 23:50:06 +02:00
};
2023-05-22 15:08:33 +02:00
} // (lib.mapSingleFuse mkNode nodes)