Unverified Commit 4f123107 authored by Johannes Kirschbauer's avatar Johannes Kirschbauer
Browse files

lib/types: types.coercedTo deprecate functor.wrapped in favor of functor.payload.elemType

parent f6214eb7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@
    - `lib.types.unique` and `lib.types.uniq`
    - `lib.types.nullOr`
    - `lib.types.functionTo`
    - `lib.types.coercedTo`

- Plasma 5 and Qt 5 based versions of associated software are deprecated in NixOS 25.05, and will be removed in NixOS 25.11. Users are encouraged to upgrade to Plasma 6.

+6 −0
Original line number Diff line number Diff line
@@ -434,6 +434,12 @@ NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribu
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.functionTo.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nix
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedFunctionTo.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nix

# coercedTo
# Note: test 'nestedTypes.finalType' and 'nestedTypes.coercedType'
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.coercedTo.type.functor.wrapped ./deprecated-wrapped.nix
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.coercedTo.type.nestedTypes.finalType.functor.wrapped ./deprecated-wrapped.nix
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.coercedTo.type.nestedTypes.coercedType.functor.wrapped ./deprecated-wrapped.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
+7 −1
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ let
    unique
    nullOr
    functionTo
    coercedTo
    ;
in
{
@@ -43,13 +44,18 @@ in
        options.mergedNullOr = mkOption {
          type = nullOr (listOf types.str);
        };
        # nullOr
        # functionTo
        options.functionTo = mkOption {
          type = functionTo (listOf types.str);
        };
        options.mergedFunctionTo = mkOption {
          type = functionTo (listOf types.str);
        };
        # coercedTo
        # Note: coercedTo is a non-mergeable option-type
        options.coercedTo = mkOption {
          type = coercedTo (listOf types.str) lib.id (listOf types.str);
        };
      }
    )
    # Module B
+7 −4
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ let
  # Note that individual attributes can be overriden if needed.
  elemTypeFunctor = name: { elemType, ... }@payload: {
    inherit name payload;
    wrappedDeprecationMessage = makeWrappedDeprecationMessage payload;
    type    = outer_types.types.${name};
    binOp   = a: b:
      let
@@ -85,10 +86,10 @@ let
          null
        else
          { elemType = merged; };
    wrappedDeprecationMessage = { loc }: lib.warn ''
  };
  makeWrappedDeprecationMessage = payload: { loc }: lib.warn ''
    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;
  };


  outer_types =
@@ -1163,7 +1164,9 @@ rec {
        getSubModules = finalType.getSubModules;
        substSubModules = m: coercedTo coercedType coerceFunc (finalType.substSubModules m);
        typeMerge = t: null;
        functor = (defaultFunctor name) // { wrapped = finalType; };
        functor = (defaultFunctor name) // {
          wrappedDeprecationMessage = makeWrappedDeprecationMessage { elemType = finalType; };
        };
        nestedTypes.coercedType = coercedType;
        nestedTypes.finalType = finalType;
      };