main
1{
2 inputs,
3 lib,
4 config,
5 withSystem,
6 ...
7}: let
8 prefix = config.flake.meta.host.prefix;
9 collectHostsModules = modules:
10 lib.filterAttrs
11 (name: _: lib.hasPrefix prefix name)
12 modules;
13in {
14 flake.nixosConfigurations =
15 lib.pipe
16 (collectHostsModules config.flake.modules.nixos)
17 [
18 (lib.mapAttrs' (
19 name: value: {
20 name = lib.removePrefix prefix name;
21 inherit value;
22 }
23 ))
24 (lib.mapAttrs' (
25 name: module: {
26 inherit name;
27 value = withSystem config.flake.meta.host.hosts.${name}.system (
28 {system, ...}:
29 inputs.nixpkgs.lib.nixosSystem {
30 # Fix vaultix error: attribute 'inputs' missing
31 # This is an anti-pattern of Dendritic Pattern
32 # I don't like this, but I don't see another way
33 specialArgs = {inherit (inputs) self;};
34
35 modules = [
36 module
37 {
38 networking.hostName = name;
39 nixpkgs.system = system;
40 }
41 ];
42 }
43 );
44 }
45 ))
46 ];
47}