config-perso/hive.nix

59 lines
1.2 KiB
Nix
Raw Normal View History

2024-05-14 19:21:19 +02:00
let
2024-03-13 11:11:16 +01:00
mods = import ./modules;
users = import ./users;
2024-06-01 00:28:17 +02:00
sources = import ./npins;
2024-12-15 16:19:19 +01:00
pkgs = import sources.nixpkgs-unstable { };
inherit (pkgs) lib;
inherit (lib)
mapAttrs
mapAttrs'
removeSuffix
evalModules
;
2024-12-15 16:19:19 +01:00
nodes = mapAttrs' (name: _: {
name = removeSuffix ".nix" name;
value = import ./machines/${name};
}) (builtins.readDir ./machines);
2024-12-15 16:19:19 +01:00
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;
};
2024-05-14 19:21:19 +02:00
in
{
2024-12-15 16:19:19 +01:00
meta = {
nixpkgs = pkgs.path;
specialArgs = {
2024-12-15 16:19:19 +01:00
inherit
mods
users
sources
meta
;
kat-path = ./kat;
};
2024-12-15 16:19:19 +01:00
nodeNixpkgs = mapAttrs (_: node: node.nixpkgs-paths.nixpkgs-src) meta.machines;
nodeSpecialArgs = mapAttrs (_: node: { self-meta = node; }) meta.machines;
2024-03-13 11:11:16 +01:00
};
2024-05-14 19:21:19 +02:00
defaults =
2024-06-01 16:26:08 +02:00
{
name,
2024-12-15 16:19:19 +01:00
kat-path,
2024-06-01 16:26:08 +02:00
...
}:
2024-05-14 19:21:19 +02:00
{
2024-12-15 16:19:19 +01:00
imports = [ kat-path ];
2024-09-26 11:51:04 +02:00
networking.hostName = name;
2024-05-14 19:21:19 +02:00
};
2024-03-12 17:26:16 +01:00
}
2024-12-15 16:19:19 +01:00
// mapAttrs (_: n: n.config) nodes