Skip to content

Commit 062945b

Browse files
authored
lib.types: chore use consistent payload form (NixOS#363565)
2 parents c7035f6 + 1d6a2c2 commit 062945b

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

lib/types.nix

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,10 @@ rec {
475475
check = isString;
476476
merge = loc: defs: concatStringsSep sep (getValues defs);
477477
functor = (defaultFunctor name) // {
478-
payload = sep;
479-
binOp = sepLhs: sepRhs:
480-
if sepLhs == sepRhs then sepLhs
478+
payload = { inherit sep; };
479+
type = payload: types.separatedString payload.sep;
480+
binOp = lhs: rhs:
481+
if lhs.sep == rhs.sep then { inherit (lhs) sep; }
481482
else null;
482483
};
483484
};
@@ -1024,7 +1025,11 @@ rec {
10241025
else "conjunction";
10251026
check = flip elem values;
10261027
merge = mergeEqualOption;
1027-
functor = (defaultFunctor name) // { payload = values; binOp = a: b: unique (a ++ b); };
1028+
functor = (defaultFunctor name) // {
1029+
payload = { inherit values; };
1030+
type = payload: types.enum payload.values;
1031+
binOp = a: b: { values = unique (a.values ++ b.values); };
1032+
};
10281033
};
10291034

10301035
# Either value of type `t1` or `t2`.

nixos/doc/manual/redirects.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,6 +1844,12 @@
18441844
"sec-release-25.05-notable-changes": [
18451845
"release-notes.html#sec-release-25.05-notable-changes"
18461846
],
1847+
"sec-release-25.05-lib": [
1848+
"release-notes.html#sec-release-25.05-lib"
1849+
],
1850+
"sec-release-25.05-lib-breaking": [
1851+
"release-notes.html#sec-release-25.05-lib-breaking"
1852+
],
18471853
"sec-release-24.11": [
18481854
"release-notes.html#sec-release-24.11"
18491855
],

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,11 @@
118118
- `bind.cacheNetworks` now only controls access for recursive queries, where it previously controlled access for all queries.
119119

120120
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
121+
122+
## Nixpkgs Library {#sec-release-25.05-lib}
123+
124+
### Breaking changes {#sec-release-25.05-lib-breaking}
125+
126+
- Structure of the `functor` of some types has changed. `functor` is an implementation detail and should not be relied upon. If you did rely on it let us know in this [PR](https://github.com/NixOS/nixpkgs/pull/363565).
127+
- [`lib.types.enum`](https://nixos.org/manual/nixos/unstable/#sec-option-types-basic): Previously the `functor.payload` was the list of enum values directly. Now it is an attribute set containing the values in the `values` attribute.
128+
- [`lib.types.separatedString`](https://nixos.org/manual/nixos/unstable/#sec-option-types-string): Previously the `functor.payload` was the seperator directly. Now it is an attribute set containing the seperator in the `sep` attribute.

0 commit comments

Comments
 (0)