Unverified Commit 64a1c1da authored by Silvan Mosberger's avatar Silvan Mosberger Committed by Johannes Kirschbauer
Browse files

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
parent 7bbacbb1
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -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;
    };