config-perso/hive.nix

58 lines
1.2 KiB
Nix

let
mods = import ./modules;
users = import ./users;
sources = import ./npins;
pkgs = import sources.nixpkgs-unstable { };
inherit (pkgs) lib;
inherit (lib)
mapAttrs
mapAttrs'
removeSuffix
evalModules
;
nodes = mapAttrs' (name: _: {
name = removeSuffix ".nix" name;
value = import ./machines/${name};
}) (builtins.readDir ./machines);
meta' = evalModules {
modules = [
./kat/meta.nix
{ machines = mapAttrs (_: n: n.meta) nodes; }
];
specialArgs = {
inherit pkgs sources;
};
};
meta = meta'.config // {
machines = mapAttrs (_: node: node.node_meta) meta'.config.machines;
};
in
{
meta = {
nixpkgs = pkgs.path;
specialArgs = {
inherit
mods
users
sources
meta
;
kat-path = ./kat;
};
nodeNixpkgs = mapAttrs (_: node: node.nixpkgs-paths.nixpkgs-src) meta.machines;
nodeSpecialArgs = mapAttrs (_: node: { self-meta = node; }) meta.machines;
};
defaults =
{
name,
kat-path,
...
}:
{
imports = [ kat-path ];
networking.hostName = name;
};
}
// mapAttrs (_: n: n.config) nodes