|
224 | 224 | ); |
225 | 225 | }; |
226 | 226 | specs = lib.mkOption { |
227 | | - type = |
228 | | - wlib.dag.dagWith |
229 | | - { |
230 | | - modules = [ config.specMods ]; |
231 | | - specialArgs = { |
232 | | - parentSpec = null; |
233 | | - parentOpts = null; |
234 | | - }; |
235 | | - dataTypeFn = |
236 | | - let |
237 | | - inherit (config) specMods; |
238 | | - in |
239 | | - elemType: |
240 | | - { |
241 | | - config, |
242 | | - options, |
243 | | - ... |
244 | | - }: |
245 | | - types.nullOr ( |
246 | | - types.either wlib.types.stringable ( |
247 | | - wlib.dag.dalWith { |
248 | | - modules = [ specMods ]; |
249 | | - specialArgs = { |
250 | | - parentSpec = config; |
251 | | - parentOpts = options; |
252 | | - }; |
253 | | - } (types.nullOr wlib.types.stringable) |
254 | | - ) |
255 | | - ); |
256 | | - } |
257 | | - ( |
258 | | - types.nullOr ( |
259 | | - types.either wlib.types.stringable ( |
260 | | - wlib.dag.dalWith { |
261 | | - modules = [ config.specMods ]; |
262 | | - specialArgs = { |
263 | | - parentSpec = null; |
264 | | - parentOpts = null; |
| 227 | + type = lib.types.attrsOf ( |
| 228 | + wlib.types.specWith { |
| 229 | + specialArgs = { |
| 230 | + parentSpec = null; |
| 231 | + parentOpts = null; |
| 232 | + parentName = null; |
| 233 | + }; |
| 234 | + modules = |
| 235 | + let |
| 236 | + inherit (config) specMods; |
| 237 | + in |
| 238 | + [ |
| 239 | + ( |
| 240 | + { |
| 241 | + config, |
| 242 | + options, |
| 243 | + name, |
| 244 | + ... |
| 245 | + }: |
| 246 | + { |
| 247 | + options.data = lib.mkOption { |
| 248 | + description = '' |
| 249 | + A list of specs or plugins, or a plugin, or null |
| 250 | +
|
| 251 | + A plugin can be a derivation, |
| 252 | + or an impure string path for testing! |
| 253 | + ''; |
| 254 | + type = types.nullOr ( |
| 255 | + lib.types.either wlib.types.stringable ( |
| 256 | + types.listOf ( |
| 257 | + wlib.types.specWith { |
| 258 | + specialArgs = { |
| 259 | + parentSpec = config; |
| 260 | + parentOpts = options; |
| 261 | + parentName = name; |
| 262 | + }; |
| 263 | + modules = [ |
| 264 | + { |
| 265 | + options.data = lib.mkOption { |
| 266 | + type = types.nullOr wlib.types.stringable; |
| 267 | + description = '' |
| 268 | + A plugin (or null) |
| 269 | +
|
| 270 | + A plugin can be a derivation, |
| 271 | + or an impure string path for testing! |
| 272 | + ''; |
| 273 | + }; |
| 274 | + } |
| 275 | + specMods |
| 276 | + ]; |
| 277 | + } |
| 278 | + ) |
| 279 | + ) |
| 280 | + ); |
265 | 281 | }; |
266 | | - } (types.nullOr wlib.types.stringable) |
| 282 | + } |
267 | 283 | ) |
268 | | - ) |
269 | | - ); |
| 284 | + specMods |
| 285 | + ]; |
| 286 | + } |
| 287 | + ); |
270 | 288 | default = { }; |
271 | 289 | description = builtins.readFile ./spec_desc.md; |
272 | 290 | }; |
|
384 | 402 | specMods = lib.mkOption { |
385 | 403 | default = { }; |
386 | 404 | description = '' |
387 | | - extra module for the plugin spec submodules (provided to `wlib.dag.dagWith` or `wlib.dag.dalWith`) |
| 405 | + extra module for the plugin spec submodules (provided to `wlib.types.specWith`) |
| 406 | +
|
| 407 | + These modules recieve some `specialArgs`! |
388 | 408 |
|
389 | | - These modules recieve `parentSpec` and `parentOpts` via `specialArgs` |
| 409 | + `parentSpec`, `parentOpts`, and `parentName` |
390 | 410 |
|
391 | | - If the spec is a parent, this will be `null` |
| 411 | + If the spec is a parent, these will be `null` |
392 | 412 |
|
393 | | - If the spec is a child, it will be the `config` argument of the parent spec. |
| 413 | + If the spec is a child, `parentSpec` will be the `config` argument of the parent spec. |
| 414 | +
|
| 415 | + Likewise, `parentOpts` will be the `options` argument and `parentName` the name argument. |
394 | 416 |
|
395 | 417 | You may use this to change defaults and allow parent overrides of the default to propagate default values to child specs. |
396 | 418 |
|
397 | 419 | ```nix |
398 | | - config.specMods = { parentSpec, ... }: { |
| 420 | + config.specMods = { |
| 421 | + parentSpec, config, parentOpts, options, parentName, ... |
| 422 | + }: { |
399 | 423 | config.collateGrammars = lib.mkDefault (parentSpec.collateGrammars or false); |
400 | 424 | }; |
401 | 425 | ``` |
402 | 426 |
|
403 | | - You could also declare entirely new items for the spec to process in `specMaps` and `specCollect`. |
| 427 | + You could also declare entirely new items for the spec to process with `specMaps` and `specCollect`. |
404 | 428 | ''; |
405 | 429 | type = types.deferredModuleWith { |
406 | 430 | staticModules = [ |
|
410 | 434 | options, |
411 | 435 | parentSpec ? null, |
412 | 436 | parentOpts ? null, |
| 437 | + parentName ? null, |
| 438 | + name, |
413 | 439 | ... |
414 | 440 | }: |
415 | 441 | { |
416 | 442 | # NOTE: for docgen |
| 443 | + config._module.args.parentName = lib.mkOptionDefault null; |
417 | 444 | config._module.args.parentSpec = lib.mkOptionDefault null; |
418 | 445 | config._module.args.parentOpts = lib.mkOptionDefault null; |
419 | 446 | options = { |
|
426 | 453 | If this is in the inner list, then the default value from the parent spec will be used. |
427 | 454 | ''; |
428 | 455 | }; |
| 456 | + name = lib.mkOption { |
| 457 | + type = types.nullOr types.str; |
| 458 | + default = if parentName != null then null else name; |
| 459 | + description = '' |
| 460 | + The name of this spec in the DAG of specs |
| 461 | +
|
| 462 | + May differ from the name of the plugin, |
| 463 | + which is controlled by the `pname` option. |
| 464 | + ''; |
| 465 | + }; |
| 466 | + before = lib.mkOption { |
| 467 | + type = with types; listOf str; |
| 468 | + default = [ ]; |
| 469 | + description = '' |
| 470 | + Sort this spec before the list of spec names |
| 471 | + ''; |
| 472 | + }; |
| 473 | + after = lib.mkOption { |
| 474 | + type = types.listOf types.str; |
| 475 | + default = [ ]; |
| 476 | + description = '' |
| 477 | + Sort this spec after the list of spec names |
| 478 | + ''; |
| 479 | + }; |
429 | 480 | pname = lib.mkOption { |
430 | 481 | type = types.nullOr types.str; |
431 | 482 | default = null; |
|
0 commit comments