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

This commit is contained in:
Johannes Kirschbauer 2025-01-19 16:39:44 +01:00
parent 987a096334
commit 484a0477d8
No known key found for this signature in database
4 changed files with 22 additions and 3 deletions

View file

@ -79,6 +79,7 @@
- `lib.types.nullOr` - `lib.types.nullOr`
- `lib.types.functionTo` - `lib.types.functionTo`
- `lib.types.coercedTo` - `lib.types.coercedTo`
- `lib.types.either`
- 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.

View file

@ -439,6 +439,14 @@ 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.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.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.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 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
# either
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.either.type.functor.wrapped ./deprecated-wrapped.nix
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedEither.type.functor.wrapped ./deprecated-wrapped.nix
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.either.type.nestedTypes.left.functor.wrapped ./deprecated-wrapped.nix
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.either.type.nestedTypes.right.functor.wrapped ./deprecated-wrapped.nix
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedEither.type.nestedTypes.left.functor.wrapped ./deprecated-wrapped.nix
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedEither.type.nestedTypes.right.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 .*' \

View file

@ -10,6 +10,7 @@ let
nullOr nullOr
functionTo functionTo
coercedTo coercedTo
either
; ;
in in
{ {
@ -56,6 +57,12 @@ in
options.coercedTo = mkOption { options.coercedTo = mkOption {
type = coercedTo (listOf types.str) lib.id (listOf types.str); type = coercedTo (listOf types.str) lib.id (listOf types.str);
}; };
options.either = mkOption {
type = either (listOf types.str) (listOf types.str);
};
options.mergedEither = mkOption {
type = either (listOf types.str) (listOf types.str);
};
} }
) )
# Module B # Module B
@ -77,6 +84,9 @@ in
options.mergedFunctionTo = mkOption { options.mergedFunctionTo = mkOption {
type = functionTo (listOf types.str); type = functionTo (listOf types.str);
}; };
options.mergedEither = mkOption {
type = either (listOf types.str) (listOf types.str);
};
} }
) )
]; ];

View file

@ -1134,13 +1134,13 @@ rec {
then t2.merge loc defs then t2.merge loc defs
else mergeOneOption loc defs; else mergeOneOption loc defs;
typeMerge = f': typeMerge = f':
let mt1 = t1.typeMerge (elemAt f'.wrapped 0).functor; let mt1 = t1.typeMerge (elemAt f'.payload.elemType 0).functor;
mt2 = t2.typeMerge (elemAt f'.wrapped 1).functor; mt2 = t2.typeMerge (elemAt f'.payload.elemType 1).functor;
in in
if (name == f'.name) && (mt1 != null) && (mt2 != null) if (name == f'.name) && (mt1 != null) && (mt2 != null)
then functor.type mt1 mt2 then functor.type mt1 mt2
else null; else null;
functor = (defaultFunctor name) // { wrapped = [ t1 t2 ]; }; functor = elemTypeFunctor name { elemType = [ t1 t2 ]; };
nestedTypes.left = t1; nestedTypes.left = t1;
nestedTypes.right = t2; nestedTypes.right = t2;
}; };