Files
clan-core/lib/inventory/build-inventory/default.nix
Johannes Kirschbauer 05c45371af feat(buildInventory): move instance resolution into buildInventory
Such that buildClan doesn't have to compose the results
buildInventory should be more self contained. But it is NOT meant a
public API! use buildClan argument 'inventory' instead
2025-04-09 17:31:35 +02:00

42 lines
1.1 KiB
Nix

# Generate partial NixOS configurations for every machine in the inventory
# This function is responsible for generating the module configuration for every machine in the inventory.
{ lib, clanLib }:
let
/*
Returns a set with NixOS configuration for every machine in the inventory.
machinesFromInventory :: Inventory -> { ${machine_name} :: NixOSConfiguration }
*/
buildInventory =
{
inventory,
directory,
flakeInputs,
}:
(lib.evalModules {
specialArgs = {
inherit clanLib;
};
modules = [
./builder
{ inherit directory inventory; }
(
# config.distributedServices.allMachines.${name} or [ ];
{ config, ... }:
{
distributedServices = clanLib.inventory.mapInstances {
inherit (config) inventory;
inherit flakeInputs;
};
machines = lib.mapAttrs (machineName: v: {
machineImports = v;
}) config.distributedServices.allMachines;
}
)
];
}).config;
in
{
inherit buildInventory;
}