lib.types: Make functor.wrapped deprecation work in unprocessed types

Otherwise nested types such as `attrsOf (attrsOf int)` won't have a
backwards compatible `type.nestedTypes.elemType.functor.wrapped`.

Follow-up work to https://github.com/NixOS/nixpkgs/pull/366015
This commit is contained in:
Silvan Mosberger 2025-02-17 15:59:53 +01:00 committed by Johannes Kirschbauer
parent 7bbacbb11b
commit 64a1c1da3e
No known key found for this signature in database

View file

@ -86,7 +86,7 @@ let
else
{ elemType = merged; };
wrappedDeprecationMessage = { loc }: lib.warn ''
The deprecated `type.functor.wrapped` attribute of the option `${showOption loc}` is accessed, use `type.nestedTypes.elemType` instead.
The deprecated `${lib.optionalString (loc != null) "type."}functor.wrapped` attribute ${lib.optionalString (loc != null) "of the option `${showOption loc}` "}is accessed, use `${lib.optionalString (loc != null) "type."}nestedTypes.elemType` instead.
'' payload.elemType;
};
@ -227,7 +227,16 @@ rec {
{ _type = "option-type";
inherit
name check merge emptyValue getSubOptions getSubModules substSubModules
typeMerge functor deprecationMessage nestedTypes descriptionClass;
typeMerge deprecationMessage nestedTypes descriptionClass;
functor =
if functor ? wrappedDeprecationMessage then
functor // {
wrapped = functor.wrappedDeprecationMessage {
loc = null;
};
}
else
functor;
description = if description == null then name else description;
};