clanServices: remove unnecessary localModules

This commit is contained in:
Johannes Kirschbauer
2025-06-30 16:02:56 +02:00
parent 65f01c72bd
commit 1e94fd18f8
5 changed files with 26 additions and 24 deletions

View File

@@ -1,6 +1,6 @@
{
lib,
clanLib
clanLib,
}:
let
services = clanLib.callLib ./distributed-service/inventory-adapter.nix { };

View File

@@ -24,7 +24,6 @@ in
flakeInputs,
# The clan inventory
inventory,
localModuleSet,
clanCoreModules,
prefix ? [ ],
}:
@@ -37,7 +36,6 @@ in
let
resolvedModule = resolveModule {
moduleSpec = instance.module;
inherit localModuleSet;
inherit flakeInputs clanCoreModules;
};

View File

@@ -2,11 +2,9 @@
{
moduleSpec,
flakeInputs,
localModuleSet,
clanCoreModules,
}:
let
inputName = if moduleSpec.input == null then "<clan>" else moduleSpec.input;
inputError = throw ''
Flake doesn't provide input with name '${moduleSpec.input}'
@@ -31,20 +29,27 @@ let
input =
if moduleSpec.input == null then
{ clan.modules = clanCoreModules; }
else if moduleSpec.input == "self" then
{ clan.modules = localModuleSet; }
else
flakeInputs.${moduleSpec.input} or inputError;
in
input.clan.modules
or (throw "flake input ${moduleSpec.input} doesn't export any clan services via the `clan.modules` output attribute");
or (throw "flake input '${moduleSpec.input}' doesn't export any clan services via the `clan.modules` output attribute");
resolvedModule =
resolvedModuleSet.${moduleSpec.name} or (throw ''
flake input '${inputName}' doesn't provide clan-module with name ${moduleSpec.name}.
${
lib.optionalString (
moduleSpec.input != null
) "flake input '${moduleSpec.input}' doesn't provide clan-module with name '${moduleSpec.name}'."
}${
lib.optionalString (
moduleSpec.input == null
) "clan-core doesn't provide clan-module with name '${moduleSpec.name}'."
}
Set `module.name = "self"` if the module is defined in your own flake.
Set `module.input = "self"` if the module is defined in your own flake.
Set `module.input = "<flake-input>" if the module is defined by a flake input called `<flake-input>`.
Unset `module.input` (or set module.input = null) - to use the clan-core module '${moduleSpec.name}'
'');
in
resolvedModule

View File

@@ -27,28 +27,27 @@ let
];
}).config;
flakeInputsFixture = {
# Example upstream module
upstream.clan.modules = {
uzzi = {
_class = "clan.service";
manifest = {
name = "uzzi-from-upstream";
};
};
};
};
callInventoryAdapter =
inventoryModule:
let
inventory = evalInventory inventoryModule;
flakeInputsFixture = {
self.clan.modules = inventory.modules;
# Example upstream module
upstream.clan.modules = {
uzzi = {
_class = "clan.service";
manifest = {
name = "uzzi-from-upstream";
};
};
};
};
in
clanLib.inventory.mapInstances {
clanCoreModules = { };
flakeInputs = flakeInputsFixture;
inherit inventory;
localModuleSet = inventory.modules;
};
in
{