fix(inventory/interface): use explizit file dependency, until dependency injection works properly

This commit is contained in:
Johannes Kirschbauer
2025-04-02 11:09:09 +02:00
parent 6e16d1345e
commit f6f0c1b356
7 changed files with 15 additions and 8 deletions

View File

@@ -35,6 +35,8 @@ in
specialArgs = {
inherit clan-core self;
inherit (inputs) nixpkgs;
# TODO: inject the inventory interface
# inventoryInterface = {};
};
modules = [
buildClanModule.flakePartsModule

View File

@@ -4,6 +4,7 @@
{
lib,
nixpkgs,
...
}:
{
flakePartsModule = {

View File

@@ -1,6 +1,8 @@
{
lib,
self,
# TODO: Use dependency injection to allow for testing
# inventoryInterface,
...
}:
let
@@ -79,7 +81,7 @@ in
};
inventory = lib.mkOption {
type = types.submodule { imports = [ self.clanLib.inventory.interface ]; };
type = types.submodule { imports = [ ../inventory/build-inventory/interface.nix ]; };
description = ''
The `Inventory` submodule.
@@ -128,6 +130,7 @@ in
visible = false;
# ClanInternals
type = types.submodule {
freeformType = types.attrsOf types.raw;
options = {
# Those options are interfaced by the CLI
# We don't specify the type here, for better performance.

View File

@@ -20,9 +20,8 @@ lib.fix (clanLib: {
clan-core = self;
pkgs = nixpkgs.legacyPackages.x86_64-linux;
};
buildClanModule = import ./build-clan {
inherit lib nixpkgs;
};
buildClanModule = clanLib.callLib ./build-clan { inherit nixpkgs; };
buildClan = clanLib.buildClanModule.buildClanWith { clan-core = self; };
# ------------------------------------
# Lib functions that don't depend on 'self'

View File

@@ -2,8 +2,8 @@
{
inherit (import ./build-inventory { inherit lib clanLib; }) buildInventory;
interface = ./build-inventory/interface.nix;
mapInstances = clanLib.callLib ./distributed-service/inventory-adapter.nix {};
# Returns the list of machine names
mapInstances = clanLib.callLib ./distributed-service/inventory-adapter.nix { };
# Returns the list of machine names
# { ... } -> [ string ]
resolveTags =
{

View File

@@ -169,5 +169,6 @@ in
grouped
allMachines
importedModulesEvaluated;
importedModulesEvaluated
;
}

View File

@@ -84,7 +84,8 @@ in
specificMachineSettings = filterInternals res.importedModulesEvaluated.self-A.config.result.allMachines.jon.nixosModule.instance_foo.roles.peer.machines.jon.settings;
hasRoleSettings =
res.importedModulesEvaluated.self-A.config.result.allMachines.jon.nixosModule.instance_foo.roles.peer ? settings;
res.importedModulesEvaluated.self-A.config.result.allMachines.jon.nixosModule.instance_foo.roles.peer
? settings;
# settings are specific.
# Below we access: