|
633 | 633 | default = null;
|
634 | 634 | };
|
635 | 635 | };
|
| 636 | + no-commit-to-branch = |
| 637 | + { |
| 638 | + branch = |
| 639 | + mkOption { |
| 640 | + description = lib.mdDoc "Branches to disallow commits to."; |
| 641 | + type = types.listOf types.str; |
| 642 | + default = [ "main" ]; |
| 643 | + example = [ "main" "master" ]; |
| 644 | + }; |
| 645 | + pattern = |
| 646 | + mkOption { |
| 647 | + description = lib.mdDoc "RegEx patterns for branch names to disallow commits to."; |
| 648 | + type = types.listOf types.str; |
| 649 | + default = [ ]; |
| 650 | + example = [ "ma.*" ]; |
| 651 | + }; |
| 652 | + }; |
636 | 653 | ormolu =
|
637 | 654 | {
|
638 | 655 | defaultExtensions =
|
@@ -1057,6 +1074,21 @@ in
|
1057 | 1074 | example = [ "flake.nix" "_*" ];
|
1058 | 1075 | };
|
1059 | 1076 | };
|
| 1077 | + sort-file-contents = |
| 1078 | + { |
| 1079 | + ignore-case = |
| 1080 | + mkOption { |
| 1081 | + type = types.bool; |
| 1082 | + description = lib.mdDoc "Fold lower case to upper case characters."; |
| 1083 | + default = false; |
| 1084 | + }; |
| 1085 | + unique = |
| 1086 | + mkOption { |
| 1087 | + type = types.bool; |
| 1088 | + description = lib.mdDoc "Ensure each line is unique."; |
| 1089 | + default = false; |
| 1090 | + }; |
| 1091 | + }; |
1060 | 1092 | treefmt =
|
1061 | 1093 | {
|
1062 | 1094 | package = mkOption {
|
@@ -1356,6 +1388,106 @@ in
|
1356 | 1388 | "The version of nixpkgs used by pre-commit-hooks.nix must have `checkmake` in version at least 0.2.2 for it to work on non-Linux systems."
|
1357 | 1389 | "${tools.checkmake}/bin/checkmake";
|
1358 | 1390 | };
|
| 1391 | + check-added-large-files = |
| 1392 | + { |
| 1393 | + name = "check-added-large-files"; |
| 1394 | + description = "Prevent very large files to be committed (e.g. binaries)."; |
| 1395 | + entry = "${tools.pre-commit-hooks}/bin/check-added-large-files"; |
| 1396 | + stages = [ "commit" "push" "manual" ]; |
| 1397 | + }; |
| 1398 | + check-builtin-literals = |
| 1399 | + { |
| 1400 | + name = "check-builtin-literals"; |
| 1401 | + description = "Require literal syntax when initializing empty or zero builtin types in Python."; |
| 1402 | + entry = "${tools.pre-commit-hooks}/bin/check-builtin-literals"; |
| 1403 | + types = [ "python" ]; |
| 1404 | + }; |
| 1405 | + check-case-conflicts = |
| 1406 | + { |
| 1407 | + name = "check-case-conflicts"; |
| 1408 | + description = "Check for files that would conflict in case-insensitive filesystems."; |
| 1409 | + entry = "${tools.pre-commit-hooks}/bin/check-case-conflict"; |
| 1410 | + types = [ "file" ]; |
| 1411 | + }; |
| 1412 | + check-docstring-first = |
| 1413 | + { |
| 1414 | + name = "check-docstring-above"; |
| 1415 | + description = "Check that all docstrings appear above the code."; |
| 1416 | + entry = "${tools.pre-commit-hooks}/bin/check-docstring-first"; |
| 1417 | + types = [ "python" ]; |
| 1418 | + }; |
| 1419 | + check-executables-have-shebangs = |
| 1420 | + { |
| 1421 | + name = "check-executables-have-shebangs"; |
| 1422 | + description = "Ensure that all non-binary executables have shebangs."; |
| 1423 | + entry = "${tools.pre-commit-hooks}/bin/check-executables-have-shebangs"; |
| 1424 | + types = [ "text" "executable" ]; |
| 1425 | + stages = [ "commit" "push" "manual" ]; |
| 1426 | + }; |
| 1427 | + check-json = |
| 1428 | + { |
| 1429 | + name = "check-json"; |
| 1430 | + description = "Check syntax of JSON files."; |
| 1431 | + entry = "${tools.pre-commit-hooks}/bin/check-json"; |
| 1432 | + types = [ "json" ]; |
| 1433 | + }; |
| 1434 | + check-merge-conflicts = |
| 1435 | + { |
| 1436 | + name = "check-merge-conflicts"; |
| 1437 | + description = "Check for files that contain merge conflict strings."; |
| 1438 | + entry = "${tools.pre-commit-hooks}/bin/check-merge-conflict"; |
| 1439 | + types = [ "text" ]; |
| 1440 | + }; |
| 1441 | + check-python = |
| 1442 | + { |
| 1443 | + name = "check-python"; |
| 1444 | + description = "Check syntax of Python file by parsing Python abstract syntax tree."; |
| 1445 | + entry = "${tools.pre-commit-hooks}/bin/check-ast"; |
| 1446 | + types = [ "python" ]; |
| 1447 | + }; |
| 1448 | + check-shebang-scripts-are-executable = |
| 1449 | + { |
| 1450 | + name = "check-shebang-scripts-are-executable"; |
| 1451 | + description = "Ensure that all (non-binary) files with a shebang are executable."; |
| 1452 | + entry = "${tools.pre-commit-hooks}/bin/check-shebang-scripts-are-executable"; |
| 1453 | + types = [ "text" ]; |
| 1454 | + stages = [ "commit" "push" "manual" ]; |
| 1455 | + }; |
| 1456 | + check-symlinks = |
| 1457 | + { |
| 1458 | + name = "check-symlinks"; |
| 1459 | + description = "Find broken symlinks."; |
| 1460 | + entry = "${tools.pre-commit-hooks}/bin/check-symlinks"; |
| 1461 | + types = [ "symlink" ]; |
| 1462 | + }; |
| 1463 | + check-toml = |
| 1464 | + { |
| 1465 | + name = "check-toml"; |
| 1466 | + description = "Check syntax of TOML files."; |
| 1467 | + entry = "${tools.pre-commit-hooks}/bin/check-toml"; |
| 1468 | + types = [ "toml" ]; |
| 1469 | + }; |
| 1470 | + check-vcs-permalinks = |
| 1471 | + { |
| 1472 | + name = "check-vcs-permalinks"; |
| 1473 | + description = "Ensure that links to VCS websites are permalinks."; |
| 1474 | + entry = "${tools.pre-commit-hooks}/bin/check-vcs-permalinks"; |
| 1475 | + types = [ "text" ]; |
| 1476 | + }; |
| 1477 | + check-xml = |
| 1478 | + { |
| 1479 | + name = "check-xml"; |
| 1480 | + description = "Check syntax of TOML files."; |
| 1481 | + entry = "${tools.pre-commit-hooks}/bin/check-xml"; |
| 1482 | + types = [ "xml" ]; |
| 1483 | + }; |
| 1484 | + check-yaml = |
| 1485 | + { |
| 1486 | + name = "check-yaml"; |
| 1487 | + description = "Check syntax of YAML files."; |
| 1488 | + entry = "${tools.pre-commit-hooks}/bin/check-yaml"; |
| 1489 | + types = [ "yaml" ]; |
| 1490 | + }; |
1359 | 1491 | chktex =
|
1360 | 1492 | {
|
1361 | 1493 | name = "chktex";
|
@@ -1530,6 +1662,20 @@ in
|
1530 | 1662 | in
|
1531 | 1663 | "${tools.deno}/bin/deno lint ${cmdArgs}";
|
1532 | 1664 | };
|
| 1665 | + detect-aws-credentials = |
| 1666 | + { |
| 1667 | + name = "detect-aws-credentials"; |
| 1668 | + description = "Detect AWS credentials from the AWS cli credentials file."; |
| 1669 | + entry = "${tools.pre-commit-hooks}/bin/detect-aws-credentials --allow-missing-credentials"; |
| 1670 | + types = [ "text" ]; |
| 1671 | + }; |
| 1672 | + detect-private-keys = |
| 1673 | + { |
| 1674 | + name = "detect-private-keys"; |
| 1675 | + description = "Detect the presence of private keys."; |
| 1676 | + entry = "${tools.pre-commit-hooks}/bin/detect-private-key"; |
| 1677 | + types = [ "text" ]; |
| 1678 | + }; |
1533 | 1679 | dhall-format = {
|
1534 | 1680 | name = "dhall-format";
|
1535 | 1681 | description = "Dhall code formatter.";
|
@@ -1593,6 +1739,13 @@ in
|
1593 | 1739 | entry = "${tools.editorconfig-checker}/bin/editorconfig-checker";
|
1594 | 1740 | types = [ "file" ];
|
1595 | 1741 | };
|
| 1742 | + end-of-file-fixer = |
| 1743 | + { |
| 1744 | + name = "end-of-file-fixer"; |
| 1745 | + description = "Ensures that a file is either empty, or ends with a single newline."; |
| 1746 | + entry = "${tools.pre-commit-hooks}/bin/end-of-file-fixer"; |
| 1747 | + types = [ "text" ]; |
| 1748 | + }; |
1596 | 1749 | elm-format =
|
1597 | 1750 | {
|
1598 | 1751 | name = "elm-format";
|
@@ -1624,6 +1777,14 @@ in
|
1624 | 1777 | entry = "${settings.eslint.binPath} --fix";
|
1625 | 1778 | files = "${settings.eslint.extensions}";
|
1626 | 1779 | };
|
| 1780 | + { |
| 1781 | + fix-byte-order-marker = |
| 1782 | + { |
| 1783 | + name = "fix-byte-order-marker"; |
| 1784 | + description = "Remove UTF-8 byte order marker."; |
| 1785 | + entry = "${tools.pre-commit-hooks}/bin/fix-byte-order-marker"; |
| 1786 | + types = [ "text" ]; |
| 1787 | + }; |
1627 | 1788 | flake8 =
|
1628 | 1789 | let
|
1629 | 1790 | extendIgnoreStr =
|
@@ -1660,14 +1821,28 @@ in
|
1660 | 1821 | "${settings.flynt.binPath} ${cmdArgs}";
|
1661 | 1822 | types = [ "python" ];
|
1662 | 1823 | };
|
| 1824 | + forbid-new-submodules = |
| 1825 | + { |
| 1826 | + name = "forbid-new-submodules"; |
| 1827 | + description = "Prevent addition of new Git submodules."; |
| 1828 | + entry = "${tools.pre-commit-hooks}/bin/forbid-new-submodules"; |
| 1829 | + types = [ "directory" ]; |
| 1830 | + }; |
| 1831 | + forbid-submodules = |
| 1832 | + { |
| 1833 | + name = "forbid-submodules"; |
| 1834 | + description = "Forbid any Git submodule in a repository."; |
| 1835 | + entry = "${tools.pre-commit-hooks}/bin/forbid-submodules"; |
| 1836 | + types = [ "directory" ]; |
| 1837 | + }; |
1663 | 1838 | fourmolu =
|
1664 | 1839 | {
|
1665 | 1840 | name = "fourmolu";
|
1666 | 1841 | description = "Haskell code prettifier.";
|
1667 | 1842 | entry =
|
1668 | 1843 | "${tools.fourmolu}/bin/fourmolu --mode inplace ${
|
1669 |
| - lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) settings.ormolu.defaultExtensions) |
1670 |
| - }"; |
| 1844 | +lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) settings.ormolu.defaultExtensions) |
| 1845 | +}"; |
1671 | 1846 | files = "\\.l?hs(-boot)?$";
|
1672 | 1847 | };
|
1673 | 1848 | fprettify = {
|
@@ -2010,6 +2185,12 @@ in
|
2010 | 2185 | entry = toString script;
|
2011 | 2186 | files = "\\.md$";
|
2012 | 2187 | };
|
| 2188 | + mixed-line-endings = { |
| 2189 | + name = "mixed-line-endings"; |
| 2190 | + description = "Resolve mixed line endings."; |
| 2191 | + entry = "${tools.pre-commit-hooks}/bin/mixed-line-endings --fix"; |
| 2192 | + types = [ "text" ]; |
| 2193 | + }; |
2013 | 2194 | mix-format = {
|
2014 | 2195 | name = "mix-format";
|
2015 | 2196 | description = "Runs the built-in Elixir syntax formatter";
|
@@ -2047,6 +2228,13 @@ in
|
2047 | 2228 | entry = settings.mypy.binPath;
|
2048 | 2229 | files = "\\.py$";
|
2049 | 2230 | };
|
| 2231 | + name-tests-test = |
| 2232 | + { |
| 2233 | + name = "mypy"; |
| 2234 | + description = "Verify that Python test files are named correctly."; |
| 2235 | + entry = "${tools.pre-commit-hooks}/bin/name-tests-test"; |
| 2236 | + files = "(^|/)tests/\.+\\.py$"; |
| 2237 | + }; |
2050 | 2238 | nil =
|
2051 | 2239 | {
|
2052 | 2240 | name = "nil";
|
@@ -2087,6 +2275,23 @@ in
|
2087 | 2275 | entry = "${tools.nixpkgs-fmt}/bin/nixpkgs-fmt";
|
2088 | 2276 | files = "\\.nix$";
|
2089 | 2277 | };
|
| 2278 | + no-commit-to-branch = |
| 2279 | + { |
| 2280 | + name = "no-commit-to-branch"; |
| 2281 | + description = "Disallow committing to certain branch/branches."; |
| 2282 | + pass_filenames = false; |
| 2283 | + always_run = true; |
| 2284 | + entry = |
| 2285 | + let |
| 2286 | + cmdArgs = |
| 2287 | + mkCmdArgs |
| 2288 | + (with settings.no-commit-to-branch; [ |
| 2289 | + [ (branch != [ ]) "--branch ${lib.strings.concatStringsSep " --branch " branch}" ] |
| 2290 | + [ (pattern != [ ]) "--pattern ${lib.strings.concatStringsSep " --pattern " pattern}" ] |
| 2291 | + ]); |
| 2292 | + in |
| 2293 | + "${tools.pre-commit-hooks}/bin/no-commit-to-branch ${cmdArgs}"; |
| 2294 | + }; |
2090 | 2295 | ocp-indent =
|
2091 | 2296 | {
|
2092 | 2297 | name = "ocp-indent";
|
@@ -2147,6 +2352,13 @@ in
|
2147 | 2352 | "${binPath} analyse";
|
2148 | 2353 | types = [ "php" ];
|
2149 | 2354 | };
|
| 2355 | + pretty-format-json = |
| 2356 | + { |
| 2357 | + name = "pretty-format-json"; |
| 2358 | + description = "Formats JSON files."; |
| 2359 | + entry = "${tools.pre-commit-hooks}/bin/pretty-format-json"; |
| 2360 | + types = [ "json" ]; |
| 2361 | + }; |
2150 | 2362 | pre-commit-hook-ensure-sops = {
|
2151 | 2363 | name = "pre-commit-hook-ensure-sops";
|
2152 | 2364 | entry =
|
@@ -2251,6 +2463,13 @@ in
|
2251 | 2463 | entry = settings.pyright.binPath;
|
2252 | 2464 | files = "\\.py$";
|
2253 | 2465 | };
|
| 2466 | + python-debug-statements = |
| 2467 | + { |
| 2468 | + name = "python-debug-statements"; |
| 2469 | + description = "Check for debugger imports and py37+ `breakpoint()` calls in python source."; |
| 2470 | + entry = "${tools.pre-commit-hooks}/bin/debug-statement-hook"; |
| 2471 | + types = [ "python" ]; |
| 2472 | + }; |
2254 | 2473 | pyupgrade =
|
2255 | 2474 | {
|
2256 | 2475 | name = "pyupgrade";
|
@@ -2342,6 +2561,44 @@ in
|
2342 | 2561 | types = [ "shell" ];
|
2343 | 2562 | entry = "${tools.shfmt}/bin/shfmt -w -s -l";
|
2344 | 2563 | };
|
| 2564 | + single-quoted-strings = |
| 2565 | + { |
| 2566 | + name = "single-quoted-strings"; |
| 2567 | + description = "Replace double quoted strings with single quoted strings."; |
| 2568 | + entry = "${tools.pre-commit-hooks}/bin/double-quote-string-fixer"; |
| 2569 | + types = [ "python" ]; |
| 2570 | + }; |
| 2571 | + sort-file-contents = |
| 2572 | + { |
| 2573 | + name = "sort-file-contents"; |
| 2574 | + description = "Sort the lines in specified files (defaults to alphabetical)."; |
| 2575 | + types = [ "text" ]; |
| 2576 | + entry = |
| 2577 | + let |
| 2578 | + cmdArgs = |
| 2579 | + mkCmdArgs |
| 2580 | + (with settings.sort-file-contents; |
| 2581 | + [ |
| 2582 | + [ ignore-case "--ignore-case" ] |
| 2583 | + [ unique "--unique" ] |
| 2584 | + ]); |
| 2585 | + in |
| 2586 | + "${tools.pre-commit-hooks}/bin/file-contents-sorter ${cmdArgs}"; |
| 2587 | + }; |
| 2588 | + sort-requirements-txt = |
| 2589 | + { |
| 2590 | + name = "sort-requirements.txt"; |
| 2591 | + description = "Sort requirements in requirements.txt and constraints.txt files."; |
| 2592 | + entry = "${tools.pre-commit-hooks}/bin/requirements-txt-fixer"; |
| 2593 | + files = "\\.*(requirements|constraints)\\.*\\.txt$"; |
| 2594 | + }; |
| 2595 | + sort-simple-yaml = |
| 2596 | + { |
| 2597 | + name = "sort-simple-yaml"; |
| 2598 | + description = "Sort simple YAML files which consist only of top-level keys, preserving comments and blocks."; |
| 2599 | + entry = "${tools.pre-commit-hooks}/bin/sort-simple-yaml"; |
| 2600 | + files = "(\\.yaml$)|(\\.yml$)"; |
| 2601 | + }; |
2345 | 2602 | staticcheck =
|
2346 | 2603 | {
|
2347 | 2604 | name = "staticcheck";
|
@@ -2447,6 +2704,14 @@ in
|
2447 | 2704 | );
|
2448 | 2705 | files = "(\\.json$)|(\\.toml$)|(\\.mli?$)";
|
2449 | 2706 | };
|
| 2707 | + trim-trailing-whitespace = |
| 2708 | + { |
| 2709 | + name = "trim-trailing-whitespace"; |
| 2710 | + description = "Trim trailing whitespace."; |
| 2711 | + types = [ "text" ]; |
| 2712 | + stages = [ "commit" "push" "manual" ]; |
| 2713 | + entry = "${tools.pre-commit-hooks}/bin/trailing-whitespace-fixer"; |
| 2714 | + }; |
2450 | 2715 | treefmt =
|
2451 | 2716 | {
|
2452 | 2717 | name = "treefmt";
|
|
0 commit comments