Skip to content

Commit

Permalink
lib.types: Make functor.wrapped deprecation work in unprocessed types
Browse files Browse the repository at this point in the history
Otherwise nested types such as `attrsOf (attrsOf int)` won't have a
backwards compatible `type.nestedTypes.elemType.functor.wrapped`.

Follow-up work to #366015
  • Loading branch information
infinisil authored and hsjobeki committed Feb 19, 2025
1 parent 7bbacbb commit 64a1c1d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/types.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down Expand Up @@ -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;
};

Expand Down

0 comments on commit 64a1c1d

Please sign in to comment.