From c25910c796c223c204597ff507cf91ec9793293e Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Mon, 12 May 2025 16:12:43 +0200 Subject: [PATCH] Feat: print better error if module was migrated --- lib/inventory/frontmatter/default.nix | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/inventory/frontmatter/default.nix b/lib/inventory/frontmatter/default.nix index ce4a573b4..a340486ed 100644 --- a/lib/inventory/frontmatter/default.nix +++ b/lib/inventory/frontmatter/default.nix @@ -64,15 +64,30 @@ let ]; }).options; + migratedModules = [ "admin" ]; + + makeModuleNotFoundError = + serviceName: + if builtins.elem serviceName migratedModules then + '' + (Legacy) ClanModule not found: '${serviceName}'. + + Please update your configuration to use this module via 'inventory.instances' + See: https://docs.clan.lol/manual/distributed-services/ + '' + else + '' + (Legacy) ClanModule not found: '${serviceName}'. + + Make sure the module is added to inventory.modules.${serviceName} + ''; # This is a legacy function # Old modules needed to define their roles by directory # This means if this function gets anything other than a string/path it will throw getRoles = - scope: allModules: serviceName: + _scope: allModules: serviceName: let - module = - allModules.${serviceName} - or (throw "(Legacy) ClanModule not found: '${serviceName}'. Make sure the module is added to ${scope}"); + module = allModules.${serviceName} or (throw (makeModuleNotFoundError serviceName)); moduleType = (lib.typeOf module); checked = if