Skip to content

Commit d3f6bef

Browse files
authored
lib/types: types.either deprecate functor.wrapped in favor of functor payload.elemType (#375090)
2 parents 19f68bd + 484a047 commit d3f6bef

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

doc/release-notes/rl-2505.section.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
- `lib.types.nullOr`
8080
- `lib.types.functionTo`
8181
- `lib.types.coercedTo`
82+
- `lib.types.either`
8283

8384
- 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.
8485

lib/tests/modules.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,14 @@ NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribu
439439
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
440440
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
441441
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
442+
# either
443+
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
444+
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
445+
446+
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
447+
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
448+
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
449+
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
442450

443451
# Even with multiple assignments, a type error should be thrown if any of them aren't valid
444452
checkConfigError 'A definition for option .* is not of type .*' \

lib/tests/modules/deprecated-wrapped.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ let
1010
nullOr
1111
functionTo
1212
coercedTo
13+
either
1314
;
1415
in
1516
{
@@ -56,6 +57,12 @@ in
5657
options.coercedTo = mkOption {
5758
type = coercedTo (listOf types.str) lib.id (listOf types.str);
5859
};
60+
options.either = mkOption {
61+
type = either (listOf types.str) (listOf types.str);
62+
};
63+
options.mergedEither = mkOption {
64+
type = either (listOf types.str) (listOf types.str);
65+
};
5966
}
6067
)
6168
# Module B
@@ -77,6 +84,9 @@ in
7784
options.mergedFunctionTo = mkOption {
7885
type = functionTo (listOf types.str);
7986
};
87+
options.mergedEither = mkOption {
88+
type = either (listOf types.str) (listOf types.str);
89+
};
8090
}
8191
)
8292
];

lib/types.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,13 +1134,13 @@ rec {
11341134
then t2.merge loc defs
11351135
else mergeOneOption loc defs;
11361136
typeMerge = f':
1137-
let mt1 = t1.typeMerge (elemAt f'.wrapped 0).functor;
1138-
mt2 = t2.typeMerge (elemAt f'.wrapped 1).functor;
1137+
let mt1 = t1.typeMerge (elemAt f'.payload.elemType 0).functor;
1138+
mt2 = t2.typeMerge (elemAt f'.payload.elemType 1).functor;
11391139
in
11401140
if (name == f'.name) && (mt1 != null) && (mt2 != null)
11411141
then functor.type mt1 mt2
11421142
else null;
1143-
functor = (defaultFunctor name) // { wrapped = [ t1 t2 ]; };
1143+
functor = elemTypeFunctor name { elemType = [ t1 t2 ]; };
11441144
nestedTypes.left = t1;
11451145
nestedTypes.right = t2;
11461146
};

0 commit comments

Comments
 (0)