|
36 | 36 | (builtins.attrValues enabledHooks); |
37 | 37 | in |
38 | 38 | if sortedHooks ? result then |
39 | | - builtins.map (value: value.raw) sortedHooks.result |
| 39 | + sortedHooks.result |
40 | 40 | else |
41 | 41 | let |
42 | 42 | getIds = builtins.map (value: value.id); |
|
61 | 61 |
|
62 | 62 | ${prettyPrintCycle { indent = " "; } sortedHooks.cycle} |
63 | 63 | ''; |
| 64 | + _prekBuiltins = |
| 65 | + if usingPrek then |
| 66 | + builtins.filter (s: s != "") (builtins.split "\n" ( |
| 67 | + builtins.readFile ( |
| 68 | + pkgs.runCommand "prek-builtins.txt" |
| 69 | + { |
| 70 | + buildInputs = [ cfg.package ]; |
| 71 | + PREK_HOME = "/tmp/"; # This is to avoid prek trying to create ~/.cache/prek/ |
| 72 | + } |
| 73 | + ''${lib.getExe cfg.package} util list-builtins > $out'' |
| 74 | + ) |
| 75 | + )) |
| 76 | + else |
| 77 | + [ ]; |
| 78 | + |
| 79 | + _is_builtin = |
| 80 | + { |
| 81 | + package, |
| 82 | + name, |
| 83 | + ... |
| 84 | + }: |
| 85 | + usingPrek && (package.pname == "pre-commit-hooks") && (builtins.elem name _prekBuiltins); |
| 86 | + |
| 87 | + _partitioned = builtins.partition _is_builtin processedHooks; |
| 88 | + |
| 89 | + builtinHooks = builtins.map (value: builtins.removeAttrs value.raw [ "entry" ]) _partitioned.right; |
| 90 | + localHooks = builtins.map (value: value.raw) _partitioned.wrong; |
64 | 91 |
|
65 | 92 | configFile = |
66 | 93 | performAssertions ( |
|
439 | 466 | message = "The `purty` hook has been removed because the project is unmaintained. Consider using `purs-tidy` instead."; |
440 | 467 | } |
441 | 468 | { |
442 | | - assertion = usingPrek || (lib.all (hook: !(hook ? priority)) processedHooks); |
| 469 | + assertion = usingPrek || (lib.all (hook: !(hook ? priority)) localHooks); |
443 | 470 | message = |
444 | 471 | let |
445 | | - hooksWithPriority = lib.filter (hook: hook ? priority) processedHooks; |
| 472 | + hooksWithPriority = lib.filter (hook: hook ? priority) localHooks; |
446 | 473 | hookNames = lib.concatMapStringsSep ", " (hook: hook.id) hooksWithPriority; |
447 | 474 | in |
448 | 475 | '' |
|
455 | 482 |
|
456 | 483 | rawConfig = |
457 | 484 | { |
458 | | - repos = |
459 | | - [ |
460 | | - { |
461 | | - repo = "local"; |
462 | | - hooks = processedHooks; |
463 | | - } |
464 | | - ]; |
| 485 | + repos = [ |
| 486 | + { |
| 487 | + repo = "local"; |
| 488 | + hooks = localHooks; |
| 489 | + } |
| 490 | + ] |
| 491 | + ++ lib.optionals (builtinHooks != [ ]) [ |
| 492 | + { |
| 493 | + repo = "builtin"; |
| 494 | + hooks = builtinHooks; |
| 495 | + } |
| 496 | + ]; |
465 | 497 | } // lib.optionalAttrs (cfg.excludes != [ ]) { |
466 | 498 | exclude = mergeExcludes cfg.excludes; |
467 | 499 | } // lib.optionalAttrs (cfg.default_stages != [ ]) { |
|
0 commit comments