feat(inventory/instances): map over all machines and return lazy attributes
This commit is contained in:
@@ -30,16 +30,13 @@ let
|
||||
# config.distributedServices.allMachines.${name} or [ ];
|
||||
{ config, ... }:
|
||||
{
|
||||
|
||||
distributedServices = clanLib.inventory.mapInstances {
|
||||
inherit (config) inventory;
|
||||
inherit localModuleSet;
|
||||
inherit flakeInputs;
|
||||
prefix = prefix ++ [ "distributedServices" ];
|
||||
};
|
||||
machines = lib.mapAttrs (_machineName: v: {
|
||||
machineImports = v;
|
||||
}) config.distributedServices.allMachines;
|
||||
machines = config.distributedServices.allMachines;
|
||||
|
||||
}
|
||||
)
|
||||
|
||||
@@ -157,6 +157,7 @@ in
|
||||
modules =
|
||||
[
|
||||
# Import the resolved module.
|
||||
# i.e. clan.modules.admin
|
||||
(builtins.head instances).instance.resolvedModule
|
||||
] # Include all the instances that correlate to the resolved module
|
||||
++ (builtins.map (v: {
|
||||
@@ -185,20 +186,18 @@ in
|
||||
}
|
||||
) { } importedModuleWithInstances;
|
||||
|
||||
# TODO: Return an attribute set of resources instead of a plain list of nixosModules
|
||||
allMachines = lib.foldlAttrs (
|
||||
allMachines = lib.mapAttrs (machineName: _: {
|
||||
# This is the list of nixosModules for each machine
|
||||
machineImports = lib.foldlAttrs (
|
||||
acc: _module_ident: eval:
|
||||
acc
|
||||
// lib.mapAttrs (
|
||||
machineName: result: acc.${machineName} or [ ] ++ [ result.nixosModule ]
|
||||
) eval.config.result.final
|
||||
) { } importedModulesEvaluated;
|
||||
acc ++ [ eval.config.result.final.${machineName}.nixosModule or {}]
|
||||
) [ ] importedModulesEvaluated;
|
||||
}) inventory.machines;
|
||||
in
|
||||
{
|
||||
inherit
|
||||
importedModuleWithInstances
|
||||
grouped
|
||||
|
||||
allMachines
|
||||
importedModulesEvaluated
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user