From 0fb1b5c5ce6d598bb552036c88e2297ee1a96992 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Sat, 29 Mar 2025 17:48:24 +0100 Subject: [PATCH] feat(inventory/instances): add service result to nixos machines --- lib/build-clan/module.nix | 3 +++ lib/distributed-service/inventory-adapter.nix | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/build-clan/module.nix b/lib/build-clan/module.nix index 0117ce42e..90756799f 100644 --- a/lib/build-clan/module.nix +++ b/lib/build-clan/module.nix @@ -77,6 +77,9 @@ let # Inherit the inventory assertions ? # { inherit (mergedInventory) assertions; } { imports = inventoryClass.machines.${name}.machineImports or [ ]; } + + # Import the distribute services + { imports = config.clanInternals.distributedServices.allMachines.${name} or []; } ( { # Settings diff --git a/lib/distributed-service/inventory-adapter.nix b/lib/distributed-service/inventory-adapter.nix index c07a8cadc..fde7bdfee 100644 --- a/lib/distributed-service/inventory-adapter.nix +++ b/lib/distributed-service/inventory-adapter.nix @@ -183,8 +183,17 @@ let ]; } ) { } importedModuleWithInstances; + + # TODO: Return an attribute set of resources instead of a plain list of nixosModules + allMachines = lib.foldlAttrs ( + acc: _name: eval: + acc + // lib.mapAttrs ( + machineName: result: acc.${machineName} or [ ] ++ [ result.nixosModule ] + ) eval.config.result.final + ) { } evals; in { inherit importedModuleWithInstances grouped; - inherit evals; + inherit evals allMachines; }