build-inventory: replace by equivalent submodule

This commit is contained in:
Johannes Kirschbauer
2025-06-25 17:23:46 +02:00
parent 3585470759
commit ae4e18c152
4 changed files with 38 additions and 16 deletions

View File

@@ -21,7 +21,7 @@ let
inherit clanLib;
};
modules = [
./builder
./builder/default.nix
(lib.modules.importApply ./service-list-from-inputs.nix {
inherit flakeInputs clanLib localModuleSet;
})

View File

@@ -1,8 +1,7 @@
{ clanLib }:
{
config,
options,
lib,
clanLib,
...
}:
{

View File

@@ -207,7 +207,11 @@ in
clanModules = lib.mkOption { type = lib.types.raw; };
# The machine 'imports' generated by the inventory per machine
inventoryClass = lib.mkOption { type = lib.types.raw; };
inventoryClass = lib.mkOption {
type = types.submoduleWith {
modules = [ ];
};
};
# TODO: remove all dependents in python, delete this option
inventory = lib.mkOption {

View File

@@ -19,8 +19,6 @@ let
specialArgs
;
inherit (clan-core.clanLib.inventory) buildInventory;
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
@@ -43,18 +41,39 @@ let
if pkgs != null then pkgs else nixpkgs.legacyPackages.${system}
);
# map from machine name to service configuration
# { ${machineName} :: Config }
inventoryClass = (
buildInventory {
inherit inventory directory;
flakeInputs = config.self.inputs;
prefix = config._prefix ++ [ "inventoryClass" ];
# TODO: remove inventory.modules, this is here for backwards compatibility
inherit (clan-core) clanLib;
inventoryClass =
let
localModuleSet =
lib.filterAttrs (n: _: !inventory._legacyModules ? ${n}) inventory.modules // config.modules;
}
);
flakeInputs = config.self.inputs;
in
{
_module.args = {
inherit clanLib;
};
imports = [
../../inventory/build-inventory/builder/default.nix
(lib.modules.importApply ../../inventory/build-inventory/service-list-from-inputs.nix {
inherit localModuleSet flakeInputs clanLib;
})
{
inherit inventory directory;
}
(
{ config, ... }:
{
distributedServices = clanLib.inventory.mapInstances {
inherit (config) inventory;
inherit localModuleSet flakeInputs;
prefix = [ "distributedServices" ];
};
machines = config.distributedServices.allMachines;
}
)
../../inventory/build-inventory/inventory-introspection.nix
];
};
moduleSystemConstructor = {
# TODO: remove default system once we have a hardware-config mechanism