From bb50241c6057c3996e469ea5049fa33a790336ed Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Tue, 26 May 2026 13:38:37 -0400 Subject: [PATCH] lib.modules: remove throwIfNot usage throwIfNot sends our error message through a function call, even if the error condition doesn't trigger. This requires a lot of thunk allocation that can be easily avoided. --- lib/modules.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/modules.nix b/lib/modules.nix index c5c935144ea6..a206ed6ed8e2 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -46,7 +46,6 @@ let setAttrByPath substring take - throwIfNot trace typeOf types @@ -680,8 +679,11 @@ let config = addFreeformType (addMeta (m.config or { })); } else - # shorthand syntax - throwIfNot (isAttrs m) "module ${file} (${key}) does not look like a module." { + # shorthand syntax + if !isAttrs m then + throw "module ${file} (${key}) does not look like a module." + else + { _file = toString m._file or file; _class = m._class or null; key = toString m.key or key;