From dd5e03eac4d4c06ddcc4a0cfcdfb97eebf0aa0fa Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Mon, 2 Dec 2024 16:08:59 +0100 Subject: [PATCH] lib/types: standardise attrsOf functor.wrapped warning and add a test --- lib/tests/modules.sh | 4 ++++ lib/types.nix | 8 ++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index 4c00ecaab605bf..6085d4b7984ab3 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -391,6 +391,10 @@ checkConfigError 'The option `mergedLazyNonLazy'\'' in `.*'\'' is already declar checkConfigOutput '^11$' config.lazyResult ./lazy-attrsWith.nix checkConfigError 'infinite recursion encountered' config.nonLazyResult ./lazy-attrsWith.nix +# Test the attrsOf functor.wrapped warning +# shellcheck disable=2016 +NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `type.functor.wrapped` attribute of the option `mergedLazyLazy` is accessed, use `nestedTypes.elemType` instead.' options.mergedLazyLazy.type.functor.wrapped ./lazy-attrsWith.nix + # Even with multiple assignments, a type error should be thrown if any of them aren't valid checkConfigError 'A definition for option .* is not of type .*' \ config.value ./declare-int-unsigned-value.nix ./define-value-list.nix ./define-value-int-positive.nix diff --git a/lib/types.nix b/lib/types.nix index 41c53ec89ba65f..7f2ac26b67e2c9 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -636,12 +636,8 @@ rec { substSubModules = m: attrsWith { elemType = elemType.substSubModules m; inherit lazy; }; functor = defaultFunctor "attrsWith" // { wrappedDeprecationMessage = { loc }: lib.warn '' - Using 'functor.wrapped' on option types will be deprecated. - - Use 'nestedTypes.elemType' instead. - - option: '${showOption loc}' - '' elemType; + The deprecated `type.functor.wrapped` attribute of the option `${showOption loc}` is accessed, use `nestedTypes.elemType` instead. + '' elemType; payload = { # Important!: Add new function attributes here in case of future changes inherit elemType lazy;