From ce99cfa1039d81a377f044f4a079b5b3e2b781bb Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Tue, 26 May 2026 13:23:08 -0400 Subject: [PATCH] lib.types: remove assertMsg usage assertMsg 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/types.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/types.nix b/lib/types.nix index f9ae3c82a172..41acfd907854 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -408,7 +408,7 @@ rec { betweenDesc = lowest: highest: "${toString lowest} and ${toString highest} (both inclusive)"; between = lowest: highest: - assert lib.assertMsg (lowest <= highest) "ints.between: lowest must be smaller than highest"; + assert lowest <= highest || throw "ints.between: lowest must be smaller than highest"; addCheck int (x: x >= lowest && x <= highest) // { name = "intBetween"; @@ -495,7 +495,7 @@ rec { { between = lowest: highest: - assert lib.assertMsg (lowest <= highest) "numbers.between: lowest must be smaller than highest"; + assert lowest <= highest || throw "numbers.between: lowest must be smaller than highest"; addCheck number (x: x >= lowest && x <= highest) // { name = "numberBetween"; @@ -1728,9 +1728,9 @@ rec { # converted to `finalType` using `coerceFunc`. coercedTo = coercedType: coerceFunc: finalType: - assert lib.assertMsg ( + assert coercedType.getSubModules == null - ) "coercedTo: coercedType must not have submodules (it’s a ${coercedType.description})"; + || throw "coercedTo: coercedType must not have submodules (it’s a ${coercedType.description})"; mkOptionType rec { name = "coercedTo"; description = "${optionDescriptionPhrase (class: class == "noun") finalType} or ${