diff --git a/lib/build-clan/default.nix b/lib/build-clan/default.nix index 02e74aa99..7327814a0 100644 --- a/lib/build-clan/default.nix +++ b/lib/build-clan/default.nix @@ -3,12 +3,13 @@ ## Add any logic to ./module.nix { lib, + clanLib, ... }: { flakePartsModule = { imports = [ - ./interface.nix + (lib.modules.importApply ./interface.nix { inherit clanLib; }) ./module.nix ]; }; diff --git a/lib/build-clan/eval-docs.nix b/lib/build-clan/eval-docs.nix index 5ac1aca7d..584aa3e06 100644 --- a/lib/build-clan/eval-docs.nix +++ b/lib/build-clan/eval-docs.nix @@ -1,9 +1,13 @@ -{ pkgs, lib }: +{ + pkgs, + lib, + clanLib, +}: let eval = lib.evalModules { class = "nixos"; modules = [ - ./interface.nix + (lib.modules.importApply ./interface.nix { inherit clanLib; }) ]; }; evalDocs = pkgs.nixosOptionsDoc { diff --git a/lib/build-clan/flake-module.nix b/lib/build-clan/flake-module.nix index 5cb96520a..a03f618ca 100644 --- a/lib/build-clan/flake-module.nix +++ b/lib/build-clan/flake-module.nix @@ -19,6 +19,7 @@ in let jsonDocs = import ./eval-docs.nix { inherit pkgs lib; + inherit (self) clanLib; }; in { diff --git a/lib/build-clan/function-adapter.nix b/lib/build-clan/function-adapter.nix index aa8b1a601..cb5add50e 100644 --- a/lib/build-clan/function-adapter.nix +++ b/lib/build-clan/function-adapter.nix @@ -18,7 +18,7 @@ module: ; }; modules = [ - ./interface.nix + (lib.modules.importApply ./interface.nix { inherit (clan-core) clanLib; }) module { inherit specialArgs; diff --git a/lib/build-clan/interface.nix b/lib/build-clan/interface.nix index fa4f781bb..3d652a72b 100644 --- a/lib/build-clan/interface.nix +++ b/lib/build-clan/interface.nix @@ -1,3 +1,4 @@ +{ clanLib }: { lib, self, @@ -94,7 +95,11 @@ in }; inventory = lib.mkOption { - type = types.submodule { imports = [ ../inventory/build-inventory/interface.nix ]; }; + type = types.submodule { + imports = [ + (lib.modules.importApply ../inventory/build-inventory/interface.nix { inherit clanLib; }) + ]; + }; description = '' The `Inventory` submodule. diff --git a/lib/inventory/build-inventory/interface.nix b/lib/inventory/build-inventory/interface.nix index 8a4a60474..d1caca220 100644 --- a/lib/inventory/build-inventory/interface.nix +++ b/lib/inventory/build-inventory/interface.nix @@ -403,7 +403,7 @@ in }; settings = lib.mkOption { default = { }; - type = types.uniqueDeferredSerializableModule; + type = clanLib.types.uniqueDeferredSerializableModule; }; }; } diff --git a/lib/inventory/default.nix b/lib/inventory/default.nix index 9b3112f37..66fa02330 100644 --- a/lib/inventory/default.nix +++ b/lib/inventory/default.nix @@ -5,7 +5,7 @@ in { inherit (services) evalClanService mapInstances resolveModule; inherit (import ./build-inventory { inherit lib clanLib; }) buildInventory; - interface = ./build-inventory/interface.nix; + interface = lib.modules.importApply ./build-inventory/interface.nix { inherit clanLib; }; # Returns the list of machine names # { ... } -> [ string ] resolveTags = diff --git a/lib/inventory/schemas/default.nix b/lib/inventory/schemas/default.nix index e014b190a..048a03ae9 100644 --- a/lib/inventory/schemas/default.nix +++ b/lib/inventory/schemas/default.nix @@ -17,7 +17,9 @@ let frontMatterSchema = jsonLib.parseOptions self.clanLib.modules.frontmatterOptions { }; - inventorySchema = jsonLib.parseModule (import ../build-inventory/interface.nix); + inventorySchema = jsonLib.parseModule ( + import ../build-inventory/interface.nix { inherit (self) clanLib; } + ); renderSchema = pkgs.writers.writePython3Bin "render-schema" { flakeIgnore = [ diff --git a/lib/types/default.nix b/lib/types/default.nix index 0073c0d2b..aa00fcac4 100644 --- a/lib/types/default.nix +++ b/lib/types/default.nix @@ -4,7 +4,12 @@ self: let - checkDef = loc: def: if def.value ? imports then throw "uniqueDeferredSerializableModule doesn't allow nested imports" else def; + checkDef = + _loc: def: + if def.value ? imports then + throw "uniqueDeferredSerializableModule doesn't allow nested imports" + else + def; in # Essentially the "raw" type, but with a custom name and check lib.mkOptionType { @@ -18,8 +23,9 @@ merge = loc: defs: { imports = map ( def: - lib.seq (checkDef loc def) - lib.setDefaultModuleLocation "${def.file}, via option ${lib.showOption loc}" def.value + lib.seq (checkDef loc def) lib.setDefaultModuleLocation + "${def.file}, via option ${lib.showOption loc}" + def.value ) defs; }; }; diff --git a/lib/types/tests.nix b/lib/types/tests.nix index 850ffaf9d..ffcf9fb25 100644 --- a/lib/types/tests.nix +++ b/lib/types/tests.nix @@ -43,7 +43,7 @@ in let eval = evalSettingsModule { foo = { - imports = []; + imports = [ ]; }; }; in @@ -53,15 +53,17 @@ in expectedError = { type = "ThrownError"; message = "*nested imports"; - }; + }; }; test_no_function_modules = let eval = evalSettingsModule { - foo = {...}: { + foo = + { ... }: + { - }; + }; }; in {