|
424 | 424 | else
|
425 | 425 | m: m;
|
426 | 426 |
|
| 427 | + # isDisabled :: String -> [ { disabled, file } ] -> StructuredModule -> bool |
| 428 | + # |
| 429 | + # Figures out whether a `StructuredModule` is disabled. |
| 430 | + isDisabled = |
| 431 | + modulesPath: disabledList: |
| 432 | + let |
| 433 | + moduleKey = |
| 434 | + file: m: |
| 435 | + if isString m then |
| 436 | + if substring 0 1 m == "/" then m else toString modulesPath + "/" + m |
| 437 | + |
| 438 | + else if isConvertibleWithToString m then |
| 439 | + if m ? key && m.key != toString m then |
| 440 | + throw "Module `${file}` contains a disabledModules item that is an attribute set that can be converted to a string (${toString m}) but also has a `.key` attribute (${m.key}) with a different value. This makes it ambiguous which module should be disabled." |
| 441 | + else |
| 442 | + toString m |
| 443 | + |
| 444 | + else if m ? key then |
| 445 | + m.key |
| 446 | + |
| 447 | + else if isAttrs m then |
| 448 | + throw "Module `${file}` contains a disabledModules item that is an attribute set, presumably a module, that does not have a `key` attribute. This means that the module system doesn't have any means to identify the module that should be disabled. Make sure that you've put the correct value in disabledModules: a string path relative to modulesPath, a path value, or an attribute set with a `key` attribute." |
| 449 | + else |
| 450 | + throw "Each disabledModules item must be a path, string, or a attribute set with a key attribute, or a value supported by toString. However, one of the disabledModules items in `${toString file}` is none of that, but is of type ${typeOf m}."; |
| 451 | + |
| 452 | + disabledKeys = concatMap ({ file, disabled }: map (moduleKey file) disabled) disabledList; |
| 453 | + in |
| 454 | + structuredModule: elem structuredModule.key disabledKeys; |
| 455 | + |
427 | 456 | /**
|
428 |
| - Collects all modules recursively into the form |
| 457 | + Collects all modules recursively into a `[ StructuredModule ]` and a list of disabled modules: |
429 | 458 |
|
430 | 459 | {
|
431 | 460 | disabled = [ <list of disabled modules> ];
|
|
493 | 522 | modulesPath:
|
494 | 523 | { disabled, modules }:
|
495 | 524 | let
|
496 |
| - moduleKey = |
497 |
| - file: m: |
498 |
| - if isString m then |
499 |
| - if substring 0 1 m == "/" then m else toString modulesPath + "/" + m |
500 |
| - |
501 |
| - else if isConvertibleWithToString m then |
502 |
| - if m ? key && m.key != toString m then |
503 |
| - throw "Module `${file}` contains a disabledModules item that is an attribute set that can be converted to a string (${toString m}) but also has a `.key` attribute (${m.key}) with a different value. This makes it ambiguous which module should be disabled." |
504 |
| - else |
505 |
| - toString m |
506 |
| - |
507 |
| - else if m ? key then |
508 |
| - m.key |
509 |
| - |
510 |
| - else if isAttrs m then |
511 |
| - throw "Module `${file}` contains a disabledModules item that is an attribute set, presumably a module, that does not have a `key` attribute. This means that the module system doesn't have any means to identify the module that should be disabled. Make sure that you've put the correct value in disabledModules: a string path relative to modulesPath, a path value, or an attribute set with a `key` attribute." |
512 |
| - else |
513 |
| - throw "Each disabledModules item must be a path, string, or a attribute set with a key attribute, or a value supported by toString. However, one of the disabledModules items in `${toString file}` is none of that, but is of type ${typeOf m}."; |
514 |
| - |
515 |
| - disabledKeys = concatMap ({ file, disabled }: map (moduleKey file) disabled) disabled; |
516 |
| - keyFilter = filter (attrs: !elem attrs.key disabledKeys); |
| 525 | + keyFilter = filter (attrs: !isDisabled modulesPath disabled attrs); |
517 | 526 | in
|
518 | 527 | map (attrs: attrs.module) (genericClosure {
|
519 | 528 | startSet = keyFilter modules;
|
|
0 commit comments