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