|
87 | 87 | mkDerivation { |
88 | 88 | name = "pre-commit-run"; |
89 | 89 | src = cfg.rootSrc; |
90 | | - buildInputs = [ cfg.gitPackage ]; |
| 90 | + buildInputs = [ cfg.gitPackage cfg.package ]; |
91 | 91 | nativeBuildInputs = enabledExtraPackages |
92 | 92 | ++ lib.optional (config.settings.rust.check.cargoDeps != null) cargoSetupHook; |
93 | 93 | cargoDeps = config.settings.rust.check.cargoDeps; |
94 | 94 | buildPhase = '' |
95 | 95 | set +e |
96 | 96 | # Set HOME to a temporary directory for pre-commit to create its cache files in. |
97 | 97 | HOME=$(mktemp -d) |
98 | | - ln -fs ${configFile} .pre-commit-config.yaml |
| 98 | + ln -fs ${cfg.configFile} .pre-commit-config.yaml |
99 | 99 | git init -q |
100 | 100 | git add . |
101 | 101 | git config --global user.email "you@example.com" |
102 | 102 | git config --global user.name "Your Name" |
103 | 103 | git commit -m "init" -q |
104 | | - if [[ ${toString (compare install_stages [ "manual" ])} -eq 0 ]] |
| 104 | + if [[ ${toString (compare cfg.installStages [ "manual" ])} -eq 0 ]] |
105 | 105 | then |
106 | 106 | echo "Running: $ pre-commit run --hook-stage manual --all-files" |
107 | | - ${cfg.package}/bin/pre-commit run --hook-stage manual --all-files |
| 107 | + pre-commit run --hook-stage manual --all-files |
108 | 108 | else |
109 | 109 | echo "Running: $ pre-commit run --all-files" |
110 | | - ${cfg.package}/bin/pre-commit run --all-files |
| 110 | + pre-commit run --all-files |
111 | 111 | fi |
112 | 112 | exitcode=$? |
113 | 113 | git --no-pager diff --color |
|
254 | 254 | A derivation that tests whether the pre-commit hooks run cleanly on |
255 | 255 | the entire project. |
256 | 256 | ''; |
257 | | - readOnly = true; |
| 257 | + readOnly = false; |
258 | 258 | default = run; |
259 | 259 | defaultText = lib.literalExpression "<derivation>"; |
260 | 260 | }; |
|
269 | 269 | readOnly = true; |
270 | 270 | }; |
271 | 271 |
|
| 272 | + configFile = |
| 273 | + mkOption { |
| 274 | + type = types.package; |
| 275 | + description = |
| 276 | + '' |
| 277 | + The pre-commit configuration file. |
| 278 | + ''; |
| 279 | + readOnly = true; |
| 280 | + default = configFile; |
| 281 | + defaultText = "<derivation>"; |
| 282 | + }; |
| 283 | + |
272 | 284 | src = |
273 | 285 | lib.mkOption { |
274 | 286 | description = '' |
|
363 | 375 | display a warning message when a renamed option is used. |
364 | 376 | ''; |
365 | 377 | }; |
| 378 | + |
| 379 | + installStages = lib.mkOption { |
| 380 | + type = types.listOf (types.either types.str types.anything); |
| 381 | + description = '' |
| 382 | + The stages to install the hooks to. |
| 383 | + ''; |
| 384 | + default = install_stages; |
| 385 | + readOnly = true; |
| 386 | + }; |
366 | 387 | }; |
367 | 388 |
|
368 | 389 | config = |
|
0 commit comments