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 = { specialArgs = {
inherit clan-core self; inherit clan-core self;
inherit (inputs) nixpkgs; inherit (inputs) nixpkgs;
# TODO: inject the inventory interface
# inventoryInterface = {};
}; };
modules = [ modules = [
buildClanModule.flakePartsModule buildClanModule.flakePartsModule

View File

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

View File

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

View File

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

View File

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

View File

@@ -169,5 +169,6 @@ in
grouped grouped
allMachines 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; specificMachineSettings = filterInternals res.importedModulesEvaluated.self-A.config.result.allMachines.jon.nixosModule.instance_foo.roles.peer.machines.jon.settings;
hasRoleSettings = 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. # settings are specific.
# Below we access: # Below we access: