|
6 | 6 | ... |
7 | 7 | }: |
8 | 8 | let |
9 | | - # deprecates `{ _attrs = ??; ... }` and `null` to `_: { props = ??; content = ...; }` and `_: {}` respectively |
10 | | - # remove on June 1, 2026 |
11 | | - convertAndWarn = |
12 | | - let |
13 | | - endOfWarningMessage = "\n" + '' |
14 | | - Warning will be removed on June 1, 2026, |
15 | | - but you can remove this deprecation layer ahead of time |
16 | | - after fixing your configuration by setting `v2-settings = true`. |
17 | | - ''; |
18 | | - recurse = |
19 | | - path: v: |
20 | | - if builtins.isAttrs v then |
21 | | - let |
22 | | - hasAttrs = v ? _attrs; |
23 | | - rest = lib.removeAttrs v [ "_attrs" ]; |
24 | | - processedRest = lib.mapAttrs (n: val: recurse (path ++ [ n ]) val) rest; |
25 | | - in |
26 | | - if hasAttrs then |
27 | | - lib.warn |
28 | | - ( |
29 | | - "wrapperModules.niri: Deprecated `{ _attrs = ??; ... }` at ${lib.concatStringsSep "." path}. Use `_: { props = ??; content = ...; }` instead." |
30 | | - + endOfWarningMessage |
31 | | - ) |
32 | | - (_: { |
33 | | - props = recurse (path ++ [ "_attrs" ]) v._attrs; |
34 | | - content = processedRest; |
35 | | - }) |
36 | | - else |
37 | | - processedRest |
38 | | - else if builtins.isList v && builtins.all builtins.isAttrs v then |
39 | | - map (i: recurse (path ++ [ "[${toString i}]" ]) i) v |
40 | | - else if v == null then |
41 | | - lib.warn ( |
42 | | - "wrapperModules.niri: Deprecated `null` at ${lib.concatStringsSep "." path}. Use `_: {}` instead." |
43 | | - + endOfWarningMessage |
44 | | - ) (_: { }) |
45 | | - else |
46 | | - v; |
47 | | - in |
48 | | - if config.v2-settings then v: v else v: recurse [ ] v; |
49 | | - |
50 | 9 | mkRule = |
51 | 10 | # "window-rules" "layer-rules" |
52 | 11 | node: r: |
|
106 | 65 |
|
107 | 66 | options = { |
108 | 67 | v2-settings = lib.mkOption { |
109 | | - type = lib.types.bool; |
110 | | - default = false; |
111 | | - description = '' |
112 | | - If you have converted your configuration from the old version of the niri module's kdl translation to the new one already, |
113 | | - you may set this to true to stop it from checking for the old version. |
114 | | -
|
115 | | - On July 1, 2026, when that version is removed, this option will warn that it no longer has any effect. |
116 | | -
|
117 | | - The change was as follows: |
118 | | -
|
119 | | - For doing |
120 | | -
|
121 | | - ```kdl |
122 | | - node "some" "args" "y"=100 { |
123 | | - } |
124 | | - ``` |
125 | | -
|
126 | | - `{ _attrs = ??; ... }` was changed to `_: { props = ??; content = ...; }` |
127 | | -
|
128 | | - And in the context of declaring a node which is just a name with no children or props: |
129 | | -
|
130 | | - `null` was changed to `_: {}` because `null` is an actual value you may want to provide. |
131 | | -
|
132 | | - Functions were the only type of value we could not translate. |
133 | | -
|
134 | | - The argument to the function is provided by calling the function with `lib.fix`. |
135 | | - ''; |
| 68 | + type = lib.types.nullOr lib.types.bool; |
| 69 | + default = null; |
| 70 | + internal = true; |
| 71 | + apply = |
| 72 | + x: |
| 73 | + lib.warnIf (x != null) '' |
| 74 | + nix-wrapper-modules niri v2-settings option no longer has any effect! |
| 75 | + `v2-settings == true` is now the default behaviour, and the deprecations for v1 have been removed. |
| 76 | + You should remove `v2-settings = true` from your config, this option will be removed in a future version. |
| 77 | + ''; |
136 | 78 | }; |
137 | 79 | settings = lib.mkOption { |
138 | 80 | description = '' |
|
150 | 92 | default = { }; |
151 | 93 | type = wlib.types.attrsRecursive; |
152 | 94 | description = "Bindings of niri"; |
153 | | - apply = convertAndWarn; |
154 | 95 | example = lib.literalMD '' |
155 | 96 | ```nix |
156 | 97 | binds = { |
|
170 | 111 | default = { }; |
171 | 112 | type = wlib.types.attrsRecursive; |
172 | 113 | description = "Layout definitions"; |
173 | | - apply = convertAndWarn; |
174 | 114 | example = lib.literalMD '' |
175 | 115 | ```nix |
176 | 116 | layout = { |
|
218 | 158 | default = [ ]; |
219 | 159 | type = lib.types.listOf lib.types.attrs; |
220 | 160 | description = "List of window rules"; |
221 | | - apply = convertAndWarn; |
222 | 161 | example = [ |
223 | 162 | { |
224 | 163 | matches = [ { app-id = ".*"; } ]; |
|
234 | 173 | default = [ ]; |
235 | 174 | type = lib.types.listOf lib.types.attrs; |
236 | 175 | description = "List of layer rules"; |
237 | | - apply = convertAndWarn; |
238 | 176 | example = [ |
239 | 177 | { |
240 | 178 | matches = [ { namespace = "^notifications$"; } ]; |
|
247 | 185 | default = { }; |
248 | 186 | type = lib.types.attrsOf (lib.types.nullOr lib.types.anything); |
249 | 187 | description = "Named workspace definitions"; |
250 | | - apply = convertAndWarn; |
251 | 188 | example = lib.literalMD '' |
252 | 189 | ```nix |
253 | 190 | workspaces = { |
|
263 | 200 | default = { }; |
264 | 201 | type = wlib.types.attrsRecursive; |
265 | 202 | description = "Output configuration"; |
266 | | - apply = convertAndWarn; |
267 | 203 | example = lib.literalMD '' |
268 | 204 | ```nix |
269 | 205 | { |
|
401 | 337 | (attrAsArg "workspace" config.settings.workspaces) |
402 | 338 | (attrAsArg "output" config.settings.outputs) |
403 | 339 | [ |
404 | | - (convertAndWarn ( |
405 | | - lib.removeAttrs config.settings [ |
406 | | - "window-rules" |
407 | | - "layer-rules" |
408 | | - "spawn-at-startup" |
409 | | - "spawn-sh-at-startup" |
410 | | - "workspaces" |
411 | | - "outputs" |
412 | | - "extraConfig" |
413 | | - ] |
414 | | - )) |
| 340 | + (lib.removeAttrs config.settings [ |
| 341 | + "window-rules" |
| 342 | + "layer-rules" |
| 343 | + "spawn-at-startup" |
| 344 | + "spawn-sh-at-startup" |
| 345 | + "workspaces" |
| 346 | + "outputs" |
| 347 | + "extraConfig" |
| 348 | + ]) |
415 | 349 | ] |
416 | 350 | config.extraSettings |
417 | 351 | ]; |
|
0 commit comments