From aa96a113696ad641f4804a4b70c236db445df60c Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Tue, 24 Jun 2025 09:52:26 +0200 Subject: [PATCH 1/2] build-clan: move clan attribute relates modules into subfolder --- lib/modules/clan/default.nix | 9 +++++++++ lib/modules/default.nix | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 lib/modules/clan/default.nix diff --git a/lib/modules/clan/default.nix b/lib/modules/clan/default.nix new file mode 100644 index 000000000..ce9428b80 --- /dev/null +++ b/lib/modules/clan/default.nix @@ -0,0 +1,9 @@ +{clanLib}: { + _module.args = { + inherit clanLib; + }; + imports = [ + ./module.nix + ./interface.nix + ]; +} \ No newline at end of file diff --git a/lib/modules/default.nix b/lib/modules/default.nix index 2fb01f1c3..e27c89022 100644 --- a/lib/modules/default.nix +++ b/lib/modules/default.nix @@ -9,8 +9,7 @@ { flakePartsModule = { imports = [ - (lib.modules.importApply ./clan/interface.nix { inherit clanLib; }) - ./clan/module.nix + (lib.modules.importApply ./clan/default.nix { inherit clanLib; }) ]; }; From d0ae75e5ccb758ad66edfea2172f2e507c43b16d Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 25 Jun 2025 10:57:13 +0200 Subject: [PATCH 2/2] build-clan: export default.nix that injects clanLib This should be the single entry point, that includes clanLib instead of importApply propagation --- lib/inventory/build-inventory/default.nix | 2 +- lib/inventory/default.nix | 9 ++++++++- lib/modules/clan/default.nix | 5 +++-- lib/modules/clan/interface.nix | 2 +- lib/modules/eval-docs.nix | 2 +- lib/modules/function-adapter.nix | 2 +- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/inventory/build-inventory/default.nix b/lib/inventory/build-inventory/default.nix index 0e67452f4..8c023fd22 100644 --- a/lib/inventory/build-inventory/default.nix +++ b/lib/inventory/build-inventory/default.nix @@ -16,7 +16,7 @@ let localModuleSet ? { }, }: (lib.evalModules { - # TODO: remove clanLib from specialArgs + # TODO: move clanLib from specialArgs to options specialArgs = { inherit clanLib; }; diff --git a/lib/inventory/default.nix b/lib/inventory/default.nix index 66fa02330..129782dd9 100644 --- a/lib/inventory/default.nix +++ b/lib/inventory/default.nix @@ -5,7 +5,14 @@ in { inherit (services) evalClanService mapInstances resolveModule; inherit (import ./build-inventory { inherit lib clanLib; }) buildInventory; - interface = lib.modules.importApply ./build-inventory/interface.nix { inherit clanLib; }; + interface = { + imports = [ + (import ./build-inventory/interface.nix { inherit clanLib; }) + ]; + _module.args = { + inherit clanLib; + }; + }; # Returns the list of machine names # { ... } -> [ string ] resolveTags = diff --git a/lib/modules/clan/default.nix b/lib/modules/clan/default.nix index ce9428b80..975a584be 100644 --- a/lib/modules/clan/default.nix +++ b/lib/modules/clan/default.nix @@ -1,4 +1,5 @@ -{clanLib}: { +{ clanLib }: +{ _module.args = { inherit clanLib; }; @@ -6,4 +7,4 @@ ./module.nix ./interface.nix ]; -} \ No newline at end of file +} diff --git a/lib/modules/clan/interface.nix b/lib/modules/clan/interface.nix index d2bc92f5a..bf4599ef3 100644 --- a/lib/modules/clan/interface.nix +++ b/lib/modules/clan/interface.nix @@ -1,6 +1,6 @@ -{ clanLib }: { lib, + clanLib, self, # TODO: Use dependency injection to allow for testing # inventoryInterface, diff --git a/lib/modules/eval-docs.nix b/lib/modules/eval-docs.nix index b72e130bb..b1dfc9e1b 100644 --- a/lib/modules/eval-docs.nix +++ b/lib/modules/eval-docs.nix @@ -7,7 +7,7 @@ let eval = lib.evalModules { class = "nixos"; modules = [ - (lib.modules.importApply ./clan/interface.nix { inherit clanLib; }) + (import ./clan/default.nix { inherit clanLib; }) ]; }; evalDocs = pkgs.nixosOptionsDoc { diff --git a/lib/modules/function-adapter.nix b/lib/modules/function-adapter.nix index 9828e5d9c..0f8742091 100644 --- a/lib/modules/function-adapter.nix +++ b/lib/modules/function-adapter.nix @@ -18,7 +18,7 @@ module: ; }; modules = [ - (lib.modules.importApply ./clan/interface.nix { inherit (clan-core) clanLib; }) + (import ./clan/default.nix { inherit (clan-core) clanLib; }) module { inherit specialArgs;