mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +03:00
lib/types: types deprecate functor.wrapped in favor of functor.payload.elemType for trivial cases (#375084)
This commit is contained in:
commit
987a096334
4 changed files with 83 additions and 7 deletions
|
@ -75,6 +75,10 @@
|
||||||
- `functor.wrapped` is now deprecated for some types and using it will give a warning with migration instructions. It is deprecated for these types:
|
- `functor.wrapped` is now deprecated for some types and using it will give a warning with migration instructions. It is deprecated for these types:
|
||||||
- `lib.types.attrsWith`
|
- `lib.types.attrsWith`
|
||||||
- `lib.types.listOf`
|
- `lib.types.listOf`
|
||||||
|
- `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.
|
- 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.
|
||||||
|
|
||||||
|
|
|
@ -415,6 +415,30 @@ 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.listOf.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.listOf.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.mergedListOf.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.mergedListOf.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nix
|
||||||
|
# unique / uniq
|
||||||
|
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.unique.type.functor.wrapped ./deprecated-wrapped.nix
|
||||||
|
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedUnique.type.functor.wrapped ./deprecated-wrapped.nix
|
||||||
|
|
||||||
|
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.unique.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.mergedUnique.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nix
|
||||||
|
# nullOr
|
||||||
|
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.nullOr.type.functor.wrapped ./deprecated-wrapped.nix
|
||||||
|
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedNullOr.type.functor.wrapped ./deprecated-wrapped.nix
|
||||||
|
|
||||||
|
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.nullOr.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.mergedNullOr.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nix
|
||||||
|
# functionTo
|
||||||
|
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.functionTo.type.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.functor.wrapped ./deprecated-wrapped.nix
|
||||||
|
|
||||||
|
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
|
# 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 .*' \
|
checkConfigError 'A definition for option .* is not of type .*' \
|
||||||
|
|
|
@ -6,6 +6,10 @@ let
|
||||||
# attrsOf uses attrsWith internally
|
# attrsOf uses attrsWith internally
|
||||||
attrsOf
|
attrsOf
|
||||||
listOf
|
listOf
|
||||||
|
unique
|
||||||
|
nullOr
|
||||||
|
functionTo
|
||||||
|
coercedTo
|
||||||
;
|
;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -26,6 +30,32 @@ in
|
||||||
options.mergedListOf = mkOption {
|
options.mergedListOf = mkOption {
|
||||||
type = listOf (listOf types.str);
|
type = listOf (listOf types.str);
|
||||||
};
|
};
|
||||||
|
# unique
|
||||||
|
options.unique = mkOption {
|
||||||
|
type = unique { message = ""; } (listOf types.str);
|
||||||
|
};
|
||||||
|
options.mergedUnique = mkOption {
|
||||||
|
type = unique { message = ""; } (listOf types.str);
|
||||||
|
};
|
||||||
|
# nullOr
|
||||||
|
options.nullOr = mkOption {
|
||||||
|
type = nullOr (listOf types.str);
|
||||||
|
};
|
||||||
|
options.mergedNullOr = mkOption {
|
||||||
|
type = nullOr (listOf types.str);
|
||||||
|
};
|
||||||
|
# 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
|
# Module B
|
||||||
|
@ -38,6 +68,15 @@ in
|
||||||
options.mergedListOf = mkOption {
|
options.mergedListOf = mkOption {
|
||||||
type = listOf (listOf types.str);
|
type = listOf (listOf types.str);
|
||||||
};
|
};
|
||||||
|
options.mergedUnique = mkOption {
|
||||||
|
type = unique { message = ""; } (listOf types.str);
|
||||||
|
};
|
||||||
|
options.mergedNullOr = mkOption {
|
||||||
|
type = nullOr (listOf types.str);
|
||||||
|
};
|
||||||
|
options.mergedFunctionTo = mkOption {
|
||||||
|
type = functionTo (listOf types.str);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
|
|
|
@ -75,6 +75,7 @@ let
|
||||||
# Note that individual attributes can be overriden if needed.
|
# Note that individual attributes can be overriden if needed.
|
||||||
elemTypeFunctor = name: { elemType, ... }@payload: {
|
elemTypeFunctor = name: { elemType, ... }@payload: {
|
||||||
inherit name payload;
|
inherit name payload;
|
||||||
|
wrappedDeprecationMessage = makeWrappedDeprecationMessage payload;
|
||||||
type = outer_types.types.${name};
|
type = outer_types.types.${name};
|
||||||
binOp = a: b:
|
binOp = a: b:
|
||||||
let
|
let
|
||||||
|
@ -85,10 +86,10 @@ let
|
||||||
null
|
null
|
||||||
else
|
else
|
||||||
{ elemType = merged; };
|
{ elemType = merged; };
|
||||||
wrappedDeprecationMessage = { 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;
|
|
||||||
};
|
};
|
||||||
|
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 =
|
outer_types =
|
||||||
|
@ -853,7 +854,9 @@ rec {
|
||||||
getSubOptions = type.getSubOptions;
|
getSubOptions = type.getSubOptions;
|
||||||
getSubModules = type.getSubModules;
|
getSubModules = type.getSubModules;
|
||||||
substSubModules = m: uniq (type.substSubModules m);
|
substSubModules = m: uniq (type.substSubModules m);
|
||||||
functor = (defaultFunctor name) // { wrapped = type; };
|
functor = elemTypeFunctor name { elemType = type; } // {
|
||||||
|
type = payload: types.unique { inherit message; } payload.elemType;
|
||||||
|
};
|
||||||
nestedTypes.elemType = type;
|
nestedTypes.elemType = type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -873,7 +876,9 @@ rec {
|
||||||
getSubOptions = elemType.getSubOptions;
|
getSubOptions = elemType.getSubOptions;
|
||||||
getSubModules = elemType.getSubModules;
|
getSubModules = elemType.getSubModules;
|
||||||
substSubModules = m: nullOr (elemType.substSubModules m);
|
substSubModules = m: nullOr (elemType.substSubModules m);
|
||||||
functor = (defaultFunctor name) // { wrapped = elemType; };
|
functor = (elemTypeFunctor name { inherit elemType; }) // {
|
||||||
|
type = payload: types.nullOr payload.elemType;
|
||||||
|
};
|
||||||
nestedTypes.elemType = elemType;
|
nestedTypes.elemType = elemType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -892,7 +897,9 @@ rec {
|
||||||
getSubOptions = prefix: elemType.getSubOptions (prefix ++ [ "<function body>" ]);
|
getSubOptions = prefix: elemType.getSubOptions (prefix ++ [ "<function body>" ]);
|
||||||
getSubModules = elemType.getSubModules;
|
getSubModules = elemType.getSubModules;
|
||||||
substSubModules = m: functionTo (elemType.substSubModules m);
|
substSubModules = m: functionTo (elemType.substSubModules m);
|
||||||
functor = (defaultFunctor "functionTo") // { wrapped = elemType; };
|
functor = (elemTypeFunctor "functionTo" { inherit elemType; }) // {
|
||||||
|
type = payload: types.functionTo payload.elemType;
|
||||||
|
};
|
||||||
nestedTypes.elemType = elemType;
|
nestedTypes.elemType = elemType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1166,7 +1173,9 @@ rec {
|
||||||
getSubModules = finalType.getSubModules;
|
getSubModules = finalType.getSubModules;
|
||||||
substSubModules = m: coercedTo coercedType coerceFunc (finalType.substSubModules m);
|
substSubModules = m: coercedTo coercedType coerceFunc (finalType.substSubModules m);
|
||||||
typeMerge = t: null;
|
typeMerge = t: null;
|
||||||
functor = (defaultFunctor name) // { wrapped = finalType; };
|
functor = (defaultFunctor name) // {
|
||||||
|
wrappedDeprecationMessage = makeWrappedDeprecationMessage { elemType = finalType; };
|
||||||
|
};
|
||||||
nestedTypes.coercedType = coercedType;
|
nestedTypes.coercedType = coercedType;
|
||||||
nestedTypes.finalType = finalType;
|
nestedTypes.finalType = finalType;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue