From 2715c398cc38a719254ac46dd9c9cb09fd205d7a Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 2 Apr 2025 11:09:09 +0200 Subject: [PATCH] fix(inventory/interface): use explizit file dependency, until dependency injection works properly --- flakeModules/clan.nix | 2 ++ lib/build-clan/default.nix | 1 + lib/build-clan/interface.nix | 5 ++++- lib/default.nix | 5 ++--- lib/inventory/default.nix | 4 ++-- lib/inventory/distributed-service/inventory-adapter.nix | 3 ++- lib/inventory/distributed-service/tests/per_machine_args.nix | 3 ++- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/flakeModules/clan.nix b/flakeModules/clan.nix index 07e84dbf4..ae960793c 100644 --- a/flakeModules/clan.nix +++ b/flakeModules/clan.nix @@ -35,6 +35,8 @@ in specialArgs = { inherit clan-core self; inherit (inputs) nixpkgs; + # TODO: inject the inventory interface + # inventoryInterface = {}; }; modules = [ buildClanModule.flakePartsModule diff --git a/lib/build-clan/default.nix b/lib/build-clan/default.nix index 35a0d7753..466368484 100644 --- a/lib/build-clan/default.nix +++ b/lib/build-clan/default.nix @@ -4,6 +4,7 @@ { lib, nixpkgs, + ... }: { flakePartsModule = { diff --git a/lib/build-clan/interface.nix b/lib/build-clan/interface.nix index 12a0690c3..cfcd62063 100644 --- a/lib/build-clan/interface.nix +++ b/lib/build-clan/interface.nix @@ -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. diff --git a/lib/default.nix b/lib/default.nix index 7ec821e4b..ca2c93ac3 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -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' diff --git a/lib/inventory/default.nix b/lib/inventory/default.nix index 7be7a2c51..9dec489c8 100644 --- a/lib/inventory/default.nix +++ b/lib/inventory/default.nix @@ -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 = { diff --git a/lib/inventory/distributed-service/inventory-adapter.nix b/lib/inventory/distributed-service/inventory-adapter.nix index 4075833c8..305295b15 100644 --- a/lib/inventory/distributed-service/inventory-adapter.nix +++ b/lib/inventory/distributed-service/inventory-adapter.nix @@ -169,5 +169,6 @@ in grouped allMachines - importedModulesEvaluated; + importedModulesEvaluated + ; } diff --git a/lib/inventory/distributed-service/tests/per_machine_args.nix b/lib/inventory/distributed-service/tests/per_machine_args.nix index 95931683e..67d51439e 100644 --- a/lib/inventory/distributed-service/tests/per_machine_args.nix +++ b/lib/inventory/distributed-service/tests/per_machine_args.nix @@ -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: