diff --git a/lib/build-clan/module.nix b/lib/build-clan/module.nix index 684e82669..12b8eda88 100644 --- a/lib/build-clan/module.nix +++ b/lib/build-clan/module.nix @@ -179,6 +179,7 @@ in # Merge the meta attributes from the buildClan function { inventory.modules = clan-core.clanModules; + inventory._legacyModules = clan-core.clanModules; } # config.inventory.meta <- config.meta { inventory.meta = config.meta; } diff --git a/lib/inventory/build-inventory/interface.nix b/lib/inventory/build-inventory/interface.nix index 318cb2e91..9d5449447 100644 --- a/lib/inventory/build-inventory/interface.nix +++ b/lib/inventory/build-inventory/interface.nix @@ -96,6 +96,12 @@ in ./assertions.nix ]; options = { + _legacyModules = lib.mkOption { + internal = true; + visible = false; + default = { }; + }; + options = lib.mkOption { internal = true; visible = false; @@ -138,6 +144,28 @@ in }; ``` ''; + + apply = + moduleSet: + let + allowedNames = lib.attrNames config._legacyModules; + in + if builtins.all (moduleName: builtins.elem moduleName allowedNames) (lib.attrNames moduleSet) then + moduleSet + else + lib.warn '' + `inventory.modules` will be deprecated soon. + + Please migrate the following modules into `clan.service` modules + and register them in `clan.modules` + + ${lib.concatStringsSep "\n" ( + map (m: "'${m}'") (lib.attrNames (lib.filterAttrs (n: _v: !builtins.elem n allowedNames) moduleSet)) + )} + + See: https://docs.clan.lol/manual/distributed-services/ + And: https://docs.clan.lol/authoring/clanServices/ + '' moduleSet; }; assertions = lib.mkOption { diff --git a/module.nix b/module.nix new file mode 100644 index 000000000..29c75278b --- /dev/null +++ b/module.nix @@ -0,0 +1,21 @@ +{ lib, ... }: +{ + _class = "clan.service"; + manifest.name = "test"; + + roles.peer.interface = + { ... }: + { + options.debug = lib.mkOption { default = 1; }; + }; + + roles.peer.perInstance = + { settings, ... }: + { + nixosModule = { + options.debug = lib.mkOption { + default = settings; + }; + }; + }; +}