From 3a32aade6200a562bea2bdf08d9d140df310483a Mon Sep 17 00:00:00 2001 From: Sander Date: Sun, 25 May 2025 23:35:36 +0200 Subject: [PATCH 01/13] hooks: move all options to individual modules --- modules/hooks.nix | 1683 +------------------------ modules/hooks/alejandra.nix | 36 + modules/hooks/ansible-lint.nix | 20 + modules/hooks/autoflake.nix | 24 + modules/hooks/biome.nix | 39 + modules/hooks/black.nix | 14 + modules/hooks/cabal2nix.nix | 14 + modules/hooks/clippy.nix | 46 + modules/hooks/cmake-format.nix | 14 + modules/hooks/credo.nix | 14 + modules/hooks/deadnix.nix | 56 + modules/hooks/denofmt.nix | 22 + modules/hooks/denolint.nix | 23 + modules/hooks/dune-fmt.nix | 21 + modules/hooks/eclint.nix | 38 + modules/hooks/eslint.nix | 32 + modules/hooks/flake8.nix | 30 + modules/hooks/flynt.nix | 74 ++ modules/hooks/fourmolu.nix | 13 + modules/hooks/golines.nix | 14 + modules/hooks/headache.nix | 13 + modules/hooks/hlint.nix | 14 + modules/hooks/hpack.nix | 14 + modules/hooks/isort.nix | 20 + modules/hooks/lacheck.nix | 20 + modules/hooks/latexindent.nix | 14 + modules/hooks/lua-ls.nix | 20 + modules/hooks/lychee.nix | 20 + modules/hooks/markdownlint.nix | 15 + modules/hooks/mdl.nix | 80 ++ modules/hooks/mkdocs-linkcheck.nix | 52 + modules/hooks/mypy.nix | 17 + modules/hooks/nixfmt-classic.nix | 14 + modules/hooks/nixfmt-rfc-style.nix | 14 + modules/hooks/nixfmt.nix | 14 + modules/hooks/no-commit-to-branch.nix | 22 + modules/hooks/ormolu.nix | 20 + modules/hooks/php-cs-fixer.nix | 17 + modules/hooks/phpcbf.nix | 17 + modules/hooks/phpcs.nix | 17 + modules/hooks/phpstan.nix | 17 + modules/hooks/prettier.nix | 249 ++++ modules/hooks/pretty-format-json.nix | 38 + modules/hooks/proselint.nix | 33 + modules/hooks/psalm.nix | 17 + modules/hooks/pylint.nix | 29 + modules/hooks/pyright.nix | 17 + modules/hooks/pyupgrade.nix | 17 + modules/hooks/reuse.nix | 14 + modules/hooks/revive.nix | 16 + modules/hooks/ripsecrets.nix | 14 + modules/hooks/rome.nix | 39 + modules/hooks/rustfmt.nix | 89 ++ modules/hooks/shfmt.nix | 13 + modules/hooks/sort-file-contents.nix | 20 + modules/hooks/statix.nix | 37 + modules/hooks/treefmt.nix | 34 + modules/hooks/typos.nix | 133 ++ modules/hooks/vale.nix | 31 + modules/hooks/yamlfmt.nix | 25 + modules/hooks/yamllint.nix | 55 + 61 files changed, 1984 insertions(+), 1614 deletions(-) create mode 100644 modules/hooks/alejandra.nix create mode 100644 modules/hooks/ansible-lint.nix create mode 100644 modules/hooks/autoflake.nix create mode 100644 modules/hooks/biome.nix create mode 100644 modules/hooks/black.nix create mode 100644 modules/hooks/cabal2nix.nix create mode 100644 modules/hooks/clippy.nix create mode 100644 modules/hooks/cmake-format.nix create mode 100644 modules/hooks/credo.nix create mode 100644 modules/hooks/deadnix.nix create mode 100644 modules/hooks/denofmt.nix create mode 100644 modules/hooks/denolint.nix create mode 100644 modules/hooks/dune-fmt.nix create mode 100644 modules/hooks/eclint.nix create mode 100644 modules/hooks/eslint.nix create mode 100644 modules/hooks/flake8.nix create mode 100644 modules/hooks/flynt.nix create mode 100644 modules/hooks/fourmolu.nix create mode 100644 modules/hooks/golines.nix create mode 100644 modules/hooks/headache.nix create mode 100644 modules/hooks/hlint.nix create mode 100644 modules/hooks/hpack.nix create mode 100644 modules/hooks/isort.nix create mode 100644 modules/hooks/lacheck.nix create mode 100644 modules/hooks/latexindent.nix create mode 100644 modules/hooks/lua-ls.nix create mode 100644 modules/hooks/lychee.nix create mode 100644 modules/hooks/markdownlint.nix create mode 100644 modules/hooks/mdl.nix create mode 100644 modules/hooks/mkdocs-linkcheck.nix create mode 100644 modules/hooks/mypy.nix create mode 100644 modules/hooks/nixfmt-classic.nix create mode 100644 modules/hooks/nixfmt-rfc-style.nix create mode 100644 modules/hooks/nixfmt.nix create mode 100644 modules/hooks/no-commit-to-branch.nix create mode 100644 modules/hooks/ormolu.nix create mode 100644 modules/hooks/php-cs-fixer.nix create mode 100644 modules/hooks/phpcbf.nix create mode 100644 modules/hooks/phpcs.nix create mode 100644 modules/hooks/phpstan.nix create mode 100644 modules/hooks/prettier.nix create mode 100644 modules/hooks/pretty-format-json.nix create mode 100644 modules/hooks/proselint.nix create mode 100644 modules/hooks/psalm.nix create mode 100644 modules/hooks/pylint.nix create mode 100644 modules/hooks/pyright.nix create mode 100644 modules/hooks/pyupgrade.nix create mode 100644 modules/hooks/reuse.nix create mode 100644 modules/hooks/revive.nix create mode 100644 modules/hooks/ripsecrets.nix create mode 100644 modules/hooks/rome.nix create mode 100644 modules/hooks/rustfmt.nix create mode 100644 modules/hooks/shfmt.nix create mode 100644 modules/hooks/sort-file-contents.nix create mode 100644 modules/hooks/statix.nix create mode 100644 modules/hooks/treefmt.nix create mode 100644 modules/hooks/typos.nix create mode 100644 modules/hooks/vale.nix create mode 100644 modules/hooks/yamlfmt.nix create mode 100644 modules/hooks/yamllint.nix diff --git a/modules/hooks.nix b/modules/hooks.nix index b0c44203..002fe2eb 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -88,982 +88,242 @@ in alejandra = mkOption { description = "alejandra hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - check = - mkOption { - type = types.bool; - description = "Check if the input is already formatted and disable writing in-place the modified content"; - default = false; - example = true; - }; - exclude = - mkOption { - type = types.listOf types.str; - description = "Files or directories to exclude from formatting."; - default = [ ]; - example = [ "flake.nix" "./templates" ]; - }; - threads = - mkOption { - type = types.nullOr types.int; - description = "Number of formatting threads to spawn."; - default = null; - example = 8; - }; - verbosity = - mkOption { - type = types.enum [ "normal" "quiet" "silent" ]; - description = "Whether informational messages or all messages should be hidden or not."; - default = "normal"; - example = "quiet"; - }; - }; + imports = [ hookModule ./hooks/alejandra.nix ]; }; }; ansible-lint = mkOption { description = "ansible-lint hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - configPath = mkOption { - type = types.str; - description = "Path to the YAML configuration file."; - # an empty string translates to use default configuration of the - # underlying ansible-lint binary - default = ""; - }; - subdir = mkOption { - type = types.str; - description = "Path to the Ansible subdirectory."; - default = ""; - }; - }; + imports = [ hookModule ./hooks/ansible-lint.nix ]; }; }; autoflake = mkOption { description = "autoflake hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - binPath = - mkOption { - type = types.nullOr types.str; - description = "Path to autoflake binary."; - default = null; - defaultText = lib.literalExpression '' - "''${tools.autoflake}/bin/autoflake" - ''; - }; - - flags = - mkOption { - type = types.str; - description = "Flags passed to autoflake."; - default = "--in-place --expand-star-imports --remove-duplicate-keys --remove-unused-variables"; - }; - }; + imports = [ hookModule ./hooks/autoflake.nix ]; }; }; biome = mkOption { description = "biome hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - binPath = - mkOption { - type = types.nullOr (types.oneOf [ types.str types.path ]); - description = '' - `biome` binary path. - For example, if you want to use the `biome` binary from `node_modules`, use `"./node_modules/.bin/biome"`. - Use a string instead of a path to avoid having to Git track the file in projects that use Nix flakes. - ''; - default = null; - defaultText = lib.literalExpression '' - "''${tools.biome}/bin/biome" - ''; - example = lib.literalExpression '' - "./node_modules/.bin/biome" - ''; - }; - - write = - mkOption { - type = types.bool; - description = "Whether to edit files inplace."; - default = true; - }; - - configPath = mkOption { - type = types.str; - description = "Path to the configuration JSON file"; - # an empty string translates to use default configuration of the - # underlying biome binary (i.e biome.json if exists) - default = ""; - }; - }; + imports = [ hookModule ./hooks/biome.nix ]; }; }; black = mkOption { description = "black hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - flags = mkOption { - type = types.str; - description = "Flags passed to black. See all available [here](https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#command-line-options)."; - default = ""; - example = "--skip-magic-trailing-comma"; - }; - }; + imports = [ hookModule ./hooks/black.nix ]; }; }; cabal2nix = mkOption { description = "cabal2nix hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - outputFilename = - mkOption { - type = types.str; - description = "The name of the output file generated after running `cabal2nix`."; - default = "default.nix"; - }; - }; + imports = [ hookModule ./hooks/cabal2nix.nix ]; }; }; clippy = mkOption { description = "clippy hook"; - type = types.submodule - ({ config, ... }: { - imports = [ hookModule ]; - options.packageOverrides = { - cargo = mkOption { - type = types.package; - description = "The cargo package to use"; - }; - clippy = mkOption { - type = types.package; - description = "The clippy package to use"; - }; - }; - options.settings = { - denyWarnings = mkOption { - type = types.bool; - description = "Fail when warnings are present"; - default = false; - }; - offline = mkOption { - type = types.bool; - description = "Run clippy offline"; - default = true; - }; - allFeatures = mkOption { - type = types.bool; - description = "Run clippy with --all-features"; - default = false; - }; - extraArgs = mkOption { - type = types.str; - description = "Additional arguments to pass to clippy"; - default = ""; - }; - }; - - config.extraPackages = [ - config.packageOverrides.cargo - config.packageOverrides.clippy - ]; - }); + type = types.submodule { + imports = [ hookModule ./hooks/clippy.nix ]; + }; }; cmake-format = mkOption { description = "cmake-format hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - configPath = mkOption { - type = types.str; - description = "Path to the configuration file (.json,.python,.yaml)"; - default = ""; - example = ".cmake-format.json"; - }; - }; + imports = [ hookModule ./hooks/cmake-format.nix ]; }; }; credo = mkOption { description = "credo hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - strict = - mkOption { - type = types.bool; - description = "Whether to auto-promote the changes."; - default = true; - }; - }; + imports = [ hookModule ./hooks/credo.nix ]; }; }; deadnix = mkOption { description = "deadnix hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - edit = - mkOption { - type = types.bool; - description = "Remove unused code and write to source file."; - default = false; - }; - - exclude = - mkOption { - type = types.listOf types.str; - description = "Files to exclude from analysis."; - default = [ ]; - }; - - hidden = - mkOption { - type = types.bool; - description = "Recurse into hidden subdirectories and process hidden .*.nix files."; - default = false; - }; - - noLambdaArg = - mkOption { - type = types.bool; - description = "Don't check lambda parameter arguments."; - default = false; - }; - - noLambdaPatternNames = - mkOption { - type = types.bool; - description = "Don't check lambda pattern names (don't break nixpkgs `callPackage`)."; - default = false; - }; - - noUnderscore = - mkOption { - type = types.bool; - description = "Don't check any bindings that start with a `_`."; - default = false; - }; - - quiet = - mkOption { - type = types.bool; - description = "Don't print a dead code report."; - default = false; - }; - }; + imports = [ hookModule ./hooks/deadnix.nix ]; }; }; denofmt = mkOption { description = "denofmt hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - write = - mkOption { - type = types.bool; - description = "Whether to edit files inplace."; - default = true; - }; - configPath = - mkOption { - type = types.str; - description = "Path to the configuration JSON file"; - # an empty string translates to use default configuration of the - # underlying deno binary (i.e deno.json or deno.jsonc) - default = ""; - }; - }; + imports = [ hookModule ./hooks/denofmt.nix ]; }; }; denolint = mkOption { description = "denolint hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - format = - mkOption { - type = types.enum [ "default" "compact" "json" ]; - description = "Output format."; - default = "default"; - }; - - configPath = - mkOption { - type = types.str; - description = "Path to the configuration JSON file"; - # an empty string translates to use default configuration of the - # underlying deno binary (i.e deno.json or deno.jsonc) - default = ""; - }; - }; + imports = [ hookModule ./hooks/denolint.nix ]; }; }; dune-fmt = mkOption { description = "dune-fmt hook"; - type = types.submodule - ({ config, ... }: { - imports = [ hookModule ]; - options.settings = { - auto-promote = - mkOption { - type = types.bool; - description = "Whether to auto-promote the changes."; - default = true; - }; - - extraRuntimeInputs = - mkOption { - type = types.listOf types.package; - description = "Extra runtimeInputs to add to the environment, eg. `ocamlformat`."; - default = [ ]; - }; - }; - - config.extraPackages = config.settings.extraRuntimeInputs; - }); + type = types.submodule { + imports = [ hookModule ./hooks/dune-fmt.nix ]; + }; }; eclint = mkOption { description = "eclint hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - fix = - mkOption { - type = types.bool; - description = "Modify files in place rather than showing the errors."; - default = false; - }; - summary = - mkOption { - type = types.bool; - description = "Only show number of errors per file."; - default = false; - }; - color = - mkOption { - type = types.enum [ "auto" "always" "never" ]; - description = "When to generate colored output."; - default = "auto"; - }; - exclude = - mkOption { - type = types.listOf types.str; - description = "Filter to exclude files."; - default = [ ]; - }; - verbosity = - mkOption { - type = types.enum [ 0 1 2 3 4 ]; - description = "Log level verbosity"; - default = 0; - }; - }; + imports = [ hookModule ./hooks/eclint.nix ]; }; }; eslint = mkOption { description = "eslint hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - binPath = - mkOption { - type = types.nullOr (types.oneOf [ types.str types.path ]); - description = '' - `eslint` binary path. - For example, if you want to use the `eslint` binary from `node_modules`, use `"./node_modules/.bin/eslint"`. - Use a string instead of a path to avoid having to Git track the file in projects that use Nix flakes. - ''; - default = null; - defaultText = lib.literalExpression '' - "''${tools.eslint}/bin/eslint" - ''; - example = lib.literalExpression '' - "./node_modules/.bin/eslint" - ''; - }; - - extensions = - mkOption { - type = types.str; - description = - "The pattern of files to run on, see [https://pre-commit.com/#hooks-files](https://pre-commit.com/#hooks-files)."; - default = "\\.js$"; - }; - }; + imports = [ hookModule ./hooks/eslint.nix ]; }; }; flake8 = mkOption { description = "flake8 hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - binPath = - mkOption { - type = types.nullOr types.str; - description = "flake8 binary path. Should be used to specify flake8 binary from your Python environment."; - default = null; - defaultText = lib.literalExpression '' - "''${tools.flake8}/bin/flake8" - ''; - }; - extendIgnore = - mkOption { - type = types.listOf types.str; - description = "List of additional ignore codes"; - default = [ ]; - example = [ "E501" ]; - }; - format = - mkOption { - type = types.str; - description = "Output format."; - default = "default"; - }; - }; + imports = [ hookModule ./hooks/flake8.nix ]; }; }; flynt = mkOption { description = "flynt hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - aggressive = - mkOption { - type = types.bool; - description = "Include conversions with potentially changed behavior."; - default = false; - }; - binPath = - mkOption { - type = types.nullOr types.str; - description = "flynt binary path. Can be used to specify the flynt binary from an existing Python environment."; - default = null; - }; - dry-run = - mkOption { - type = types.bool; - description = "Do not change files in-place and print diff instead."; - default = false; - }; - exclude = - mkOption { - type = types.listOf types.str; - description = "Ignore files with given strings in their absolute path."; - default = [ ]; - }; - fail-on-change = - mkOption { - type = types.bool; - description = "Fail when diff is not empty (for linting purposes)."; - default = true; - }; - line-length = - mkOption { - type = types.nullOr types.int; - description = "Convert expressions spanning multiple lines, only if the resulting single line will fit into this line length limit."; - default = null; - }; - no-multiline = - mkOption { - type = types.bool; - description = "Convert only single line expressions."; - default = false; - }; - quiet = - mkOption { - type = types.bool; - description = "Run without output."; - default = false; - }; - string = - mkOption { - type = types.bool; - description = "Interpret the input as a Python code snippet and print the converted version."; - default = false; - }; - transform-concats = - mkOption { - type = types.bool; - description = "Replace string concatenations with f-strings."; - default = false; - }; - verbose = - mkOption { - type = types.bool; - description = "Run with verbose output."; - default = false; - }; - }; + imports = [ hookModule ./hooks/flynt.nix ]; }; }; fourmolu = mkOption { description = "fourmolu hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings.defaultExtensions = mkOption { - type = types.listOf types.str; - description = "Haskell language extensions to enable."; - default = [ ]; - }; + imports = [ hookModule ./hooks/fourmolu.nix ]; }; }; golines = mkOption { description = "golines hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - flags = mkOption { - type = types.str; - description = "Flags passed to golines. See all available [here](https://github.com/segmentio/golines?tab=readme-ov-file#options)"; - default = ""; - example = "-m 120"; - }; - }; + imports = [ hookModule ./hooks/golines.nix ]; }; }; headache = mkOption { description = "headache hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - header-file = mkOption { - type = types.str; - description = "Path to the header file."; - default = ".header"; - }; - }; + imports = [ hookModule ./hooks/headache.nix ]; }; }; hlint = mkOption { description = "hlint hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - hintFile = - mkOption { - type = types.nullOr (types.oneOf [ types.str types.path ]); - description = "Path to hlint.yaml. By default, hlint searches for .hlint.yaml in the project root."; - default = null; - }; - }; + imports = [ hookModule ./hooks/hlint.nix ]; }; }; hpack = mkOption { description = "hpack hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - silent = - mkOption { - type = types.bool; - description = "Whether generation should be silent."; - default = false; - }; - }; + imports = [ hookModule ./hooks/hpack.nix ]; }; }; isort = mkOption { description = "isort hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - profile = - mkOption { - type = types.enum [ "" "black" "django" "pycharm" "google" "open_stack" "plone" "attrs" "hug" "wemake" "appnexus" ]; - description = "Built-in profiles to allow easy interoperability with common projects and code styles."; - default = ""; - }; - flags = - mkOption { - type = types.str; - description = "Flags passed to isort. See all available [here](https://pycqa.github.io/isort/docs/configuration/options.html)."; - default = ""; - }; - }; + imports = [ hookModule ./hooks/isort.nix ]; }; }; latexindent = mkOption { description = "latexindent hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - flags = - mkOption { - type = types.str; - description = "Flags passed to latexindent. See available flags [here](https://latexindentpl.readthedocs.io/en/latest/sec-how-to-use.html#from-the-command-line)"; - default = "--local --silent --overwriteIfDifferent"; - }; - }; + imports = [ hookModule ./hooks/latexindent.nix ]; }; }; lacheck = mkOption { description = "lacheck hook"; type = types.submodule { - imports = [ hookModule ]; + imports = [ hookModule ./hooks/lacheck.nix ]; }; }; lua-ls = mkOption { description = "lua-ls hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - checklevel = mkOption { - type = types.enum [ "Error" "Warning" "Information" "Hint" ]; - description = - "The diagnostic check level"; - default = "Warning"; - }; - configuration = mkOption { - type = types.attrs; - description = - "See https://github.com/LuaLS/lua-language-server/wiki/Configuration-File#luarcjson"; - default = { }; - }; - }; + imports = [ hookModule ./hooks/lua-ls.nix ]; }; }; lychee = mkOption { description = "lychee hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - configPath = - mkOption { - type = types.str; - description = "Path to the config file."; - default = ""; - }; - flags = - mkOption { - type = types.str; - description = "Flags passed to lychee. See all available [here](https://lychee.cli.rs/#/usage/cli)."; - default = ""; - }; - }; + imports = [ hookModule ./hooks/lychee.nix ]; }; }; markdownlint = mkOption { description = "markdownlint hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - configuration = - mkOption { - type = types.attrs; - description = - "See https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.jsonc"; - default = { }; - }; - }; + imports = [ hookModule ./hooks/markdownlint.nix ]; }; }; mdl = mkOption { description = "mdl hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - configPath = - mkOption { - type = types.str; - description = "The configuration file to use."; - default = ""; - }; - git-recurse = - mkOption { - type = types.bool; - description = "Only process files known to git when given a directory."; - default = false; - }; - ignore-front-matter = - mkOption { - type = types.bool; - description = "Ignore YAML front matter."; - default = false; - }; - json = - mkOption { - type = types.bool; - description = "Format output as JSON."; - default = false; - }; - rules = - mkOption { - type = types.listOf types.str; - description = "Markdown rules to use for linting. Per default all rules are processed."; - default = [ ]; - }; - rulesets = - mkOption { - type = types.listOf types.str; - description = "Specify additional ruleset files to load."; - default = [ ]; - }; - show-aliases = - mkOption { - type = types.bool; - description = "Show rule alias instead of rule ID when viewing rules."; - default = false; - }; - warnings = - mkOption { - type = types.bool; - description = "Show Kramdown warnings."; - default = false; - }; - skip-default-ruleset = - mkOption { - type = types.bool; - description = "Do not load the default markdownlint ruleset. Use this option if you only want to load custom rulesets."; - default = false; - }; - style = - mkOption { - type = types.str; - description = "Select which style mdl uses."; - default = "default"; - }; - tags = - mkOption { - type = types.listOf types.str; - description = "Markdown rules to use for linting containing the given tags. Per default all rules are processed."; - default = [ ]; - }; - verbose = - mkOption { - type = types.bool; - description = "Increase verbosity."; - default = false; - }; - }; + imports = [ hookModule ./hooks/mdl.nix ]; }; }; mkdocs-linkcheck = mkOption { description = "mkdocs-linkcheck hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - binPath = - mkOption { - type = types.nullOr (types.oneOf [ types.str types.path ]); - description = "mkdocs-linkcheck binary path. Should be used to specify the mkdocs-linkcheck binary from your Python environment."; - default = null; - defaultText = lib.literalExpression '' - "''${tools.mkdocs-linkcheck}/bin/mkdocs-linkcheck" - ''; - }; - - path = - mkOption { - type = types.str; - description = "Path to check"; - default = ""; - }; - - local-only = - mkOption { - type = types.bool; - description = "Whether to only check local links."; - default = false; - }; - - recurse = - mkOption { - type = types.bool; - description = "Whether to recurse directories under path."; - default = false; - }; - - extension = - mkOption { - type = types.str; - description = "File extension to scan for."; - default = ""; - }; - - method = - mkOption { - type = types.enum [ "get" "head" ]; - description = "HTTP method to use when checking external links."; - default = "get"; - }; - }; + imports = [ hookModule ./hooks/mkdocs-linkcheck.nix ]; }; }; mypy = mkOption { description = "mypy hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - binPath = - mkOption { - type = types.nullOr types.str; - description = "Mypy binary path. Should be used to specify the mypy executable in an environment containing your typing stubs."; - default = null; - defaultText = lib.literalExpression '' - "''${tools.mypy}/bin/mypy" - ''; - }; - }; + imports = [ hookModule ./hooks/mypy.nix ]; }; }; nixfmt = mkOption { description = "Deprecated nixfmt hook. Use nixfmt-classic or nixfmt-rfc-style instead."; visible = false; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - width = - mkOption { - type = types.nullOr types.int; - description = "Line width."; - default = null; - }; - }; + imports = [ hookModule ./hooks/nixfmt.nix ]; }; }; nixfmt-classic = mkOption { description = "nixfmt (classic) hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - width = - mkOption { - type = types.nullOr types.int; - description = "Line width."; - default = null; - }; - }; + imports = [ hookModule ./hooks/nixfmt-classic.nix ]; }; }; nixfmt-rfc-style = mkOption { description = "nixfmt (RFC 166 style) hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - width = - mkOption { - type = types.nullOr types.int; - description = "Line width."; - default = null; - }; - }; + imports = [ hookModule ./hooks/nixfmt-rfc-style.nix ]; }; }; no-commit-to-branch = mkOption { description = "no-commit-to-branch-hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - branch = - mkOption { - description = "Branches to disallow commits to."; - type = types.listOf types.str; - default = [ "main" ]; - example = [ "main" "master" ]; - }; - pattern = - mkOption { - description = "RegEx patterns for branch names to disallow commits to."; - type = types.listOf types.str; - default = [ ]; - example = [ "ma.*" ]; - }; - }; + imports = [ hookModule ./hooks/no-commit-to-branch.nix ]; }; }; ormolu = mkOption { description = "ormolu hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - defaultExtensions = - mkOption { - type = types.listOf types.str; - description = "Haskell language extensions to enable."; - default = [ ]; - }; - cabalDefaultExtensions = - mkOption { - type = types.bool; - description = "Use `default-extensions` from `.cabal` files."; - default = false; - }; - }; + imports = [ hookModule ./hooks/ormolu.nix ]; }; }; php-cs-fixer = mkOption { description = "php-cs-fixer hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - binPath = - mkOption { - type = types.nullOr types.str; - description = "PHP-CS-Fixer binary path."; - default = null; - defaultText = lib.literalExpression '' - "''${tools.php-cs-fixer}/bin/php-cs-fixer" - ''; - }; - }; + imports = [ hookModule ./hooks/php-cs-fixer.nix ]; }; }; phpcbf = mkOption { description = "phpcbf hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - binPath = - mkOption { - type = types.nullOr types.str; - description = "PHP_CodeSniffer binary path."; - default = null; - defaultText = lib.literalExpression '' - "''${tools.phpcbf}/bin/phpcbf" - ''; - }; - }; + imports = [ hookModule ./hooks/phpcbf.nix ]; }; }; phpcs = mkOption { description = "phpcs hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - binPath = - mkOption { - type = types.nullOr types.str; - description = "PHP_CodeSniffer binary path."; - default = null; - defaultText = lib.literalExpression '' - "''${tools.phpcs}/bin/phpcs" - ''; - }; - }; + imports = [ hookModule ./hooks/phpcs.nix ]; }; }; phpstan = mkOption { description = "phpstan hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - binPath = - mkOption { - type = types.nullOr types.str; - description = "PHPStan binary path."; - default = null; - defaultText = lib.literalExpression '' - "''${tools.phpstan}/bin/phpstan" - ''; - }; - }; + imports = [ hookModule ./hooks/phpstan.nix ]; }; }; # See all CLI flags for prettier [here](https://prettier.io/docs/en/cli.html). @@ -1071,486 +331,69 @@ in prettier = mkOption { description = "prettier hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - binPath = - mkOption { - description = '' - `prettier` binary path. - For example, if you want to use the `prettier` binary from `node_modules`, use `"./node_modules/.bin/prettier"`. - Use a string instead of a path to avoid having to Git track the file in projects that use Nix flakes. - ''; - type = types.nullOr (types.oneOf [ types.str types.path ]); - default = null; - defaultText = lib.literalExpression '' - "''${tools.prettier}/bin/prettier" - ''; - example = lib.literalExpression '' - "./node_modules/.bin/prettier" - ''; - }; - allow-parens = - mkOption { - description = "Include parentheses around a sole arrow function parameter."; - default = "always"; - type = types.enum [ "always" "avoid" ]; - }; - bracket-same-line = - mkOption { - description = "Put > of opening tags on the last line instead of on a new line."; - type = types.bool; - default = false; - }; - cache = - mkOption { - description = "Only format changed files."; - type = types.bool; - default = false; - }; - cache-location = - mkOption { - description = "Path to the cache file location used by `--cache` flag."; - type = types.str; - default = "./node_modules/.cache/prettier/.prettier-cache"; - }; - cache-strategy = - mkOption { - description = "Strategy for the cache to use for detecting changed files."; - type = types.nullOr (types.enum [ "metadata" "content" ]); - default = null; - }; - check = - mkOption { - description = "Output a human-friendly message and a list of unformatted files, if any."; - type = types.bool; - default = false; - }; - list-different = - mkOption { - description = "Print the filenames of files that are different from Prettier formatting."; - type = types.bool; - default = true; - }; - color = - mkOption { - description = "Colorize error messages."; - type = types.bool; - default = true; - }; - configPath = - mkOption { - description = "Path to a Prettier configuration file (.prettierrc, package.json, prettier.config.js)."; - type = types.str; - default = ""; - }; - config-precedence = - mkOption { - description = "Defines how config file should be evaluated in combination of CLI options."; - type = types.enum [ "cli-override" "file-override" "prefer-file" ]; - default = "cli-override"; - }; - embedded-language-formatting = - mkOption { - description = "Control how Prettier formats quoted code embedded in the file."; - type = types.enum [ "auto" "off" ]; - default = "auto"; - }; - end-of-line = - mkOption { - description = "Which end of line characters to apply."; - type = types.enum [ "lf" "crlf" "cr" "auto" ]; - default = "lf"; - }; - html-whitespace-sensitivity = - mkOption { - description = "How to handle whitespaces in HTML."; - type = types.enum [ "css" "strict" "ignore" ]; - default = "css"; - }; - ignore-path = - mkOption { - description = "Path to a file containing patterns that describe files to ignore. - By default, prettier looks for `./.gitignore` and `./.prettierignore`. - Multiple values are accepted."; - type = types.listOf (types.oneOf [ types.str types.path ]); - default = [ ]; - }; - ignore-unknown = - mkOption { - description = "Ignore unknown files."; - type = types.bool; - default = true; - }; - insert-pragma = - mkOption { - description = "Insert @format pragma into file's first docblock comment."; - type = types.bool; - default = false; - }; - jsx-single-quote = - mkOption { - description = "Use single quotes in JSX."; - type = types.bool; - default = false; - }; - log-level = - mkOption { - description = "What level of logs to report."; - type = types.enum [ "silent" "error" "warn" "log" "debug" ]; - default = "log"; - example = "debug"; - }; - no-bracket-spacing = - mkOption { - description = "Do not print spaces between brackets."; - type = types.bool; - default = false; - }; - no-config = - mkOption { - description = "Do not look for a configuration file."; - type = types.bool; - default = false; - }; - no-editorconfig = - mkOption { - description = "Don't take .editorconfig into account when parsing configuration."; - type = types.bool; - default = false; - }; - no-error-on-unmatched-pattern = - mkOption { - description = "Prevent errors when pattern is unmatched."; - type = types.bool; - default = false; - }; - no-semi = - mkOption { - description = "Do not print semicolons, except at the beginning of lines which may need them."; - type = types.bool; - default = false; - }; - parser = - mkOption { - description = "Which parser to use."; - type = types.enum [ "" "flow" "babel" "babel-flow" "babel-ts" "typescript" "acorn" "espree" "meriyah" "css" "less" "scss" "json" "json5" "json-stringify" "graphql" "markdown" "mdx" "vue" "yaml" "glimmer" "html" "angular" "lwc" ]; - default = ""; - }; - print-width = - mkOption { - type = types.int; - description = "Line length that the printer will wrap on."; - default = 80; - }; - prose-wrap = - mkOption { - description = "When to or if at all hard wrap prose to print width."; - type = types.enum [ "always" "never" "preserve" ]; - default = "preserve"; - }; - plugins = - mkOption { - description = "Add plugins from paths."; - type = types.listOf types.str; - default = [ ]; - }; - quote-props = - mkOption { - description = "Change when properties in objects are quoted."; - type = types.enum [ "as-needed" "consistent" "preserve" ]; - default = "as-needed"; - }; - require-pragma = - mkOption { - description = "Require either '@prettier' or '@format' to be present in the file's first docblock comment."; - type = types.bool; - default = false; - }; - single-attribute-per-line = - mkOption { - description = "Enforce single attribute per line in HTML, Vue andJSX."; - type = types.bool; - default = false; - }; - single-quote = - mkOption { - description = "Number of spaces per indentation-level."; - type = types.bool; - default = false; - }; - tab-width = - mkOption { - description = "Line length that the printer will wrap on."; - type = types.int; - default = 2; - }; - trailing-comma = - mkOption { - description = "Print trailing commas wherever possible in multi-line comma-separated syntactic structures."; - type = types.enum [ "all" "es5" "none" ]; - default = "all"; - }; - use-tabs = - mkOption { - type = types.bool; - description = "Indent with tabs instead of spaces."; - default = false; - }; - vue-indent-script-and-style = - mkOption { - description = "Indent script and style tags in Vue files."; - type = types.bool; - default = false; - }; - with-node-modules = - mkOption { - type = types.bool; - description = "Process files inside 'node_modules' directory."; - default = false; - }; - write = - mkOption { - description = "Edit files in-place."; - type = types.bool; - default = true; - }; - }; + imports = [ hookModule ./hooks/prettier.nix ]; }; }; pretty-format-json = mkOption { description = "pretty-format-json hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - autofix = - mkOption { - type = types.bool; - description = "Automatically format JSON files."; - default = false; - }; - indent = - mkOption { - type = types.nullOr (types.oneOf [ types.int types.str ]); - description = "Control the indentation (either a number for a number of spaces or a string of whitespace). Defaults to 2 spaces."; - default = null; - }; - no-ensure-ascii = - mkOption { - type = types.bool; - description = "Preserve unicode characters instead of converting to escape sequences."; - default = false; - }; - no-sort-keys = - mkOption { - type = types.bool; - description = "When autofixing, retain the original key ordering (instead of sorting the keys)."; - default = false; - }; - top-keys = - mkOption { - type = types.listOf types.str; - description = "Keys to keep at the top of mappings."; - default = [ ]; - }; - }; + imports = [ hookModule ./hooks/pretty-format-json.nix ]; }; }; proselint = mkOption { description = "proselint hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - config = - mkOption { - type = types.str; - description = "Multiline-string configuration passed as config file."; - default = ""; - example = '' - { - "checks": { - "typography.diacritical_marks": false - } - } - ''; - }; - configPath = - mkOption { - type = types.str; - description = "Path to the config file."; - default = ""; - }; - flags = - mkOption { - type = types.str; - description = "Flags passed to proselint."; - default = ""; - }; - }; + imports = [ hookModule ./hooks/proselint.nix ]; }; }; psalm = mkOption { description = "psalm hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - binPath = - mkOption { - type = types.nullOr types.str; - description = "Psalm binary path."; - default = null; - defaultText = lib.literalExpression '' - "''${tools.psalm}/bin/psalm" - ''; - }; - }; + imports = [ hookModule ./hooks/psalm.nix ]; }; }; pylint = mkOption { description = "pylint hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - binPath = - mkOption { - type = types.nullOr types.str; - description = "Pylint binary path. Should be used to specify Pylint binary from your Python environment."; - default = null; - defaultText = lib.literalExpression '' - "''${tools.pylint}/bin/pylint" - ''; - }; - reports = - mkOption { - type = types.bool; - description = "Whether to display a full report."; - default = false; - }; - score = - mkOption { - type = types.bool; - description = "Whether to activate the evaluation score."; - default = true; - }; - }; + imports = [ hookModule ./hooks/pylint.nix ]; }; }; pyright = mkOption { description = "pyright hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - binPath = - mkOption { - type = types.nullOr types.str; - description = "Pyright binary path. Should be used to specify the pyright executable in an environment containing your typing stubs."; - default = null; - defaultText = lib.literalExpression '' - "''${tools.pyright}/bin/pyright" - ''; - }; - }; + imports = [ hookModule ./hooks/pyright.nix ]; }; }; pyupgrade = mkOption { description = "pyupgrade hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - binPath = - mkOption { - type = types.nullOr types.str; - description = "pyupgrade binary path. Should be used to specify the pyupgrade binary from your Python environment."; - default = null; - defaultText = lib.literalExpression '' - "''${tools.pyupgrade}/bin/pyupgrade" - ''; - }; - }; + imports = [ hookModule ./hooks/pyupgrade.nix ]; }; }; reuse = mkOption { description = "reuse hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - flags = mkOption { - type = types.str; - description = "Flags passed to reuse. For available options run 'reuse lint --help'"; - default = ""; - example = "--json"; - }; - }; + imports = [ hookModule ./hooks/reuse.nix ]; }; }; revive = mkOption { description = "revive hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - configPath = - mkOption { - type = types.str; - description = "Path to the configuration TOML file."; - # an empty string translates to use default configuration of the - # underlying revive binary - default = ""; - }; - }; + imports = [ hookModule ./hooks/revive.nix ]; }; }; ripsecrets = mkOption { description = "ripsecrets hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - additionalPatterns = - mkOption { - type = types.listOf types.str; - description = "Additional regex patterns used to find secrets. If there is a matching group in the regex the matched group will be tested for randomness before being reported as a secret."; - default = [ ]; - }; - }; + imports = [ hookModule ./hooks/ripsecrets.nix ]; }; }; rome = mkOption { description = "Deprecated rome hook. Use biome instead."; visible = false; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - binPath = - mkOption { - type = types.nullOr (types.oneOf [ types.str types.path ]); - description = '' - `rome` binary path. - For example, if you want to use the `rome` binary from `node_modules`, use `"./node_modules/.bin/rome"`. - Use a string instead of a path to avoid having to Git track the file in projects that use Nix flakes. - ''; - default = null; - defaultText = lib.literalExpression '' - "''${tools.rome}/bin/rome - ''; - example = lib.literalExpression '' - "./node_modules/.bin/rome" - ''; - }; - - write = - mkOption { - type = types.bool; - description = "Whether to edit files inplace."; - default = true; - }; - - configPath = mkOption { - type = types.str; - description = "Path to the configuration JSON file"; - # an empty string translates to use default configuration of the - # underlying biome binary (i.e biome.json if exists) - default = ""; - }; - }; + imports = [ hookModule ./hooks/rome.nix ]; }; }; rustfmt = mkOption { @@ -1564,166 +407,27 @@ in hooks.rustfmt.packageOverrides.rustfmt = pkgs.rustfmt; ``` ''; - type = types.submodule ({ config, ... }: { - imports = [ hookModule ]; - options = { - packageOverrides = { - cargo = mkOption { - type = types.package; - description = "The cargo package to use."; - }; - rustfmt = mkOption { - type = types.package; - description = "The rustfmt package to use."; - }; - }; - settings = - let - nameType = types.strMatching "[][*?!0-9A-Za-z_-]+"; - in - { - all = mkOption { - type = types.bool; - description = "Format all packages, and also their local path-based dependencies"; - default = true; - }; - check = mkOption { - type = types.bool; - description = "Run rustfmt in check mode"; - default = false; - }; - color = mkOption { - type = types.enum [ "auto" "always" "never" ]; - description = "Coloring the output"; - default = "always"; - }; - config = mkOption { - type = types.attrs; - description = "Override configuration values"; - default = { }; - apply = config: - let - config' = lib.mapAttrsToList - (key: value: "${key}=${toString value}") - config; - in - if config != { } - then - (builtins.concatStringsSep "," config') - else - null; - }; - config-path = mkOption { - type = types.nullOr types.str; - description = "Path to rustfmt.toml config file"; - default = null; - }; - emit = mkOption { - type = types.nullOr (types.enum [ "files" "stdout" ]); - description = "What data to emit and how"; - default = null; - }; - files-with-diff = mkOption { - type = types.bool; - description = ""; - default = hooks.rustfmt.settings.message-format == "short"; - }; - manifest-path = mkOption { - type = types.nullOr types.str; - description = "Path to Cargo.toml"; - default = settings.rust.cargoManifestPath; - }; - message-format = mkOption { - type = types.nullOr (types.enum [ "human" "short" ]); - description = "The output format of diagnostic messages"; - default = null; - }; - package = mkOption { - type = types.listOf nameType; - description = "Package(s) to check"; - default = [ ]; - }; - verbose = mkOption { - type = types.bool; - description = "Use verbose output"; - default = false; - }; - }; - }; - config.extraPackages = [ - config.packageOverrides.cargo - config.packageOverrides.rustfmt - ]; - }); + type = types.submoduleWith { + modules = [ hookModule ./hooks/rustfmt.nix ]; + specialArgs = { rustSettings = config.settings.rust; }; + }; }; shfmt = mkOption { description = "shfmt hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - simplify = mkOption { - type = types.bool; - description = "Simplify the code."; - default = true; - }; - }; + imports = [ hookModule ./hooks/shfmt.nix ]; }; }; statix = mkOption { description = "statix hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - config = - mkOption { - type = types.nullOr types.str; - description = "Path to statix.toml or its parent directory."; - default = null; - }; - - format = - mkOption { - type = types.enum [ "stderr" "errfmt" "json" ]; - description = "Error Output format."; - default = "errfmt"; - }; - - ignore = - mkOption { - type = types.listOf types.str; - description = "Globs of file patterns to skip."; - default = [ ]; - example = [ "flake.nix" "_*" ]; - }; - - unrestricted = - mkOption { - type = types.bool; - description = "Don't respect .gitignore files."; - default = false; - example = true; - }; - }; + imports = [ hookModule ./hooks/statix.nix ]; }; }; sort-file-contents = mkOption { description = "sort-file-contents-hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - ignore-case = - mkOption { - type = types.bool; - description = "Fold lower case to upper case characters."; - default = false; - }; - unique = - mkOption { - type = types.bool; - description = "Ensure each line is unique."; - default = false; - }; - }; + imports = [ hookModule ./hooks/sort-file-contents.nix ]; }; }; treefmt = mkOption { @@ -1745,281 +449,32 @@ in hooks.treefmt.packageOverrides.treefmt = pkgs.treefmt; ``` ''; - type = types.submodule - ({ config, ... }: - { - imports = [ hookModule ]; - options.packageOverrides = { - treefmt = mkOption { - type = types.package; - description = "The treefmt package to use"; - }; - }; - options.settings = { - fail-on-change = - mkOption { - type = types.bool; - description = "Fail if some files require re-formatting."; - default = true; - }; - no-cache = - mkOption { - type = types.bool; - description = "Ignore the evaluation cache entirely."; - default = true; - }; - formatters = mkOption { - type = types.listOf types.package; - description = "The formatter packages configured by treefmt"; - default = [ ]; - }; - }; - - config.extraPackages = config.settings.formatters; - }); + type = types.submodule { + imports = [ hookModule ./hooks/treefmt.nix ]; + }; }; typos = mkOption { description = "typos hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - binary = - mkOption { - type = types.bool; - description = "Whether to search binary files."; - default = false; - }; - color = - mkOption { - type = types.enum [ "auto" "always" "never" ]; - description = "When to use generate output."; - default = "auto"; - }; - configuration = - mkOption { - type = types.str; - description = "Multiline-string configuration passed as config file. If set, config set in `typos.settings.configPath` gets ignored."; - default = ""; - example = '' - [files] - ignore-dot = true - - [default] - binary = false - - [type.py] - extend-glob = [] - ''; - }; - - configPath = - mkOption { - type = types.str; - description = "Path to a custom config file."; - default = ""; - example = ".typos.toml"; - }; - - diff = - mkOption { - type = types.bool; - description = "Print a diff of what would change."; - default = false; - }; - - exclude = - mkOption { - type = types.str; - description = "Ignore files and directories matching the glob."; - default = ""; - example = "*.nix"; - }; - - format = - mkOption { - type = types.enum [ "silent" "brief" "long" "json" ]; - description = "Output format to use."; - default = "long"; - }; - - hidden = - mkOption { - type = types.bool; - description = "Search hidden files and directories."; - default = false; - }; - - ignored-words = - mkOption { - type = types.listOf types.str; - description = "Spellings and words to ignore."; - default = [ ]; - example = [ - "MQTT" - "mosquitto" - ]; - }; - - locale = - mkOption { - type = types.enum [ "en" "en-us" "en-gb" "en-ca" "en-au" ]; - description = "Which language to use for spell checking."; - default = "en"; - }; - - no-check-filenames = - mkOption { - type = types.bool; - description = "Skip verifying spelling in file names."; - default = false; - }; - - no-check-files = - mkOption { - type = types.bool; - description = "Skip verifying spelling in files."; - default = false; - }; - - no-unicode = - mkOption { - type = types.bool; - description = "Only allow ASCII characters in identifiers."; - default = false; - }; - - quiet = - mkOption { - type = types.bool; - description = "Less output per occurrence."; - default = false; - }; - - verbose = - mkOption { - type = types.bool; - description = "More output per occurrence."; - default = false; - }; - - write = - mkOption { - type = types.bool; - description = "Fix spelling in files by writing them. Cannot be used with `typos.settings.diff`."; - default = false; - }; - }; + imports = [ hookModule ./hooks/typos.nix ]; }; }; vale = mkOption { description = "vale hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - configuration = - mkOption { - type = types.str; - description = "Multiline-string configuration passed as config file."; - default = ""; - example = '' - MinAlertLevel = suggestion - [*] - BasedOnStyles = Vale - ''; - }; - configPath = - mkOption { - type = types.str; - description = "Path to the config file."; - default = ""; - }; - flags = - mkOption { - type = types.str; - description = "Flags passed to vale."; - default = ""; - }; - }; + imports = [ hookModule ./hooks/vale.nix ]; }; }; yamlfmt = mkOption { description = "yamlfmt hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - configPath = - mkOption { - type = types.str; - description = "Path to a custom configuration file."; - # An empty string translates to yamlfmt looking for a configuration file in the - # following locations (by order of preference): - # a file named .yamlfmt, yamlfmt.yml, yamlfmt.yaml, .yamlfmt.yaml or .yamlfmt.yml in the current working directory - # See details [here](https://github.com/google/yamlfmt/blob/main/docs/config-file.md#config-file-discovery) - default = ""; - example = ".yamlfmt"; - }; - lint-only = - mkOption { - type = types.bool; - description = "Only lint the files, do not format them in place."; - default = true; - }; - }; + imports = [ hookModule ./hooks/yamlfmt.nix ]; }; }; yamllint = mkOption { description = "yamllint hook"; type = types.submodule { - imports = [ hookModule ]; - options.settings = { - # `list-files` is not useful for a pre-commit hook as it always exits with exit code 0 - # `no-warnings` is not useful for a pre-commit hook as it exits with exit code 2 and the hook - # therefore fails when warnings level problems are detected but there is no output - configuration = mkOption { - type = types.str; - description = "Multiline-string configuration passed as config file. If set, configuration file set in `yamllint.settings.configPath` gets ignored."; - default = ""; - example = '' - --- - - extends: relaxed - - rules: - indentation: enable - ''; - }; - configData = mkOption { - type = types.str; - description = "Serialized YAML object describing the configuration."; - default = ""; - example = "{extends: relaxed, rules: {line-length: {max: 120}}}"; - }; - configPath = mkOption { - type = types.str; - description = "Path to a custom configuration file."; - # An empty string translates to yamllint looking for a configuration file in the - # following locations (by order of preference): - # a file named .yamllint, .yamllint.yaml or .yamllint.yml in the current working directory - # a filename referenced by $YAMLLINT_CONFIG_FILE, if set - # a file named $XDG_CONFIG_HOME/yamllint/config or ~/.config/yamllint/config, if present - default = ""; - }; - format = mkOption { - type = types.enum [ "parsable" "standard" "colored" "github" "auto" ]; - description = "Format for parsing output."; - default = "auto"; - }; - preset = mkOption { - type = types.enum [ "default" "relaxed" ]; - description = "The configuration preset to use."; - default = "default"; - }; - strict = mkOption { - type = types.bool; - description = "Return non-zero exit code on warnings as well as errors."; - default = true; - }; - }; + imports = [ hookModule ./hooks/yamllint.nix ]; }; }; }; diff --git a/modules/hooks/alejandra.nix b/modules/hooks/alejandra.nix new file mode 100644 index 00000000..4520fa37 --- /dev/null +++ b/modules/hooks/alejandra.nix @@ -0,0 +1,36 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + check = + mkOption { + type = types.bool; + description = "Check if the input is already formatted and disable writing in-place the modified content"; + default = false; + example = true; + }; + exclude = + mkOption { + type = types.listOf types.str; + description = "Files or directories to exclude from formatting."; + default = [ ]; + example = [ "flake.nix" "./templates" ]; + }; + threads = + mkOption { + type = types.nullOr types.int; + description = "Number of formatting threads to spawn."; + default = null; + example = 8; + }; + verbosity = + mkOption { + type = types.enum [ "normal" "quiet" "silent" ]; + description = "Whether informational messages or all messages should be hidden or not."; + default = "normal"; + example = "quiet"; + }; + }; +} diff --git a/modules/hooks/ansible-lint.nix b/modules/hooks/ansible-lint.nix new file mode 100644 index 00000000..bd6d60c2 --- /dev/null +++ b/modules/hooks/ansible-lint.nix @@ -0,0 +1,20 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + configPath = mkOption { + type = types.str; + description = "Path to the YAML configuration file."; + # an empty string translates to use default configuration of the + # underlying ansible-lint binary + default = ""; + }; + subdir = mkOption { + type = types.str; + description = "Path to the Ansible subdirectory."; + default = ""; + }; + }; +} diff --git a/modules/hooks/autoflake.nix b/modules/hooks/autoflake.nix new file mode 100644 index 00000000..2e1be5cf --- /dev/null +++ b/modules/hooks/autoflake.nix @@ -0,0 +1,24 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + binPath = + mkOption { + type = types.nullOr types.str; + description = "Path to autoflake binary."; + default = null; + defaultText = lib.literalExpression '' + "''${tools.autoflake}/bin/autoflake" + ''; + }; + + flags = + mkOption { + type = types.str; + description = "Flags passed to autoflake."; + default = "--in-place --expand-star-imports --remove-duplicate-keys --remove-unused-variables"; + }; + }; +} diff --git a/modules/hooks/biome.nix b/modules/hooks/biome.nix new file mode 100644 index 00000000..c9bd8d81 --- /dev/null +++ b/modules/hooks/biome.nix @@ -0,0 +1,39 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + binPath = + mkOption { + type = types.nullOr (types.oneOf [ types.str types.path ]); + description = '' + `biome` binary path. + For example, if you want to use the `biome` binary from `node_modules`, use `"./node_modules/.bin/biome"`. + Use a string instead of a path to avoid having to Git track the file in projects that use Nix flakes. + ''; + default = null; + defaultText = lib.literalExpression '' + "''${tools.biome}/bin/biome" + ''; + example = lib.literalExpression '' + "./node_modules/.bin/biome" + ''; + }; + + write = + mkOption { + type = types.bool; + description = "Whether to edit files inplace."; + default = true; + }; + + configPath = mkOption { + type = types.str; + description = "Path to the configuration JSON file"; + # an empty string translates to use default configuration of the + # underlying biome binary (i.e biome.json if exists) + default = ""; + }; + }; +} diff --git a/modules/hooks/black.nix b/modules/hooks/black.nix new file mode 100644 index 00000000..b2908adc --- /dev/null +++ b/modules/hooks/black.nix @@ -0,0 +1,14 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + flags = mkOption { + type = types.str; + description = "Flags passed to black. See all available [here](https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#command-line-options)."; + default = ""; + example = "--skip-magic-trailing-comma"; + }; + }; +} diff --git a/modules/hooks/cabal2nix.nix b/modules/hooks/cabal2nix.nix new file mode 100644 index 00000000..daef528c --- /dev/null +++ b/modules/hooks/cabal2nix.nix @@ -0,0 +1,14 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + outputFilename = + mkOption { + type = types.str; + description = "The name of the output file generated after running `cabal2nix`."; + default = "default.nix"; + }; + }; +} diff --git a/modules/hooks/clippy.nix b/modules/hooks/clippy.nix new file mode 100644 index 00000000..29974d97 --- /dev/null +++ b/modules/hooks/clippy.nix @@ -0,0 +1,46 @@ +{ config, lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options = { + settings = { + denyWarnings = mkOption { + type = types.bool; + description = "Fail when warnings are present"; + default = false; + }; + offline = mkOption { + type = types.bool; + description = "Run clippy offline"; + default = true; + }; + allFeatures = mkOption { + type = types.bool; + description = "Run clippy with --all-features"; + default = false; + }; + extraArgs = mkOption { + type = types.str; + description = "Additional arguments to pass to clippy"; + default = ""; + }; + }; + + packageOverrides = { + cargo = mkOption { + type = types.package; + description = "The cargo package to use"; + }; + clippy = mkOption { + type = types.package; + description = "The clippy package to use"; + }; + }; + }; + + config.extraPackages = [ + config.packageOverrides.cargo + config.packageOverrides.clippy + ]; +} diff --git a/modules/hooks/cmake-format.nix b/modules/hooks/cmake-format.nix new file mode 100644 index 00000000..e5069ca7 --- /dev/null +++ b/modules/hooks/cmake-format.nix @@ -0,0 +1,14 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + configPath = mkOption { + type = types.str; + description = "Path to the configuration file (.json,.python,.yaml)"; + default = ""; + example = ".cmake-format.json"; + }; + }; +} diff --git a/modules/hooks/credo.nix b/modules/hooks/credo.nix new file mode 100644 index 00000000..f6caaeb1 --- /dev/null +++ b/modules/hooks/credo.nix @@ -0,0 +1,14 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + strict = + mkOption { + type = types.bool; + description = "Whether to auto-promote the changes."; + default = true; + }; + }; +} diff --git a/modules/hooks/deadnix.nix b/modules/hooks/deadnix.nix new file mode 100644 index 00000000..2d618371 --- /dev/null +++ b/modules/hooks/deadnix.nix @@ -0,0 +1,56 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + edit = + mkOption { + type = types.bool; + description = "Remove unused code and write to source file."; + default = false; + }; + + exclude = + mkOption { + type = types.listOf types.str; + description = "Files to exclude from analysis."; + default = [ ]; + }; + + hidden = + mkOption { + type = types.bool; + description = "Recurse into hidden subdirectories and process hidden .*.nix files."; + default = false; + }; + + noLambdaArg = + mkOption { + type = types.bool; + description = "Don't check lambda parameter arguments."; + default = false; + }; + + noLambdaPatternNames = + mkOption { + type = types.bool; + description = "Don't check lambda pattern names (don't break nixpkgs `callPackage`)."; + default = false; + }; + + noUnderscore = + mkOption { + type = types.bool; + description = "Don't check any bindings that start with a `_`."; + default = false; + }; + + quiet = + mkOption { + type = types.bool; + description = "Don't print a dead code report."; + default = false; + }; + }; +} diff --git a/modules/hooks/denofmt.nix b/modules/hooks/denofmt.nix new file mode 100644 index 00000000..20875dbf --- /dev/null +++ b/modules/hooks/denofmt.nix @@ -0,0 +1,22 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + write = + mkOption { + type = types.bool; + description = "Whether to edit files inplace."; + default = true; + }; + configPath = + mkOption { + type = types.str; + description = "Path to the configuration JSON file"; + # an empty string translates to use default configuration of the + # underlying deno binary (i.e deno.json or deno.jsonc) + default = ""; + }; + }; +} diff --git a/modules/hooks/denolint.nix b/modules/hooks/denolint.nix new file mode 100644 index 00000000..1b7d6860 --- /dev/null +++ b/modules/hooks/denolint.nix @@ -0,0 +1,23 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + format = + mkOption { + type = types.enum [ "default" "compact" "json" ]; + description = "Output format."; + default = "default"; + }; + + configPath = + mkOption { + type = types.str; + description = "Path to the configuration JSON file"; + # an empty string translates to use default configuration of the + # underlying deno binary (i.e deno.json or deno.jsonc) + default = ""; + }; + }; +} diff --git a/modules/hooks/dune-fmt.nix b/modules/hooks/dune-fmt.nix new file mode 100644 index 00000000..4c210d0d --- /dev/null +++ b/modules/hooks/dune-fmt.nix @@ -0,0 +1,21 @@ +{ config, lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + auto-promote = mkOption { + type = types.bool; + description = "Whether to auto-promote the changes."; + default = true; + }; + + extraRuntimeInputs = mkOption { + type = types.listOf types.package; + description = "Extra runtimeInputs to add to the environment, eg. `ocamlformat`."; + default = [ ]; + }; + }; + + config.extraPackages = config.settings.extraRuntimeInputs; +} diff --git a/modules/hooks/eclint.nix b/modules/hooks/eclint.nix new file mode 100644 index 00000000..6b1055ba --- /dev/null +++ b/modules/hooks/eclint.nix @@ -0,0 +1,38 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + fix = + mkOption { + type = types.bool; + description = "Modify files in place rather than showing the errors."; + default = false; + }; + summary = + mkOption { + type = types.bool; + description = "Only show number of errors per file."; + default = false; + }; + color = + mkOption { + type = types.enum [ "auto" "always" "never" ]; + description = "When to generate colored output."; + default = "auto"; + }; + exclude = + mkOption { + type = types.listOf types.str; + description = "Filter to exclude files."; + default = [ ]; + }; + verbosity = + mkOption { + type = types.enum [ 0 1 2 3 4 ]; + description = "Log level verbosity"; + default = 0; + }; + }; +} diff --git a/modules/hooks/eslint.nix b/modules/hooks/eslint.nix new file mode 100644 index 00000000..3af6de10 --- /dev/null +++ b/modules/hooks/eslint.nix @@ -0,0 +1,32 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + binPath = + mkOption { + type = types.nullOr (types.oneOf [ types.str types.path ]); + description = '' + `eslint` binary path. + For example, if you want to use the `eslint` binary from `node_modules`, use `"./node_modules/.bin/eslint"`. + Use a string instead of a path to avoid having to Git track the file in projects that use Nix flakes. + ''; + default = null; + defaultText = lib.literalExpression '' + "''${tools.eslint}/bin/eslint" + ''; + example = lib.literalExpression '' + "./node_modules/.bin/eslint" + ''; + }; + + extensions = + mkOption { + type = types.str; + description = + "The pattern of files to run on, see [https://pre-commit.com/#hooks-files](https://pre-commit.com/#hooks-files)."; + default = "\\.js$"; + }; + }; +} diff --git a/modules/hooks/flake8.nix b/modules/hooks/flake8.nix new file mode 100644 index 00000000..d2e388a4 --- /dev/null +++ b/modules/hooks/flake8.nix @@ -0,0 +1,30 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + binPath = + mkOption { + type = types.nullOr types.str; + description = "flake8 binary path. Should be used to specify flake8 binary from your Python environment."; + default = null; + defaultText = lib.literalExpression '' + "''${tools.flake8}/bin/flake8" + ''; + }; + extendIgnore = + mkOption { + type = types.listOf types.str; + description = "List of additional ignore codes"; + default = [ ]; + example = [ "E501" ]; + }; + format = + mkOption { + type = types.str; + description = "Output format."; + default = "default"; + }; + }; +} diff --git a/modules/hooks/flynt.nix b/modules/hooks/flynt.nix new file mode 100644 index 00000000..5b15ea45 --- /dev/null +++ b/modules/hooks/flynt.nix @@ -0,0 +1,74 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + aggressive = + mkOption { + type = types.bool; + description = "Include conversions with potentially changed behavior."; + default = false; + }; + binPath = + mkOption { + type = types.nullOr types.str; + description = "flynt binary path. Can be used to specify the flynt binary from an existing Python environment."; + default = null; + }; + dry-run = + mkOption { + type = types.bool; + description = "Do not change files in-place and print diff instead."; + default = false; + }; + exclude = + mkOption { + type = types.listOf types.str; + description = "Ignore files with given strings in their absolute path."; + default = [ ]; + }; + fail-on-change = + mkOption { + type = types.bool; + description = "Fail when diff is not empty (for linting purposes)."; + default = true; + }; + line-length = + mkOption { + type = types.nullOr types.int; + description = "Convert expressions spanning multiple lines, only if the resulting single line will fit into this line length limit."; + default = null; + }; + no-multiline = + mkOption { + type = types.bool; + description = "Convert only single line expressions."; + default = false; + }; + quiet = + mkOption { + type = types.bool; + description = "Run without output."; + default = false; + }; + string = + mkOption { + type = types.bool; + description = "Interpret the input as a Python code snippet and print the converted version."; + default = false; + }; + transform-concats = + mkOption { + type = types.bool; + description = "Replace string concatenations with f-strings."; + default = false; + }; + verbose = + mkOption { + type = types.bool; + description = "Run with verbose output."; + default = false; + }; + }; +} diff --git a/modules/hooks/fourmolu.nix b/modules/hooks/fourmolu.nix new file mode 100644 index 00000000..3c119e2a --- /dev/null +++ b/modules/hooks/fourmolu.nix @@ -0,0 +1,13 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + defaultExtensions = mkOption { + type = types.listOf types.str; + description = "Haskell language extensions to enable."; + default = [ ]; + }; + }; +} diff --git a/modules/hooks/golines.nix b/modules/hooks/golines.nix new file mode 100644 index 00000000..74df9a1b --- /dev/null +++ b/modules/hooks/golines.nix @@ -0,0 +1,14 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + flags = mkOption { + type = types.str; + description = "Flags passed to golines. See all available [here](https://github.com/segmentio/golines?tab=readme-ov-file#options)"; + default = ""; + example = "-m 120"; + }; + }; +} diff --git a/modules/hooks/headache.nix b/modules/hooks/headache.nix new file mode 100644 index 00000000..98c2d833 --- /dev/null +++ b/modules/hooks/headache.nix @@ -0,0 +1,13 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + header-file = mkOption { + type = types.str; + description = "Path to the header file."; + default = ".header"; + }; + }; +} diff --git a/modules/hooks/hlint.nix b/modules/hooks/hlint.nix new file mode 100644 index 00000000..362e0327 --- /dev/null +++ b/modules/hooks/hlint.nix @@ -0,0 +1,14 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + hintFile = + mkOption { + type = types.nullOr (types.oneOf [ types.str types.path ]); + description = "Path to hlint.yaml. By default, hlint searches for .hlint.yaml in the project root."; + default = null; + }; + }; +} diff --git a/modules/hooks/hpack.nix b/modules/hooks/hpack.nix new file mode 100644 index 00000000..9eb6b828 --- /dev/null +++ b/modules/hooks/hpack.nix @@ -0,0 +1,14 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + silent = + mkOption { + type = types.bool; + description = "Whether generation should be silent."; + default = false; + }; + }; +} diff --git a/modules/hooks/isort.nix b/modules/hooks/isort.nix new file mode 100644 index 00000000..64b76e90 --- /dev/null +++ b/modules/hooks/isort.nix @@ -0,0 +1,20 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + profile = + mkOption { + type = types.enum [ "" "black" "django" "pycharm" "google" "open_stack" "plone" "attrs" "hug" "wemake" "appnexus" ]; + description = "Built-in profiles to allow easy interoperability with common projects and code styles."; + default = ""; + }; + flags = + mkOption { + type = types.str; + description = "Flags passed to isort. See all available [here](https://pycqa.github.io/isort/docs/configuration/options.html)."; + default = ""; + }; + }; +} diff --git a/modules/hooks/lacheck.nix b/modules/hooks/lacheck.nix new file mode 100644 index 00000000..1e6ef53e --- /dev/null +++ b/modules/hooks/lacheck.nix @@ -0,0 +1,20 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + checklevel = mkOption { + type = types.enum [ "Error" "Warning" "Information" "Hint" ]; + description = + "The diagnostic check level"; + default = "Warning"; + }; + configuration = mkOption { + type = types.attrs; + description = + "See https://github.com/LuaLS/lua-language-server/wiki/Configuration-File#luarcjson"; + default = { }; + }; + }; +} diff --git a/modules/hooks/latexindent.nix b/modules/hooks/latexindent.nix new file mode 100644 index 00000000..3159e5fb --- /dev/null +++ b/modules/hooks/latexindent.nix @@ -0,0 +1,14 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + flags = + mkOption { + type = types.str; + description = "Flags passed to latexindent. See available flags [here](https://latexindentpl.readthedocs.io/en/latest/sec-how-to-use.html#from-the-command-line)"; + default = "--local --silent --overwriteIfDifferent"; + }; + }; +} diff --git a/modules/hooks/lua-ls.nix b/modules/hooks/lua-ls.nix new file mode 100644 index 00000000..1e6ef53e --- /dev/null +++ b/modules/hooks/lua-ls.nix @@ -0,0 +1,20 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + checklevel = mkOption { + type = types.enum [ "Error" "Warning" "Information" "Hint" ]; + description = + "The diagnostic check level"; + default = "Warning"; + }; + configuration = mkOption { + type = types.attrs; + description = + "See https://github.com/LuaLS/lua-language-server/wiki/Configuration-File#luarcjson"; + default = { }; + }; + }; +} diff --git a/modules/hooks/lychee.nix b/modules/hooks/lychee.nix new file mode 100644 index 00000000..405dd6cf --- /dev/null +++ b/modules/hooks/lychee.nix @@ -0,0 +1,20 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + configPath = + mkOption { + type = types.str; + description = "Path to the config file."; + default = ""; + }; + flags = + mkOption { + type = types.str; + description = "Flags passed to lychee. See all available [here](https://lychee.cli.rs/#/usage/cli)."; + default = ""; + }; + }; +} diff --git a/modules/hooks/markdownlint.nix b/modules/hooks/markdownlint.nix new file mode 100644 index 00000000..05c35f36 --- /dev/null +++ b/modules/hooks/markdownlint.nix @@ -0,0 +1,15 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + configuration = + mkOption { + type = types.attrs; + description = + "See https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.jsonc"; + default = { }; + }; + }; +} diff --git a/modules/hooks/mdl.nix b/modules/hooks/mdl.nix new file mode 100644 index 00000000..d54e6e48 --- /dev/null +++ b/modules/hooks/mdl.nix @@ -0,0 +1,80 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + configPath = + mkOption { + type = types.str; + description = "The configuration file to use."; + default = ""; + }; + git-recurse = + mkOption { + type = types.bool; + description = "Only process files known to git when given a directory."; + default = false; + }; + ignore-front-matter = + mkOption { + type = types.bool; + description = "Ignore YAML front matter."; + default = false; + }; + json = + mkOption { + type = types.bool; + description = "Format output as JSON."; + default = false; + }; + rules = + mkOption { + type = types.listOf types.str; + description = "Markdown rules to use for linting. Per default all rules are processed."; + default = [ ]; + }; + rulesets = + mkOption { + type = types.listOf types.str; + description = "Specify additional ruleset files to load."; + default = [ ]; + }; + show-aliases = + mkOption { + type = types.bool; + description = "Show rule alias instead of rule ID when viewing rules."; + default = false; + }; + warnings = + mkOption { + type = types.bool; + description = "Show Kramdown warnings."; + default = false; + }; + skip-default-ruleset = + mkOption { + type = types.bool; + description = "Do not load the default markdownlint ruleset. Use this option if you only want to load custom rulesets."; + default = false; + }; + style = + mkOption { + type = types.str; + description = "Select which style mdl uses."; + default = "default"; + }; + tags = + mkOption { + type = types.listOf types.str; + description = "Markdown rules to use for linting containing the given tags. Per default all rules are processed."; + default = [ ]; + }; + verbose = + mkOption { + type = types.bool; + description = "Increase verbosity."; + default = false; + }; + }; +} diff --git a/modules/hooks/mkdocs-linkcheck.nix b/modules/hooks/mkdocs-linkcheck.nix new file mode 100644 index 00000000..6dc7ac66 --- /dev/null +++ b/modules/hooks/mkdocs-linkcheck.nix @@ -0,0 +1,52 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + binPath = + mkOption { + type = types.nullOr (types.oneOf [ types.str types.path ]); + description = "mkdocs-linkcheck binary path. Should be used to specify the mkdocs-linkcheck binary from your Python environment."; + default = null; + defaultText = lib.literalExpression '' + "''${tools.mkdocs-linkcheck}/bin/mkdocs-linkcheck" + ''; + }; + + path = + mkOption { + type = types.str; + description = "Path to check"; + default = ""; + }; + + local-only = + mkOption { + type = types.bool; + description = "Whether to only check local links."; + default = false; + }; + + recurse = + mkOption { + type = types.bool; + description = "Whether to recurse directories under path."; + default = false; + }; + + extension = + mkOption { + type = types.str; + description = "File extension to scan for."; + default = ""; + }; + + method = + mkOption { + type = types.enum [ "get" "head" ]; + description = "HTTP method to use when checking external links."; + default = "get"; + }; + }; +} diff --git a/modules/hooks/mypy.nix b/modules/hooks/mypy.nix new file mode 100644 index 00000000..189022b8 --- /dev/null +++ b/modules/hooks/mypy.nix @@ -0,0 +1,17 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + binPath = + mkOption { + type = types.nullOr types.str; + description = "Mypy binary path. Should be used to specify the mypy executable in an environment containing your typing stubs."; + default = null; + defaultText = lib.literalExpression '' + "''${tools.mypy}/bin/mypy" + ''; + }; + }; +} diff --git a/modules/hooks/nixfmt-classic.nix b/modules/hooks/nixfmt-classic.nix new file mode 100644 index 00000000..c0499a2c --- /dev/null +++ b/modules/hooks/nixfmt-classic.nix @@ -0,0 +1,14 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + width = + mkOption { + type = types.nullOr types.int; + description = "Line width."; + default = null; + }; + }; +} diff --git a/modules/hooks/nixfmt-rfc-style.nix b/modules/hooks/nixfmt-rfc-style.nix new file mode 100644 index 00000000..c0499a2c --- /dev/null +++ b/modules/hooks/nixfmt-rfc-style.nix @@ -0,0 +1,14 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + width = + mkOption { + type = types.nullOr types.int; + description = "Line width."; + default = null; + }; + }; +} diff --git a/modules/hooks/nixfmt.nix b/modules/hooks/nixfmt.nix new file mode 100644 index 00000000..c0499a2c --- /dev/null +++ b/modules/hooks/nixfmt.nix @@ -0,0 +1,14 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + width = + mkOption { + type = types.nullOr types.int; + description = "Line width."; + default = null; + }; + }; +} diff --git a/modules/hooks/no-commit-to-branch.nix b/modules/hooks/no-commit-to-branch.nix new file mode 100644 index 00000000..0d876c8b --- /dev/null +++ b/modules/hooks/no-commit-to-branch.nix @@ -0,0 +1,22 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + branch = + mkOption { + description = "Branches to disallow commits to."; + type = types.listOf types.str; + default = [ "main" ]; + example = [ "main" "master" ]; + }; + pattern = + mkOption { + description = "RegEx patterns for branch names to disallow commits to."; + type = types.listOf types.str; + default = [ ]; + example = [ "ma.*" ]; + }; + }; +} diff --git a/modules/hooks/ormolu.nix b/modules/hooks/ormolu.nix new file mode 100644 index 00000000..45d2d716 --- /dev/null +++ b/modules/hooks/ormolu.nix @@ -0,0 +1,20 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + defaultExtensions = + mkOption { + type = types.listOf types.str; + description = "Haskell language extensions to enable."; + default = [ ]; + }; + cabalDefaultExtensions = + mkOption { + type = types.bool; + description = "Use `default-extensions` from `.cabal` files."; + default = false; + }; + }; +} diff --git a/modules/hooks/php-cs-fixer.nix b/modules/hooks/php-cs-fixer.nix new file mode 100644 index 00000000..bf639a12 --- /dev/null +++ b/modules/hooks/php-cs-fixer.nix @@ -0,0 +1,17 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + binPath = + mkOption { + type = types.nullOr types.str; + description = "PHP-CS-Fixer binary path."; + default = null; + defaultText = lib.literalExpression '' + "''${tools.php-cs-fixer}/bin/php-cs-fixer" + ''; + }; + }; +} diff --git a/modules/hooks/phpcbf.nix b/modules/hooks/phpcbf.nix new file mode 100644 index 00000000..a24475da --- /dev/null +++ b/modules/hooks/phpcbf.nix @@ -0,0 +1,17 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + binPath = + mkOption { + type = types.nullOr types.str; + description = "PHP_CodeSniffer binary path."; + default = null; + defaultText = lib.literalExpression '' + "''${tools.phpcbf}/bin/phpcbf" + ''; + }; + }; +} diff --git a/modules/hooks/phpcs.nix b/modules/hooks/phpcs.nix new file mode 100644 index 00000000..528c40fe --- /dev/null +++ b/modules/hooks/phpcs.nix @@ -0,0 +1,17 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + binPath = + mkOption { + type = types.nullOr types.str; + description = "PHP_CodeSniffer binary path."; + default = null; + defaultText = lib.literalExpression '' + "''${tools.phpcs}/bin/phpcs" + ''; + }; + }; +} diff --git a/modules/hooks/phpstan.nix b/modules/hooks/phpstan.nix new file mode 100644 index 00000000..69fb8302 --- /dev/null +++ b/modules/hooks/phpstan.nix @@ -0,0 +1,17 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + binPath = + mkOption { + type = types.nullOr types.str; + description = "PHPStan binary path."; + default = null; + defaultText = lib.literalExpression '' + "''${tools.phpstan}/bin/phpstan" + ''; + }; + }; +} diff --git a/modules/hooks/prettier.nix b/modules/hooks/prettier.nix new file mode 100644 index 00000000..eb7cf893 --- /dev/null +++ b/modules/hooks/prettier.nix @@ -0,0 +1,249 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + binPath = + mkOption { + description = '' + `prettier` binary path. + For example, if you want to use the `prettier` binary from `node_modules`, use `"./node_modules/.bin/prettier"`. + Use a string instead of a path to avoid having to Git track the file in projects that use Nix flakes. + ''; + type = types.nullOr (types.oneOf [ types.str types.path ]); + default = null; + defaultText = lib.literalExpression '' + "''${tools.prettier}/bin/prettier" + ''; + example = lib.literalExpression '' + "./node_modules/.bin/prettier" + ''; + }; + allow-parens = + mkOption { + description = "Include parentheses around a sole arrow function parameter."; + default = "always"; + type = types.enum [ "always" "avoid" ]; + }; + bracket-same-line = + mkOption { + description = "Put > of opening tags on the last line instead of on a new line."; + type = types.bool; + default = false; + }; + cache = + mkOption { + description = "Only format changed files."; + type = types.bool; + default = false; + }; + cache-location = + mkOption { + description = "Path to the cache file location used by `--cache` flag."; + type = types.str; + default = "./node_modules/.cache/prettier/.prettier-cache"; + }; + cache-strategy = + mkOption { + description = "Strategy for the cache to use for detecting changed files."; + type = types.nullOr (types.enum [ "metadata" "content" ]); + default = null; + }; + check = + mkOption { + description = "Output a human-friendly message and a list of unformatted files, if any."; + type = types.bool; + default = false; + }; + list-different = + mkOption { + description = "Print the filenames of files that are different from Prettier formatting."; + type = types.bool; + default = true; + }; + color = + mkOption { + description = "Colorize error messages."; + type = types.bool; + default = true; + }; + configPath = + mkOption { + description = "Path to a Prettier configuration file (.prettierrc, package.json, prettier.config.js)."; + type = types.str; + default = ""; + }; + config-precedence = + mkOption { + description = "Defines how config file should be evaluated in combination of CLI options."; + type = types.enum [ "cli-override" "file-override" "prefer-file" ]; + default = "cli-override"; + }; + embedded-language-formatting = + mkOption { + description = "Control how Prettier formats quoted code embedded in the file."; + type = types.enum [ "auto" "off" ]; + default = "auto"; + }; + end-of-line = + mkOption { + description = "Which end of line characters to apply."; + type = types.enum [ "lf" "crlf" "cr" "auto" ]; + default = "lf"; + }; + html-whitespace-sensitivity = + mkOption { + description = "How to handle whitespaces in HTML."; + type = types.enum [ "css" "strict" "ignore" ]; + default = "css"; + }; + ignore-path = + mkOption { + description = "Path to a file containing patterns that describe files to ignore. + By default, prettier looks for `./.gitignore` and `./.prettierignore`. + Multiple values are accepted."; + type = types.listOf (types.oneOf [ types.str types.path ]); + default = [ ]; + }; + ignore-unknown = + mkOption { + description = "Ignore unknown files."; + type = types.bool; + default = true; + }; + insert-pragma = + mkOption { + description = "Insert @format pragma into file's first docblock comment."; + type = types.bool; + default = false; + }; + jsx-single-quote = + mkOption { + description = "Use single quotes in JSX."; + type = types.bool; + default = false; + }; + log-level = + mkOption { + description = "What level of logs to report."; + type = types.enum [ "silent" "error" "warn" "log" "debug" ]; + default = "log"; + example = "debug"; + }; + no-bracket-spacing = + mkOption { + description = "Do not print spaces between brackets."; + type = types.bool; + default = false; + }; + no-config = + mkOption { + description = "Do not look for a configuration file."; + type = types.bool; + default = false; + }; + no-editorconfig = + mkOption { + description = "Don't take .editorconfig into account when parsing configuration."; + type = types.bool; + default = false; + }; + no-error-on-unmatched-pattern = + mkOption { + description = "Prevent errors when pattern is unmatched."; + type = types.bool; + default = false; + }; + no-semi = + mkOption { + description = "Do not print semicolons, except at the beginning of lines which may need them."; + type = types.bool; + default = false; + }; + parser = + mkOption { + description = "Which parser to use."; + type = types.enum [ "" "flow" "babel" "babel-flow" "babel-ts" "typescript" "acorn" "espree" "meriyah" "css" "less" "scss" "json" "json5" "json-stringify" "graphql" "markdown" "mdx" "vue" "yaml" "glimmer" "html" "angular" "lwc" ]; + default = ""; + }; + print-width = + mkOption { + type = types.int; + description = "Line length that the printer will wrap on."; + default = 80; + }; + prose-wrap = + mkOption { + description = "When to or if at all hard wrap prose to print width."; + type = types.enum [ "always" "never" "preserve" ]; + default = "preserve"; + }; + plugins = + mkOption { + description = "Add plugins from paths."; + type = types.listOf types.str; + default = [ ]; + }; + quote-props = + mkOption { + description = "Change when properties in objects are quoted."; + type = types.enum [ "as-needed" "consistent" "preserve" ]; + default = "as-needed"; + }; + require-pragma = + mkOption { + description = "Require either '@prettier' or '@format' to be present in the file's first docblock comment."; + type = types.bool; + default = false; + }; + single-attribute-per-line = + mkOption { + description = "Enforce single attribute per line in HTML, Vue andJSX."; + type = types.bool; + default = false; + }; + single-quote = + mkOption { + description = "Number of spaces per indentation-level."; + type = types.bool; + default = false; + }; + tab-width = + mkOption { + description = "Line length that the printer will wrap on."; + type = types.int; + default = 2; + }; + trailing-comma = + mkOption { + description = "Print trailing commas wherever possible in multi-line comma-separated syntactic structures."; + type = types.enum [ "all" "es5" "none" ]; + default = "all"; + }; + use-tabs = + mkOption { + type = types.bool; + description = "Indent with tabs instead of spaces."; + default = false; + }; + vue-indent-script-and-style = + mkOption { + description = "Indent script and style tags in Vue files."; + type = types.bool; + default = false; + }; + with-node-modules = + mkOption { + type = types.bool; + description = "Process files inside 'node_modules' directory."; + default = false; + }; + write = + mkOption { + description = "Edit files in-place."; + type = types.bool; + default = true; + }; + }; +} diff --git a/modules/hooks/pretty-format-json.nix b/modules/hooks/pretty-format-json.nix new file mode 100644 index 00000000..21450200 --- /dev/null +++ b/modules/hooks/pretty-format-json.nix @@ -0,0 +1,38 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + autofix = + mkOption { + type = types.bool; + description = "Automatically format JSON files."; + default = false; + }; + indent = + mkOption { + type = types.nullOr (types.oneOf [ types.int types.str ]); + description = "Control the indentation (either a number for a number of spaces or a string of whitespace). Defaults to 2 spaces."; + default = null; + }; + no-ensure-ascii = + mkOption { + type = types.bool; + description = "Preserve unicode characters instead of converting to escape sequences."; + default = false; + }; + no-sort-keys = + mkOption { + type = types.bool; + description = "When autofixing, retain the original key ordering (instead of sorting the keys)."; + default = false; + }; + top-keys = + mkOption { + type = types.listOf types.str; + description = "Keys to keep at the top of mappings."; + default = [ ]; + }; + }; +} diff --git a/modules/hooks/proselint.nix b/modules/hooks/proselint.nix new file mode 100644 index 00000000..ebf13bde --- /dev/null +++ b/modules/hooks/proselint.nix @@ -0,0 +1,33 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + config = + mkOption { + type = types.str; + description = "Multiline-string configuration passed as config file."; + default = ""; + example = '' + { + "checks": { + "typography.diacritical_marks": false + } + } + ''; + }; + configPath = + mkOption { + type = types.str; + description = "Path to the config file."; + default = ""; + }; + flags = + mkOption { + type = types.str; + description = "Flags passed to proselint."; + default = ""; + }; + }; +} diff --git a/modules/hooks/psalm.nix b/modules/hooks/psalm.nix new file mode 100644 index 00000000..5ff49bd0 --- /dev/null +++ b/modules/hooks/psalm.nix @@ -0,0 +1,17 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + binPath = + mkOption { + type = types.nullOr types.str; + description = "Psalm binary path."; + default = null; + defaultText = lib.literalExpression '' + "''${tools.psalm}/bin/psalm" + ''; + }; + }; +} diff --git a/modules/hooks/pylint.nix b/modules/hooks/pylint.nix new file mode 100644 index 00000000..3328cd10 --- /dev/null +++ b/modules/hooks/pylint.nix @@ -0,0 +1,29 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + binPath = + mkOption { + type = types.nullOr types.str; + description = "Pylint binary path. Should be used to specify Pylint binary from your Python environment."; + default = null; + defaultText = lib.literalExpression '' + "''${tools.pylint}/bin/pylint" + ''; + }; + reports = + mkOption { + type = types.bool; + description = "Whether to display a full report."; + default = false; + }; + score = + mkOption { + type = types.bool; + description = "Whether to activate the evaluation score."; + default = true; + }; + }; +} diff --git a/modules/hooks/pyright.nix b/modules/hooks/pyright.nix new file mode 100644 index 00000000..2cf3cdd3 --- /dev/null +++ b/modules/hooks/pyright.nix @@ -0,0 +1,17 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + binPath = + mkOption { + type = types.nullOr types.str; + description = "Pyright binary path. Should be used to specify the pyright executable in an environment containing your typing stubs."; + default = null; + defaultText = lib.literalExpression '' + "''${tools.pyright}/bin/pyright" + ''; + }; + }; +} diff --git a/modules/hooks/pyupgrade.nix b/modules/hooks/pyupgrade.nix new file mode 100644 index 00000000..699635f2 --- /dev/null +++ b/modules/hooks/pyupgrade.nix @@ -0,0 +1,17 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + binPath = + mkOption { + type = types.nullOr types.str; + description = "pyupgrade binary path. Should be used to specify the pyupgrade binary from your Python environment."; + default = null; + defaultText = lib.literalExpression '' + "''${tools.pyupgrade}/bin/pyupgrade" + ''; + }; + }; +} diff --git a/modules/hooks/reuse.nix b/modules/hooks/reuse.nix new file mode 100644 index 00000000..6e3e007b --- /dev/null +++ b/modules/hooks/reuse.nix @@ -0,0 +1,14 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + flags = mkOption { + type = types.str; + description = "Flags passed to reuse. For available options run 'reuse lint --help'"; + default = ""; + example = "--json"; + }; + }; +} diff --git a/modules/hooks/revive.nix b/modules/hooks/revive.nix new file mode 100644 index 00000000..812c9097 --- /dev/null +++ b/modules/hooks/revive.nix @@ -0,0 +1,16 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + configPath = + mkOption { + type = types.str; + description = "Path to the configuration TOML file."; + # an empty string translates to use default configuration of the + # underlying revive binary + default = ""; + }; + }; +} diff --git a/modules/hooks/ripsecrets.nix b/modules/hooks/ripsecrets.nix new file mode 100644 index 00000000..19a8712a --- /dev/null +++ b/modules/hooks/ripsecrets.nix @@ -0,0 +1,14 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + additionalPatterns = + mkOption { + type = types.listOf types.str; + description = "Additional regex patterns used to find secrets. If there is a matching group in the regex the matched group will be tested for randomness before being reported as a secret."; + default = [ ]; + }; + }; +} diff --git a/modules/hooks/rome.nix b/modules/hooks/rome.nix new file mode 100644 index 00000000..47fdf082 --- /dev/null +++ b/modules/hooks/rome.nix @@ -0,0 +1,39 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + binPath = + mkOption { + type = types.nullOr (types.oneOf [ types.str types.path ]); + description = '' + `rome` binary path. + For example, if you want to use the `rome` binary from `node_modules`, use `"./node_modules/.bin/rome"`. + Use a string instead of a path to avoid having to Git track the file in projects that use Nix flakes. + ''; + default = null; + defaultText = lib.literalExpression '' + "''${tools.rome}/bin/rome + ''; + example = lib.literalExpression '' + "./node_modules/.bin/rome" + ''; + }; + + write = + mkOption { + type = types.bool; + description = "Whether to edit files inplace."; + default = true; + }; + + configPath = mkOption { + type = types.str; + description = "Path to the configuration JSON file"; + # an empty string translates to use default configuration of the + # underlying biome binary (i.e biome.json if exists) + default = ""; + }; + }; +} diff --git a/modules/hooks/rustfmt.nix b/modules/hooks/rustfmt.nix new file mode 100644 index 00000000..afac2af3 --- /dev/null +++ b/modules/hooks/rustfmt.nix @@ -0,0 +1,89 @@ +{ lib, config, rustSettings, ... }: +let + inherit (lib) mkOption types; + nameType = types.strMatching "[][*?!0-9A-Za-z_-]+"; +in +{ + options = { + packageOverrides = { + cargo = mkOption { + type = types.package; + description = "The cargo package to use."; + }; + rustfmt = mkOption { + type = types.package; + description = "The rustfmt package to use."; + }; + }; + + settings = { + all = mkOption { + type = types.bool; + description = "Format all packages, and also their local path-based dependencies"; + default = true; + }; + check = mkOption { + type = types.bool; + description = "Run rustfmt in check mode"; + default = false; + }; + color = mkOption { + type = types.enum [ "auto" "always" "never" ]; + description = "Coloring the output"; + default = "always"; + }; + config = mkOption { + type = types.attrs; + description = "Override configuration values"; + default = { }; + apply = config: + let + config' = lib.mapAttrsToList + (key: value: "${key}=${toString value}") + config; + in + if config == { } then "" else "--config=${lib.concatStringsSep "," config'}"; + }; + config-path = mkOption { + type = types.nullOr types.str; + description = "Path to the configuration file"; + default = null; + }; + emit = mkOption { + type = types.enum [ "files" "stdout" "coverage" "checkstyle" "json" ]; + description = "What data to emit and how"; + default = "files"; + }; + files-with-diff = mkOption { + type = types.bool; + description = "Print the names of mismatched files that were formatted. Prints the names of files that would be formatted when used with `--check` mode"; + default = config.settings.message-format == "short"; + }; + manifest-path = mkOption { + type = types.nullOr types.str; + description = "Path to Cargo.toml"; + default = rustSettings.cargoManifestPath; + }; + message-format = mkOption { + type = types.nullOr (types.enum [ "human" "short" ]); + description = "The output format of diagnostic messages"; + default = null; + }; + package = mkOption { + type = types.listOf nameType; + description = "Package(s) to check"; + default = [ ]; + }; + verbose = mkOption { + type = types.bool; + description = "Use verbose output"; + default = false; + }; + }; + }; + + config.extraPackages = [ + config.packageOverrides.cargo + config.packageOverrides.rustfmt + ]; +} diff --git a/modules/hooks/shfmt.nix b/modules/hooks/shfmt.nix new file mode 100644 index 00000000..709eaa1e --- /dev/null +++ b/modules/hooks/shfmt.nix @@ -0,0 +1,13 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + simplify = mkOption { + type = types.bool; + description = "Simplify the code."; + default = true; + }; + }; +} diff --git a/modules/hooks/sort-file-contents.nix b/modules/hooks/sort-file-contents.nix new file mode 100644 index 00000000..03350464 --- /dev/null +++ b/modules/hooks/sort-file-contents.nix @@ -0,0 +1,20 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + ignore-case = + mkOption { + type = types.bool; + description = "Fold lower case to upper case characters."; + default = false; + }; + unique = + mkOption { + type = types.bool; + description = "Ensure each line is unique."; + default = false; + }; + }; +} diff --git a/modules/hooks/statix.nix b/modules/hooks/statix.nix new file mode 100644 index 00000000..172d4752 --- /dev/null +++ b/modules/hooks/statix.nix @@ -0,0 +1,37 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + config = + mkOption { + type = types.nullOr types.str; + description = "Path to statix.toml or its parent directory."; + default = null; + }; + + format = + mkOption { + type = types.enum [ "stderr" "errfmt" "json" ]; + description = "Error Output format."; + default = "errfmt"; + }; + + ignore = + mkOption { + type = types.listOf types.str; + description = "Globs of file patterns to skip."; + default = [ ]; + example = [ "flake.nix" "_*" ]; + }; + + unrestricted = + mkOption { + type = types.bool; + description = "Don't respect .gitignore files."; + default = false; + example = true; + }; + }; +} diff --git a/modules/hooks/treefmt.nix b/modules/hooks/treefmt.nix new file mode 100644 index 00000000..9de595ee --- /dev/null +++ b/modules/hooks/treefmt.nix @@ -0,0 +1,34 @@ +{ config, lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options = { + packageOverrides = { + treefmt = mkOption { + type = types.package; + description = "The treefmt package to use"; + }; + }; + + settings = { + fail-on-change = mkOption { + type = types.bool; + description = "Fail if some files require re-formatting."; + default = true; + }; + no-cache = mkOption { + type = types.bool; + description = "Ignore the evaluation cache entirely."; + default = true; + }; + formatters = mkOption { + type = types.listOf types.package; + description = "The formatter packages configured by treefmt"; + default = [ ]; + }; + }; + }; + + config.extraPackages = config.settings.formatters; +} diff --git a/modules/hooks/typos.nix b/modules/hooks/typos.nix new file mode 100644 index 00000000..9d73f5ab --- /dev/null +++ b/modules/hooks/typos.nix @@ -0,0 +1,133 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + binary = + mkOption { + type = types.bool; + description = "Whether to search binary files."; + default = false; + }; + color = + mkOption { + type = types.enum [ "auto" "always" "never" ]; + description = "When to use generate output."; + default = "auto"; + }; + configuration = + mkOption { + type = types.str; + description = "Multiline-string configuration passed as config file. If set, config set in `typos.settings.configPath` gets ignored."; + default = ""; + example = '' + [files] + ignore-dot = true + + [default] + binary = false + + [type.py] + extend-glob = [] + ''; + }; + + configPath = + mkOption { + type = types.str; + description = "Path to a custom config file."; + default = ""; + example = ".typos.toml"; + }; + + diff = + mkOption { + type = types.bool; + description = "Print a diff of what would change."; + default = false; + }; + + exclude = + mkOption { + type = types.str; + description = "Ignore files and directories matching the glob."; + default = ""; + example = "*.nix"; + }; + + format = + mkOption { + type = types.enum [ "silent" "brief" "long" "json" ]; + description = "Output format to use."; + default = "long"; + }; + + hidden = + mkOption { + type = types.bool; + description = "Search hidden files and directories."; + default = false; + }; + + ignored-words = + mkOption { + type = types.listOf types.str; + description = "Spellings and words to ignore."; + default = [ ]; + example = [ + "MQTT" + "mosquitto" + ]; + }; + + locale = + mkOption { + type = types.enum [ "en" "en-us" "en-gb" "en-ca" "en-au" ]; + description = "Which language to use for spell checking."; + default = "en"; + }; + + no-check-filenames = + mkOption { + type = types.bool; + description = "Skip verifying spelling in file names."; + default = false; + }; + + no-check-files = + mkOption { + type = types.bool; + description = "Skip verifying spelling in files."; + default = false; + }; + + no-unicode = + mkOption { + type = types.bool; + description = "Only allow ASCII characters in identifiers."; + default = false; + }; + + quiet = + mkOption { + type = types.bool; + description = "Less output per occurrence."; + default = false; + }; + + verbose = + mkOption { + type = types.bool; + description = "More output per occurrence."; + default = false; + }; + + write = + mkOption { + type = types.bool; + description = "Fix spelling in files by writing them. Cannot be used with `typos.settings.diff`."; + default = false; + }; + }; +} diff --git a/modules/hooks/vale.nix b/modules/hooks/vale.nix new file mode 100644 index 00000000..f088fbb3 --- /dev/null +++ b/modules/hooks/vale.nix @@ -0,0 +1,31 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + configuration = + mkOption { + type = types.str; + description = "Multiline-string configuration passed as config file."; + default = ""; + example = '' + MinAlertLevel = suggestion + [*] + BasedOnStyles = Vale + ''; + }; + configPath = + mkOption { + type = types.str; + description = "Path to the config file."; + default = ""; + }; + flags = + mkOption { + type = types.str; + description = "Flags passed to vale."; + default = ""; + }; + }; +} diff --git a/modules/hooks/yamlfmt.nix b/modules/hooks/yamlfmt.nix new file mode 100644 index 00000000..25389053 --- /dev/null +++ b/modules/hooks/yamlfmt.nix @@ -0,0 +1,25 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + configPath = + mkOption { + type = types.str; + description = "Path to a custom configuration file."; + # An empty string translates to yamlfmt looking for a configuration file in the + # following locations (by order of preference): + # a file named .yamlfmt, yamlfmt.yml, yamlfmt.yaml, .yamlfmt.yaml or .yamlfmt.yml in the current working directory + # See details [here](https://github.com/google/yamlfmt/blob/main/docs/config-file.md#config-file-discovery) + default = ""; + example = ".yamlfmt"; + }; + lint-only = + mkOption { + type = types.bool; + description = "Only lint the files, do not format them in place."; + default = true; + }; + }; +} diff --git a/modules/hooks/yamllint.nix b/modules/hooks/yamllint.nix new file mode 100644 index 00000000..50d2b6b7 --- /dev/null +++ b/modules/hooks/yamllint.nix @@ -0,0 +1,55 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.settings = { + # `list-files` is not useful for a pre-commit hook as it always exits with exit code 0 + # `no-warnings` is not useful for a pre-commit hook as it exits with exit code 2 and the hook + # therefore fails when warnings level problems are detected but there is no output + configuration = mkOption { + type = types.str; + description = "Multiline-string configuration passed as config file. If set, configuration file set in `yamllint.settings.configPath` gets ignored."; + default = ""; + example = '' + --- + + extends: relaxed + + rules: + indentation: enable + ''; + }; + configData = mkOption { + type = types.str; + description = "Serialized YAML object describing the configuration."; + default = ""; + example = "{extends: relaxed, rules: {line-length: {max: 120}}}"; + }; + configPath = mkOption { + type = types.str; + description = "Path to a custom configuration file."; + # An empty string translates to yamllint looking for a configuration file in the + # following locations (by order of preference): + # a file named .yamllint, .yamllint.yaml or .yamllint.yml in the current working directory + # a filename referenced by $YAMLLINT_CONFIG_FILE, if set + # a file named $XDG_CONFIG_HOME/yamllint/config or ~/.config/yamllint/config, if present + default = ""; + }; + format = mkOption { + type = types.enum [ "parsable" "standard" "colored" "github" "auto" ]; + description = "Format for parsing output."; + default = "auto"; + }; + preset = mkOption { + type = types.enum [ "default" "relaxed" ]; + description = "The configuration preset to use."; + default = "default"; + }; + strict = mkOption { + type = types.bool; + description = "Return non-zero exit code on warnings as well as errors."; + default = true; + }; + }; +} From c126bf681090dfbe0d5f10b47fb01c6bcdc734d2 Mon Sep 17 00:00:00 2001 From: Sander Date: Sun, 25 May 2025 23:41:52 +0200 Subject: [PATCH 02/13] rome: fix typo in docs --- modules/hooks/rome.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hooks/rome.nix b/modules/hooks/rome.nix index 47fdf082..ba743dd4 100644 --- a/modules/hooks/rome.nix +++ b/modules/hooks/rome.nix @@ -14,7 +14,7 @@ in ''; default = null; defaultText = lib.literalExpression '' - "''${tools.rome}/bin/rome + "''${tools.rome}/bin/rome" ''; example = lib.literalExpression '' "./node_modules/.bin/rome" From d59536a99dba3b83cdadd32724a039aec8b755c0 Mon Sep 17 00:00:00 2001 From: Sander Date: Mon, 26 May 2025 00:37:50 +0200 Subject: [PATCH 03/13] hooks: migrate pre-configured hook implementations to their modules --- modules/hooks.nix | 2227 ++--------------- modules/hooks/actionlint.nix | 11 + modules/hooks/alejandra.nix | 30 +- modules/hooks/annex.nix | 9 + modules/hooks/ansible-lint.nix | 26 +- modules/hooks/autoflake.nix | 19 +- modules/hooks/bats.nix | 11 + modules/hooks/beautysh.nix | 10 + modules/hooks/biome.nix | 33 +- modules/hooks/black.nix | 10 +- modules/hooks/cabal-fmt.nix | 10 + modules/hooks/cabal-gild.nix | 18 + modules/hooks/cabal2nix.nix | 11 +- modules/hooks/cargo-check.nix | 18 + modules/hooks/check-added-large-files.nix | 10 + modules/hooks/check-builtin-literals.nix | 10 + modules/hooks/check-case-conflicts.nix | 10 + modules/hooks/check-docstring-first.nix | 10 + .../hooks/check-executables-have-shebangs.nix | 11 + modules/hooks/check-json.nix | 10 + modules/hooks/check-merge-conflicts.nix | 10 + modules/hooks/check-python.nix | 10 + .../check-shebang-scripts-are-executable.nix | 11 + modules/hooks/check-symlinks.nix | 10 + modules/hooks/check-toml.nix | 10 + modules/hooks/check-vcs-permalinks.nix | 10 + modules/hooks/check-xml.nix | 10 + modules/hooks/check-yaml.nix | 10 + modules/hooks/checkmake.nix | 16 + modules/hooks/chktex.nix | 10 + modules/hooks/circleci.nix | 24 + modules/hooks/clang-format.nix | 22 + modules/hooks/clang-tidy.nix | 10 + modules/hooks/clippy.nix | 35 +- modules/hooks/cljfmt.nix | 10 + modules/hooks/cmake-format.nix | 18 +- modules/hooks/commitizen.nix | 12 + modules/hooks/conform.nix | 10 + modules/hooks/convco.nix | 20 + modules/hooks/credo.nix | 12 +- modules/hooks/crystal.nix | 10 + modules/hooks/cspell.nix | 10 + modules/hooks/dart-analyze.nix | 10 + modules/hooks/dart-format.nix | 10 + modules/hooks/deadnix.nix | 32 +- modules/hooks/denofmt.nix | 27 +- modules/hooks/denolint.nix | 28 +- modules/hooks/detect-aws-credentials.nix | 10 + modules/hooks/detect-private-keys.nix | 10 + modules/hooks/dhall-format.nix | 10 + modules/hooks/dialyzer.nix | 10 + modules/hooks/dune-opam-sync.nix | 14 + modules/hooks/eclint.nix | 31 +- modules/hooks/editorconfig-checker.nix | 10 + modules/hooks/elm-format.nix | 10 + modules/hooks/elm-review.nix | 11 + modules/hooks/elm-test.nix | 11 + modules/hooks/end-of-file-fixer.nix | 10 + modules/hooks/eslint.nix | 19 +- modules/hooks/fix-byte-order-marker.nix | 10 + modules/hooks/fix-encoding-pragma.nix | 10 + modules/hooks/flake-checker.nix | 11 + modules/hooks/flake8.nix | 24 +- modules/hooks/flynt.nix | 41 +- modules/hooks/forbid-new-submodules.nix | 10 + modules/hooks/fourmolu.nix | 13 +- modules/hooks/fprettify.nix | 10 + modules/hooks/gitlint.nix | 10 + modules/hooks/gofmt.nix | 27 + modules/hooks/golangci-lint.nix | 22 + modules/hooks/golines.nix | 27 +- modules/hooks/gotest.nix | 44 + modules/hooks/govet.nix | 23 + modules/hooks/gptcommit.nix | 19 + modules/hooks/hadolint.nix | 10 + modules/hooks/headache.nix | 18 +- modules/hooks/hindent.nix | 10 + modules/hooks/html-tidy.nix | 10 + modules/hooks/hunspell.nix | 10 + modules/hooks/juliaformatter.nix | 11 + modules/hooks/luacheck.nix | 10 + modules/hooks/mdformat.nix | 10 + modules/hooks/mdsh.nix | 11 + modules/hooks/mix-format.nix | 10 + modules/hooks/mix-test.nix | 11 + modules/hooks/mixed-line-endings.nix | 10 + modules/hooks/name-tests-test.nix | 10 + modules/hooks/nil.nix | 10 + modules/hooks/nixpkgs-fmt.nix | 10 + modules/hooks/ocp-indent.nix | 10 + modules/hooks/opam-lint.nix | 10 + modules/hooks/openapi-spec-validator.nix | 10 + modules/hooks/poetry-check.nix | 11 + modules/hooks/poetry-lock.nix | 11 + modules/hooks/pre-commit-hook-ensure-sops.nix | 10 + modules/hooks/purs-tidy.nix | 10 + modules/hooks/python-debug-statements.nix | 10 + modules/hooks/rome.nix | 19 +- modules/hooks/ruff-format.nix | 11 + modules/hooks/ruff.nix | 11 + modules/hooks/selene.nix | 10 + modules/hooks/shellcheck.nix | 10 + modules/hooks/single-quoted-strings.nix | 10 + modules/hooks/sort-requirements-txt.nix | 10 + modules/hooks/sort-simple-yaml.nix | 10 + modules/hooks/staticcheck.nix | 11 + modules/hooks/stylish-haskell.nix | 10 + modules/hooks/stylua.nix | 10 + modules/hooks/tagref.nix | 11 + modules/hooks/taplo.nix | 10 + modules/hooks/terraform-format.nix | 10 + modules/hooks/terraform-validate.nix | 10 + modules/hooks/tflint.nix | 10 + modules/hooks/topiary.nix | 10 + modules/hooks/trim-trailing-whitespace.nix | 10 + modules/hooks/trufflehog.nix | 16 + modules/hooks/typstfmt.nix | 10 + modules/hooks/typstyle.nix | 10 + modules/hooks/zprint.nix | 10 + 119 files changed, 1755 insertions(+), 2095 deletions(-) create mode 100644 modules/hooks/actionlint.nix create mode 100644 modules/hooks/annex.nix create mode 100644 modules/hooks/bats.nix create mode 100644 modules/hooks/beautysh.nix create mode 100644 modules/hooks/cabal-fmt.nix create mode 100644 modules/hooks/cabal-gild.nix create mode 100644 modules/hooks/cargo-check.nix create mode 100644 modules/hooks/check-added-large-files.nix create mode 100644 modules/hooks/check-builtin-literals.nix create mode 100644 modules/hooks/check-case-conflicts.nix create mode 100644 modules/hooks/check-docstring-first.nix create mode 100644 modules/hooks/check-executables-have-shebangs.nix create mode 100644 modules/hooks/check-json.nix create mode 100644 modules/hooks/check-merge-conflicts.nix create mode 100644 modules/hooks/check-python.nix create mode 100644 modules/hooks/check-shebang-scripts-are-executable.nix create mode 100644 modules/hooks/check-symlinks.nix create mode 100644 modules/hooks/check-toml.nix create mode 100644 modules/hooks/check-vcs-permalinks.nix create mode 100644 modules/hooks/check-xml.nix create mode 100644 modules/hooks/check-yaml.nix create mode 100644 modules/hooks/checkmake.nix create mode 100644 modules/hooks/chktex.nix create mode 100644 modules/hooks/circleci.nix create mode 100644 modules/hooks/clang-format.nix create mode 100644 modules/hooks/clang-tidy.nix create mode 100644 modules/hooks/cljfmt.nix create mode 100644 modules/hooks/commitizen.nix create mode 100644 modules/hooks/conform.nix create mode 100644 modules/hooks/convco.nix create mode 100644 modules/hooks/crystal.nix create mode 100644 modules/hooks/cspell.nix create mode 100644 modules/hooks/dart-analyze.nix create mode 100644 modules/hooks/dart-format.nix create mode 100644 modules/hooks/detect-aws-credentials.nix create mode 100644 modules/hooks/detect-private-keys.nix create mode 100644 modules/hooks/dhall-format.nix create mode 100644 modules/hooks/dialyzer.nix create mode 100644 modules/hooks/dune-opam-sync.nix create mode 100644 modules/hooks/editorconfig-checker.nix create mode 100644 modules/hooks/elm-format.nix create mode 100644 modules/hooks/elm-review.nix create mode 100644 modules/hooks/elm-test.nix create mode 100644 modules/hooks/end-of-file-fixer.nix create mode 100644 modules/hooks/fix-byte-order-marker.nix create mode 100644 modules/hooks/fix-encoding-pragma.nix create mode 100644 modules/hooks/flake-checker.nix create mode 100644 modules/hooks/forbid-new-submodules.nix create mode 100644 modules/hooks/fprettify.nix create mode 100644 modules/hooks/gitlint.nix create mode 100644 modules/hooks/gofmt.nix create mode 100644 modules/hooks/golangci-lint.nix create mode 100644 modules/hooks/gotest.nix create mode 100644 modules/hooks/govet.nix create mode 100644 modules/hooks/gptcommit.nix create mode 100644 modules/hooks/hadolint.nix create mode 100644 modules/hooks/hindent.nix create mode 100644 modules/hooks/html-tidy.nix create mode 100644 modules/hooks/hunspell.nix create mode 100644 modules/hooks/juliaformatter.nix create mode 100644 modules/hooks/luacheck.nix create mode 100644 modules/hooks/mdformat.nix create mode 100644 modules/hooks/mdsh.nix create mode 100644 modules/hooks/mix-format.nix create mode 100644 modules/hooks/mix-test.nix create mode 100644 modules/hooks/mixed-line-endings.nix create mode 100644 modules/hooks/name-tests-test.nix create mode 100644 modules/hooks/nil.nix create mode 100644 modules/hooks/nixpkgs-fmt.nix create mode 100644 modules/hooks/ocp-indent.nix create mode 100644 modules/hooks/opam-lint.nix create mode 100644 modules/hooks/openapi-spec-validator.nix create mode 100644 modules/hooks/poetry-check.nix create mode 100644 modules/hooks/poetry-lock.nix create mode 100644 modules/hooks/pre-commit-hook-ensure-sops.nix create mode 100644 modules/hooks/purs-tidy.nix create mode 100644 modules/hooks/python-debug-statements.nix create mode 100644 modules/hooks/ruff-format.nix create mode 100644 modules/hooks/ruff.nix create mode 100644 modules/hooks/selene.nix create mode 100644 modules/hooks/shellcheck.nix create mode 100644 modules/hooks/single-quoted-strings.nix create mode 100644 modules/hooks/sort-requirements-txt.nix create mode 100644 modules/hooks/sort-simple-yaml.nix create mode 100644 modules/hooks/staticcheck.nix create mode 100644 modules/hooks/stylish-haskell.nix create mode 100644 modules/hooks/stylua.nix create mode 100644 modules/hooks/tagref.nix create mode 100644 modules/hooks/taplo.nix create mode 100644 modules/hooks/terraform-format.nix create mode 100644 modules/hooks/terraform-validate.nix create mode 100644 modules/hooks/tflint.nix create mode 100644 modules/hooks/topiary.nix create mode 100644 modules/hooks/trim-trailing-whitespace.nix create mode 100644 modules/hooks/trufflehog.nix create mode 100644 modules/hooks/typstfmt.nix create mode 100644 modules/hooks/typstyle.nix create mode 100644 modules/hooks/zprint.nix diff --git a/modules/hooks.nix b/modules/hooks.nix index 002fe2eb..d65041f7 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -85,12 +85,24 @@ in # PLEASE keep this sorted alphabetically. options.hooks = { + actionlint = mkOption { + description = "actionlint hook"; + type = types.submodule { + imports = [ hookModule ./hooks/actionlint.nix ]; + }; + }; alejandra = mkOption { description = "alejandra hook"; type = types.submodule { imports = [ hookModule ./hooks/alejandra.nix ]; }; }; + annex = mkOption { + description = "annex hook"; + type = types.submodule { + imports = [ hookModule ./hooks/annex.nix ]; + }; + }; ansible-lint = mkOption { description = "ansible-lint hook"; type = types.submodule { @@ -103,6 +115,18 @@ in imports = [ hookModule ./hooks/autoflake.nix ]; }; }; + bats = mkOption { + description = "bats hook"; + type = types.submodule { + imports = [ hookModule ./hooks/bats.nix ]; + }; + }; + beautysh = mkOption { + description = "beautysh hook"; + type = types.submodule { + imports = [ hookModule ./hooks/beautysh.nix ]; + }; + }; biome = mkOption { description = "biome hook"; type = types.submodule { @@ -115,12 +139,144 @@ in imports = [ hookModule ./hooks/black.nix ]; }; }; + cabal-fmt = mkOption { + description = "cabal-fmt hook"; + type = types.submodule { + imports = [ hookModule ./hooks/cabal-fmt.nix ]; + }; + }; + cabal-gild = mkOption { + description = "cabal-gild hook"; + type = types.submodule { + imports = [ hookModule ./hooks/cabal-gild.nix ]; + }; + }; cabal2nix = mkOption { description = "cabal2nix hook"; type = types.submodule { imports = [ hookModule ./hooks/cabal2nix.nix ]; }; }; + cargo-check = mkOption { + description = "cargo-check hook"; + type = types.submodule { + imports = [ hookModule ./hooks/cargo-check.nix ]; + }; + }; + check-added-large-files = mkOption { + description = "check-added-large-files hook"; + type = types.submodule { + imports = [ hookModule ./hooks/check-added-large-files.nix ]; + }; + }; + check-builtin-literals = mkOption { + description = "check-builtin-literals hook"; + type = types.submodule { + imports = [ hookModule ./hooks/check-builtin-literals.nix ]; + }; + }; + check-case-conflicts = mkOption { + description = "check-case-conflicts hook"; + type = types.submodule { + imports = [ hookModule ./hooks/check-case-conflicts.nix ]; + }; + }; + check-docstring-first = mkOption { + description = "check-docstring-first hook"; + type = types.submodule { + imports = [ hookModule ./hooks/check-docstring-first.nix ]; + }; + }; + check-executables-have-shebangs = mkOption { + description = "check-executables-have-shebangs hook"; + type = types.submodule { + imports = [ hookModule ./hooks/check-executables-have-shebangs.nix ]; + }; + }; + check-json = mkOption { + description = "check-json hook"; + type = types.submodule { + imports = [ hookModule ./hooks/check-json.nix ]; + }; + }; + check-merge-conflicts = mkOption { + description = "check-merge-conflicts hook"; + type = types.submodule { + imports = [ hookModule ./hooks/check-merge-conflicts.nix ]; + }; + }; + check-python = mkOption { + description = "check-python hook"; + type = types.submodule { + imports = [ hookModule ./hooks/check-python.nix ]; + }; + }; + check-shebang-scripts-are-executable = mkOption { + description = "check-shebang-scripts-are-executable hook"; + type = types.submodule { + imports = [ hookModule ./hooks/check-shebang-scripts-are-executable.nix ]; + }; + }; + check-symlinks = mkOption { + description = "check-symlinks hook"; + type = types.submodule { + imports = [ hookModule ./hooks/check-symlinks.nix ]; + }; + }; + check-toml = mkOption { + description = "check-toml hook"; + type = types.submodule { + imports = [ hookModule ./hooks/check-toml.nix ]; + }; + }; + check-vcs-permalinks = mkOption { + description = "check-vcs-permalinks hook"; + type = types.submodule { + imports = [ hookModule ./hooks/check-vcs-permalinks.nix ]; + }; + }; + check-xml = mkOption { + description = "check-xml hook"; + type = types.submodule { + imports = [ hookModule ./hooks/check-xml.nix ]; + }; + }; + check-yaml = mkOption { + description = "check-yaml hook"; + type = types.submodule { + imports = [ hookModule ./hooks/check-yaml.nix ]; + }; + }; + checkmake = mkOption { + description = "checkmake hook"; + type = types.submodule { + imports = [ hookModule ./hooks/checkmake.nix ]; + }; + }; + chktex = mkOption { + description = "chktex hook"; + type = types.submodule { + imports = [ hookModule ./hooks/chktex.nix ]; + }; + }; + circleci = mkOption { + description = "circleci hook"; + type = types.submodule { + imports = [ hookModule ./hooks/circleci.nix ]; + }; + }; + clang-format = mkOption { + description = "clang-format hook"; + type = types.submodule { + imports = [ hookModule ./hooks/clang-format.nix ]; + }; + }; + clang-tidy = mkOption { + description = "clang-tidy hook"; + type = types.submodule { + imports = [ hookModule ./hooks/clang-tidy.nix ]; + }; + }; clippy = mkOption { description = "clippy hook"; type = types.submodule { @@ -488,2075 +644,4 @@ in The new RFC 166-style nixfmt is available as `hooks.nixfmt-rfc-style`. ''; - - # PLEASE keep this sorted alphabetically. - config.hooks = mapAttrs (_: mapAttrs (_: mkDefault)) - rec { - actionlint = - { - name = "actionlint"; - description = "Static checker for GitHub Actions workflow files"; - files = "^.github/workflows/"; - types = [ "yaml" ]; - package = tools.actionlint; - entry = "${hooks.actionlint.package}/bin/actionlint"; - }; - alejandra = - { - name = "alejandra"; - description = "The Uncompromising Nix Code Formatter"; - package = tools.alejandra; - entry = - let - cmdArgs = - mkCmdArgs (with hooks.alejandra.settings; [ - [ check "--check" ] - [ (exclude != [ ]) "--exclude ${lib.strings.concatStringsSep " --exclude " (map lib.escapeShellArg (lib.unique exclude))}" ] - [ (verbosity == "quiet") "-q" ] - [ (verbosity == "silent") "-qq" ] - [ (threads != null) "--threads ${toString threads}" ] - ]); - in - "${hooks.alejandra.package}/bin/alejandra ${cmdArgs}"; - files = "\\.nix$"; - }; - annex = - { - name = "annex"; - description = "Runs the git-annex hook for large file support"; - package = tools.git-annex; - entry = "${hooks.annex.package}/bin/git-annex pre-commit"; - }; - ansible-lint = - { - name = "ansible-lint"; - description = "Ansible linter"; - package = tools.ansible-lint; - entry = - let - cmdArgs = - mkCmdArgs [ - [ (hooks.ansible-lint.settings.configPath != "") "-c ${hooks.ansible-lint.settings.configPath}" ] - ]; - in - "${hooks.ansible-lint.package}/bin/ansible-lint ${cmdArgs}"; - files = if hooks.ansible-lint.settings.subdir != "" then "${hooks.ansible-lint.settings.subdir}/" else ""; - }; - autoflake = - { - name = "autoflake"; - description = "Remove unused imports and variables from Python code"; - - package = tools.autoflake; - entry = - let - binPath = migrateBinPathToPackage hooks.autoflake "/bin/autoflake"; - in - "${binPath} ${hooks.autoflake.settings.flags}"; - types = [ "python" ]; - }; - biome = - { - name = "biome"; - description = "A toolchain for web projects, aimed to provide functionalities to maintain them"; - types_or = [ "javascript" "jsx" "ts" "tsx" "json" ]; - - package = tools.biome; - entry = - let - binPath = migrateBinPathToPackage hooks.biome "/bin/biome"; - cmdArgs = - mkCmdArgs [ - [ (hooks.biome.settings.write) "--write" ] - [ (hooks.biome.settings.configPath != "") "--config-path ${hooks.biome.settings.configPath}" ] - ]; - in - "${binPath} check ${cmdArgs}"; - }; - bats = - { - name = "bats"; - description = "Run bash unit tests"; - types = [ "shell" ]; - types_or = [ "bats" "bash" ]; - package = tools.bats; - entry = "${hooks.bats.package}/bin/bats -p"; - }; - beautysh = - { - name = "beautysh"; - description = "Format shell files"; - types = [ "shell" ]; - package = tools.beautysh; - entry = "${hooks.beautysh.package}/bin/beautysh"; - }; - black = - { - name = "black"; - description = "The uncompromising Python code formatter"; - package = tools.black; - entry = "${hooks.black.package}/bin/black ${hooks.black.settings.flags}"; - types = [ "file" "python" ]; - }; - cabal-fmt = - { - name = "cabal-fmt"; - description = "Format Cabal files"; - package = tools.cabal-fmt; - entry = "${hooks.cabal-fmt.package}/bin/cabal-fmt --inplace"; - files = "\\.cabal$"; - }; - cabal-gild = - { - name = "cabal-gild"; - description = "Format Cabal files"; - package = tools.cabal-gild; - entry = - let - script = pkgs.writeShellScript "precommit-cabal-gild" '' - for file in "$@"; do - ${hooks.cabal-gild.package}/bin/cabal-gild --io="$file" - done - ''; - in - builtins.toString script; - files = "\\.cabal$"; - }; - cabal2nix = - { - name = "cabal2nix"; - description = "Run `cabal2nix` on all `*.cabal` files to generate corresponding `.nix` files"; - package = tools.cabal2nix-dir; - entry = "${hooks.cabal2nix.package}/bin/cabal2nix-dir --outputFileName=${hooks.cabal2nix.settings.outputFilename}"; - files = "\\.cabal$"; - after = [ "hpack" ]; - }; - cargo-check = - { - name = "cargo-check"; - description = "Check the cargo package for errors"; - package = tools.cargo; - entry = "${hooks.cargo-check.package}/bin/cargo check ${cargoManifestPathArg}"; - files = "\\.rs$"; - pass_filenames = false; - }; - checkmake = { - name = "checkmake"; - description = "Experimental linter/analyzer for Makefiles"; - types = [ "makefile" ]; - package = tools.checkmake; - entry = - ## NOTE: `checkmake` 0.2.2 landed in nixpkgs on 12 April 2023. Once - ## this gets into a NixOS release, the following code will be useless. - lib.throwIf - (hooks.checkmake.package == null) - "The version of nixpkgs used by git-hooks.nix must have `checkmake` in version at least 0.2.2 for it to work on non-Linux systems." - "${hooks.checkmake.package}/bin/checkmake"; - }; - check-added-large-files = - { - name = "check-added-large-files"; - description = "Prevent very large files to be committed (e.g. binaries)."; - package = tools.pre-commit-hooks; - entry = "${hooks.check-added-large-files.package}/bin/check-added-large-files"; - stages = [ "pre-commit" "pre-push" "manual" ]; - }; - check-builtin-literals = - { - name = "check-builtin-literals"; - description = "Require literal syntax when initializing empty or zero builtin types in Python."; - package = tools.pre-commit-hooks; - entry = "${hooks.check-builtin-literals.package}/bin/check-builtin-literals"; - types = [ "python" ]; - }; - check-case-conflicts = - { - name = "check-case-conflicts"; - description = "Check for files that would conflict in case-insensitive filesystems."; - package = tools.pre-commit-hooks; - entry = "${hooks.check-case-conflicts.package}/bin/check-case-conflict"; - types = [ "file" ]; - }; - check-docstring-first = - { - name = "check-docstring-above"; - description = "Check that all docstrings appear above the code."; - package = tools.pre-commit-hooks; - entry = "${hooks.check-docstring-first.package}/bin/check-docstring-first"; - types = [ "python" ]; - }; - check-executables-have-shebangs = - { - name = "check-executables-have-shebangs"; - description = "Ensure that all non-binary executables have shebangs."; - package = tools.pre-commit-hooks; - entry = "${hooks.check-executables-have-shebangs.package}/bin/check-executables-have-shebangs"; - types = [ "text" "executable" ]; - stages = [ "pre-commit" "pre-push" "manual" ]; - }; - check-json = - { - name = "check-json"; - description = "Check syntax of JSON files."; - package = tools.pre-commit-hooks; - entry = "${hooks.check-json.package}/bin/check-json"; - types = [ "json" ]; - }; - check-merge-conflicts = - { - name = "check-merge-conflicts"; - description = "Check for files that contain merge conflict strings."; - package = tools.pre-commit-hooks; - entry = "${hooks.check-merge-conflicts.package}/bin/check-merge-conflict"; - types = [ "text" ]; - }; - check-python = - { - name = "check-python"; - description = "Check syntax of Python file by parsing Python abstract syntax tree."; - package = tools.pre-commit-hooks; - entry = "${hooks.check-python.package}/bin/check-ast"; - types = [ "python" ]; - }; - check-shebang-scripts-are-executable = - { - name = "check-shebang-scripts-are-executable"; - description = "Ensure that all (non-binary) files with a shebang are executable."; - package = tools.pre-commit-hooks; - entry = "${hooks.check-shebang-scripts-are-executable.package}/bin/check-shebang-scripts-are-executable"; - types = [ "text" ]; - stages = [ "pre-commit" "pre-push" "manual" ]; - }; - check-symlinks = - { - name = "check-symlinks"; - description = "Find broken symlinks."; - package = tools.pre-commit-hooks; - entry = "${hooks.check-symlinks.package}/bin/check-symlinks"; - types = [ "symlink" ]; - }; - check-toml = - { - name = "check-toml"; - description = "Check syntax of TOML files."; - package = tools.pre-commit-hooks; - entry = "${hooks.check-toml.package}/bin/check-toml"; - types = [ "toml" ]; - }; - check-vcs-permalinks = - { - name = "check-vcs-permalinks"; - description = "Ensure that links to VCS websites are permalinks."; - package = tools.pre-commit-hooks; - entry = "${hooks.check-vcs-permalinks.package}/bin/check-vcs-permalinks"; - types = [ "text" ]; - }; - check-xml = - { - name = "check-xml"; - description = "Check syntax of XML files."; - package = tools.pre-commit-hooks; - entry = "${hooks.check-xml.package}/bin/check-xml"; - types = [ "xml" ]; - }; - check-yaml = - { - name = "check-yaml"; - description = "Check syntax of YAML files."; - package = tools.pre-commit-hooks; - entry = "${hooks.check-yaml.package}/bin/check-yaml --multi"; - types = [ "yaml" ]; - }; - chktex = - { - name = "chktex"; - description = "LaTeX semantic checker"; - types = [ "file" "tex" ]; - package = tools.chktex; - entry = "${hooks.chktex.package}/bin/chktex"; - }; - circleci = - { - name = "circleci"; - description = "Validate CircleCI config files."; - package = tools.circleci-cli; - entry = builtins.toString (pkgs.writeShellScript "precommit-circleci" '' - set -e - failed=false - for file in "$@"; do - if ! ${hooks.circleci.package}/bin/circleci config validate "$file" 2>&1 - then - echo "Config file at $file is invalid, check the errors above." - failed=true - fi - done - if [[ $failed == "true" ]]; then - exit 1 - fi - ''); - files = "^.circleci/"; - types = [ "yaml" ]; - }; - clang-format = - { - name = "clang-format"; - description = "Format your code using `clang-format`."; - package = tools.clang-tools; - entry = "${hooks.clang-format.package}/bin/clang-format -style=file -i"; - # Source: - # https://github.com/pre-commit/mirrors-clang-format/blob/46516e8f532c8f2d55e801c34a740ebb8036365c/.pre-commit-hooks.yaml - types_or = [ - "c" - "c++" - "c#" - "cuda" - "java" - "javascript" - "json" - "objective-c" - "proto" - ]; - }; - clang-tidy = { - name = "clang-tidy"; - description = "Static analyzer for C++ code."; - package = tools.clang-tools; - entry = "${hooks.clang-tidy.package}/bin/clang-tidy --fix"; - types_or = [ "c" "c++" "c#" "objective-c" ]; - }; - clippy = - let - inherit (hooks.clippy) packageOverrides; - wrapper = pkgs.symlinkJoin { - name = "clippy-wrapped"; - paths = [ packageOverrides.clippy ]; - nativeBuildInputs = [ pkgs.makeWrapper ]; - postBuild = '' - wrapProgram $out/bin/cargo-clippy \ - --prefix PATH : ${lib.makeBinPath [ packageOverrides.cargo ]} - ''; - }; - in - { - name = "clippy"; - description = "Lint Rust code."; - package = wrapper; - packageOverrides = { cargo = tools.cargo; clippy = tools.clippy; }; - entry = "${hooks.clippy.package}/bin/cargo-clippy clippy ${cargoManifestPathArg} ${lib.optionalString hooks.clippy.settings.offline "--offline"} ${lib.optionalString hooks.clippy.settings.allFeatures "--all-features"} ${hooks.clippy.settings.extraArgs} -- ${lib.optionalString hooks.clippy.settings.denyWarnings "-D warnings"}"; - files = "\\.rs$"; - pass_filenames = false; - }; - cljfmt = - { - name = "cljfmt"; - description = "A tool for formatting Clojure code."; - package = tools.cljfmt; - entry = "${hooks.cljfmt.package}/bin/cljfmt fix"; - types_or = [ "clojure" "clojurescript" "edn" ]; - }; - cmake-format = - { - name = "cmake-format"; - description = "A tool for formatting CMake-files."; - package = tools.cmake-format; - entry = - let - maybeConfigPath = - if hooks.cmake-format.settings.configPath == "" - # Searches automatically for the config path. - then "" - else "-C ${hooks.cmake-format.settings.configPath}"; - in - "${hooks.cmake-format.package}/bin/cmake-format --check ${maybeConfigPath}"; - files = "\\.cmake$|CMakeLists.txt"; - }; - commitizen = - { - name = "commitizen check"; - description = '' - Check whether the current commit message follows committing rules. - ''; - package = tools.commitizen; - entry = "${hooks.commitizen.package}/bin/cz check --allow-abort --commit-msg-file"; - stages = [ "commit-msg" ]; - }; - conform = { - name = "conform enforce"; - description = "Policy enforcement for commits."; - package = tools.conform; - entry = "${hooks.conform.package}/bin/conform enforce --commit-msg-file"; - stages = [ "commit-msg" ]; - }; - convco = { - name = "convco"; - package = tools.convco; - entry = - let - convco = hooks.convco.package; - script = pkgs.writeShellScript "precommit-convco" '' - cat $1 | ${convco}/bin/convco check --from-stdin - ''; - # need version >= 0.4.0 for the --from-stdin flag - toolVersionCheck = lib.versionAtLeast convco.version "0.4.0"; - in - lib.throwIf (convco == null || !toolVersionCheck) "The version of Nixpkgs used by git-hooks.nix does not have the `convco` package (>=0.4.0). Please use a more recent version of Nixpkgs." - builtins.toString - script; - stages = [ "commit-msg" ]; - }; - credo = { - name = "credo"; - description = "Runs a static code analysis using Credo"; - package = tools.elixir; - entry = - let strict = if hooks.credo.settings.strict then "--strict" else ""; - in "${hooks.credo.package}/bin/mix credo ${strict}"; - files = "\\.exs?$"; - }; - crystal = { - name = "crystal"; - description = "A tool that automatically formats Crystal source code"; - package = tools.crystal; - entry = "${hooks.crystal.package}/bin/crystal tool format"; - files = "\\.cr$"; - }; - cspell = - { - name = "cspell"; - description = "A Spell Checker for Code"; - package = tools.cspell; - entry = "${hooks.cspell.package}/bin/cspell"; - }; - dart-analyze = { - name = "dart analyze"; - description = "Dart analyzer"; - package = tools.dart; - entry = "${hooks.dart-analyze.package}/bin/dart analyze"; - types = [ "dart" ]; - }; - dart-format = { - name = "dart format"; - description = "Dart formatter"; - package = tools.dart; - entry = "${hooks.dart-format.package}/bin/dart format"; - types = [ "dart" ]; - }; - deadnix = - { - name = "deadnix"; - description = "Scan Nix files for dead code (unused variable bindings)."; - package = tools.deadnix; - entry = - let - cmdArgs = - mkCmdArgs (with hooks.deadnix.settings; [ - [ noLambdaArg "--no-lambda-arg" ] - [ noLambdaPatternNames "--no-lambda-pattern-names" ] - [ noUnderscore "--no-underscore" ] - [ quiet "--quiet" ] - [ hidden "--hidden" ] - [ edit "--edit" ] - [ (exclude != [ ]) "--exclude ${lib.escapeShellArgs exclude}" ] - ]); - in - "${hooks.deadnix.package}/bin/deadnix ${cmdArgs} --fail"; - files = "\\.nix$"; - }; - denofmt = - { - name = "denofmt"; - description = "Auto-format JavaScript, TypeScript, Markdown, and JSON files."; - types_or = [ "javascript" "jsx" "ts" "tsx" "markdown" "json" ]; - package = tools.deno; - entry = - let - cmdArgs = - mkCmdArgs [ - [ (!hooks.denofmt.settings.write) "--check" ] - [ (hooks.denofmt.settings.configPath != "") "-c ${hooks.denofmt.settings.configPath}" ] - ]; - in - "${hooks.denofmt.package}/bin/deno fmt ${cmdArgs}"; - }; - denolint = - { - name = "denolint"; - description = "Lint JavaScript/TypeScript source code."; - types_or = [ "javascript" "jsx" "ts" "tsx" ]; - package = tools.deno; - entry = - let - cmdArgs = - mkCmdArgs [ - [ (hooks.denolint.settings.format == "compact") "--compact" ] - [ (hooks.denolint.settings.format == "json") "--json" ] - [ (hooks.denolint.settings.configPath != "") "-c ${hooks.denolint.settings.configPath}" ] - ]; - in - "${hooks.denolint.package}/bin/deno lint ${cmdArgs}"; - }; - detect-aws-credentials = - { - name = "detect-aws-credentials"; - description = "Detect AWS credentials from the AWS cli credentials file."; - package = tools.pre-commit-hooks; - entry = "${hooks.detect-aws-credentials.package}/bin/detect-aws-credentials --allow-missing-credentials"; - types = [ "text" ]; - }; - detect-private-keys = - { - name = "detect-private-keys"; - description = "Detect the presence of private keys."; - package = tools.pre-commit-hooks; - entry = "${hooks.detect-private-keys.package}/bin/detect-private-key"; - types = [ "text" ]; - }; - dhall-format = { - name = "dhall-format"; - description = "Dhall code formatter."; - package = tools.dhall; - entry = "${hooks.dhall-format.package}/bin/dhall format"; - files = "\\.dhall$"; - }; - dialyzer = { - name = "dialyzer"; - description = "Runs a static code analysis using Dialyzer"; - package = tools.elixir; - entry = "${hooks.dialyzer.package}/bin/mix dialyzer"; - files = "\\.exs?$"; - }; - dune-fmt = { - name = "dune-fmt"; - description = "Runs Dune's formatters on the code tree."; - package = tools.dune-fmt; - entry = - let - auto-promote = if hooks.dune-fmt.settings.auto-promote then "--auto-promote" else ""; - run-dune-fmt = pkgs.writeShellApplication { - name = "run-dune-fmt"; - runtimeInputs = hooks.dune-fmt.settings.extraRuntimeInputs; - text = "${hooks.dune-fmt.package}/bin/dune-fmt ${auto-promote}"; - }; - in - "${run-dune-fmt}/bin/run-dune-fmt"; - pass_filenames = false; - }; - dune-opam-sync = { - name = "dune/opam sync"; - description = "Check that Dune-generated OPAM files are in sync."; - package = tools.dune-build-opam-files; - entry = "${hooks.dune-opam-sync.package}/bin/dune-build-opam-files"; - files = "(\\.opam$)|(\\.opam.template$)|((^|/)dune-project$)"; - ## We don't pass filenames because they can only be misleading. Indeed, - ## we need to re-run `dune build` for every `*.opam` file, but also when - ## the `dune-project` file has changed. - pass_filenames = false; - }; - eclint = - { - name = "eclint"; - description = "EditorConfig linter written in Go."; - types = [ "file" ]; - package = tools.eclint; - entry = - let - cmdArgs = - mkCmdArgs - (with hooks.eclint.settings; [ - [ fix "-fix" ] - [ summary "-summary" ] - [ (color != "auto") "-color ${color}" ] - [ (exclude != [ ]) "-exclude ${lib.escapeShellArgs exclude}" ] - [ (verbosity != 0) "-verbosity ${toString verbosity}" ] - ]); - in - "${hooks.eclint.package}/bin/eclint ${cmdArgs}"; - }; - editorconfig-checker = - { - name = "editorconfig-checker"; - description = "Verify that the files are in harmony with the `.editorconfig`."; - package = tools.editorconfig-checker; - entry = "${hooks.editorconfig-checker.package}/bin/editorconfig-checker"; - types = [ "file" ]; - }; - end-of-file-fixer = - { - name = "end-of-file-fixer"; - description = "Ensures that a file is either empty, or ends with a single newline."; - package = tools.pre-commit-hooks; - entry = "${hooks.end-of-file-fixer.package}/bin/end-of-file-fixer"; - types = [ "text" ]; - }; - elm-format = - { - name = "elm-format"; - description = "Format Elm files."; - package = tools.elm-format; - entry = "${hooks.elm-format.package}/bin/elm-format --yes --elm-version=0.19"; - files = "\\.elm$"; - }; - elm-review = - { - name = "elm-review"; - description = "Analyzes Elm projects, to help find mistakes before your users find them."; - package = tools.elm-review; - entry = "${hooks.elm-review.package}/bin/elm-review"; - files = "\\.elm$"; - pass_filenames = false; - }; - elm-test = - { - name = "elm-test"; - description = "Run unit tests and fuzz tests for Elm code."; - package = tools.elm-test; - entry = "${hooks.elm-test.package}/bin/elm-test"; - files = "\\.elm$"; - pass_filenames = false; - }; - eslint = - { - name = "eslint"; - description = "Find and fix problems in your JavaScript code."; - - package = tools.eslint; - entry = - let - binPath = migrateBinPathToPackage hooks.eslint "/bin/eslint"; - in - "${binPath} --fix"; - files = "${hooks.eslint.settings.extensions}"; - }; - fix-byte-order-marker = - { - name = "fix-byte-order-marker"; - description = "Remove UTF-8 byte order marker."; - package = tools.pre-commit-hooks; - entry = "${hooks.fix-byte-order-marker.package}/bin/fix-byte-order-marker"; - types = [ "text" ]; - }; - fix-encoding-pragma = - { - name = "fix-encoding-pragma"; - description = "Adds \# -*- coding: utf-8 -*- to the top of Python files.'"; - package = tools.pre-commit-hooks; - entry = "${hooks.fix-encoding-pragma.package}/bin/fix-encoding-pragma"; - types = [ "python" ]; - }; - flake8 = - let - extendIgnoreStr = - if lib.lists.length hooks.flake8.settings.extendIgnore > 0 - then "--extend-ignore " + builtins.concatStringsSep "," hooks.flake8.settings.extendIgnore - else ""; - in - { - name = "flake8"; - description = "Check the style and quality of Python files."; - - package = tools.flake8; - entry = - let - binPath = migrateBinPathToPackage hooks.flake8 "/bin/flake8"; - in - "${binPath} --format ${hooks.flake8.settings.format} ${extendIgnoreStr}"; - types = [ "python" ]; - }; - flake-checker = { - name = "flake-checker"; - description = "Run health checks on your flake-powered Nix projects."; - package = tools.flake-checker; - entry = "${hooks.flake-checker.package}/bin/flake-checker -f"; - files = "(^flake\\.nix$|^flake\\.lock$)"; - pass_filenames = false; - }; - flynt = - { - name = "flynt"; - description = "CLI tool to convert a python project's %-formatted strings to f-strings."; - package = tools.flynt; - entry = - let - binPath = migrateBinPathToPackage hooks.flynt "/bin/flynt"; - cmdArgs = - mkCmdArgs (with hooks.flynt.settings; [ - [ aggressive "--aggressive" ] - [ dry-run "--dry-run" ] - [ (exclude != [ ]) "--exclude ${lib.escapeShellArgs exclude}" ] - [ fail-on-change "--fail-on-change" ] - [ (line-length != null) "--line-length ${toString line-length}" ] - [ no-multiline "--no-multiline" ] - [ quiet "--quiet" ] - [ string "--string" ] - [ transform-concats "--transform-concats" ] - [ verbose "--verbose" ] - ]); - in - "${binPath} ${cmdArgs}"; - types = [ "python" ]; - }; - forbid-new-submodules = - { - name = "forbid-new-submodules"; - description = "Prevent addition of new Git submodules."; - package = tools.pre-commit-hooks; - entry = "${hooks.forbid-new-submodules.package}/bin/forbid-new-submodules"; - types = [ "directory" ]; - }; - fourmolu = - { - name = "fourmolu"; - description = "Haskell code prettifier."; - package = tools.fourmolu; - entry = - "${hooks.fourmolu.package}/bin/fourmolu --mode inplace ${ -lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.fourmolu.settings.defaultExtensions) -}"; - files = "\\.l?hs(-boot)?$"; - }; - fprettify = { - name = "fprettify"; - description = "Auto-formatter for modern Fortran code."; - types = [ "fortran " ]; - package = tools.fprettify; - entry = "${hooks.fprettify.package}/bin/fprettify"; - }; - gitlint = { - name = "gitlint"; - description = "Linting for your git commit messages"; - package = tools.gitlint; - entry = "${hooks.gitlint.package}/bin/gitlint --staged --msg-filename"; - stages = [ "commit-msg" ]; - }; - gofmt = - { - name = "gofmt"; - description = "A tool that automatically formats Go source code"; - package = tools.go; - entry = - let - script = pkgs.writeShellScript "precommit-gofmt" '' - set -e - failed=false - for file in "$@"; do - # redirect stderr so that violations and summaries are properly interleaved. - if ! ${hooks.gofmt.package}/bin/gofmt -l -w "$file" 2>&1 - then - failed=true - fi - done - if [[ $failed == "true" ]]; then - exit 1 - fi - ''; - in - builtins.toString script; - files = "\\.go$"; - }; - golangci-lint = { - name = "golangci-lint"; - description = "Fast linters runner for Go."; - package = tools.golangci-lint; - entry = - let - script = pkgs.writeShellScript "precommit-golangci-lint" '' - set -e - for dir in $(echo "$@" | xargs -n1 dirname | sort -u); do - ${hooks.golangci-lint.package}/bin/golangci-lint run ./"$dir" - done - ''; - in - builtins.toString script; - files = "\\.go$"; - # to avoid multiple invocations of the same directory input, provide - # all file names in a single run. - require_serial = true; - }; - golines = - { - name = "golines"; - description = "A golang formatter that fixes long lines"; - package = tools.golines; - entry = - let - script = pkgs.writeShellScript "precommit-golines" '' - set -e - failed=false - for file in "$@"; do - # redirect stderr so that violations and summaries are properly interleaved. - if ! ${hooks.golines.package}/bin/golines ${hooks.golines.settings.flags} -w "$file" 2>&1 - then - failed=true - fi - done - if [[ $failed == "true" ]]; then - exit 1 - fi - ''; - in - builtins.toString script; - files = "\\.go$"; - }; - gotest = { - name = "gotest"; - description = "Run go tests"; - package = tools.go; - entry = - let - script = pkgs.writeShellScript "precommit-gotest" '' - set -e - # find all directories that contain tests - dirs=() - for file in "$@"; do - # either the file is a test - if [[ "$file" = *_test.go ]]; then - dirs+=("$(dirname "$file")") - continue - fi - - # or the file has an associated test - filename="''${file%.go}" - test_file="''${filename}_test.go" - if [[ -f "$test_file" ]]; then - dirs+=("$(dirname "$test_file")") - continue - fi - done - - # ensure we are not duplicating dir entries - IFS=$'\n' sorted_dirs=($(sort -u <<<"''${dirs[*]}")); unset IFS - - # test each directory one by one - for dir in "''${sorted_dirs[@]}"; do - ${hooks.gotest.package}/bin/go test "./$dir" - done - ''; - in - builtins.toString script; - files = "\\.go$"; - # to avoid multiple invocations of the same directory input, provide - # all file names in a single run. - require_serial = true; - }; - govet = - { - name = "govet"; - description = "Checks correctness of Go programs."; - package = tools.go; - entry = - let - # go vet requires package (directory) names as inputs. - script = pkgs.writeShellScript "precommit-govet" '' - set -e - for dir in $(echo "$@" | xargs -n1 dirname | sort -u); do - ${hooks.govet.package}/bin/go vet -C ./"$dir" - done - ''; - in - builtins.toString script; - # to avoid multiple invocations of the same directory input, provide - # all file names in a single run. - require_serial = true; - files = "\\.go$"; - }; - gptcommit = { - name = "gptcommit"; - description = "Generate a commit message using GPT3."; - package = tools.gptcommit; - entry = - let - script = pkgs.writeShellScript "precommit-gptcomit" '' - ${hooks.gptcommit.package}/bin/gptcommit prepare-commit-msg --commit-source \ - "$PRE_COMMIT_COMMIT_MSG_SOURCE" --commit-msg-file "$1" - ''; - in - lib.throwIf (hooks.gptcommit.package == null) "The version of Nixpkgs used by git-hooks.nix does not have the `gptcommit` package. Please use a more recent version of Nixpkgs." - toString - script; - stages = [ "prepare-commit-msg" ]; - }; - hadolint = - { - name = "hadolint"; - description = "Dockerfile linter, validate inline bash."; - package = tools.hadolint; - entry = "${hooks.hadolint.package}/bin/hadolint"; - files = "Dockerfile$"; - }; - headache = - { - name = "headache"; - description = "Lightweight tool for managing headers in source code files."; - ## NOTE: Supported `files` are taken from - ## https://github.com/Frama-C/headache/blob/master/config_builtin.txt - files = "(\\.ml[ily]?$)|(\\.fmli?$)|(\\.[chy]$)|(\\.tex$)|(Makefile)|(README)|(LICENSE)"; - package = tools.headache; - entry = - ## NOTE: `headache` made into in nixpkgs on 12 April 2023. At the - ## next NixOS release, the following code will become irrelevant. - lib.throwIf - (hooks.headache.package == null) - "The version of nixpkgs used by git-hooks.nix does not have `ocamlPackages.headache`. Please use a more recent version of nixpkgs." - "${hooks.headache.package}/bin/headache -h ${hooks.headache.settings.header-file}"; - }; - hindent = - { - name = "hindent"; - description = "Haskell code prettifier."; - package = tools.hindent; - entry = "${hooks.hindent.package}/bin/hindent"; - files = "\\.l?hs(-boot)?$"; - }; - hlint = - { - name = "hlint"; - description = "HLint gives suggestions on how to improve your source code."; - package = tools.hlint; - entry = "${hooks.hlint.package}/bin/hlint${if hooks.hlint.settings.hintFile == null then "" else " --hint=${hooks.hlint.settings.hintFile}"}"; - files = "\\.l?hs(-boot)?$"; - }; - hpack = - { - name = "hpack"; - description = "`hpack` converts package definitions in the hpack format (`package.yaml`) to Cabal files."; - package = tools.hpack-dir; - entry = "${hooks.hpack.package}/bin/hpack-dir --${if hooks.hpack.settings.silent then "silent" else "verbose"}"; - files = "(\\.l?hs(-boot)?$)|(\\.cabal$)|((^|/)package\\.yaml$)"; - # We don't pass filenames because they can only be misleading. - # Indeed, we need to rerun `hpack` in every directory: - # 1. In which there is a *.cabal file, or - # 2. Below which there are haskell files, or - # 3. In which there is a package.yaml that references haskell files - # that have been changed at arbitrary locations specified in that - # file. - # In other words: We have no choice but to always run `hpack` on every `package.yaml` directory. - pass_filenames = false; - }; - html-tidy = - { - name = "html-tidy"; - description = "HTML linter."; - package = tools.html-tidy; - entry = "${hooks.html-tidy.package}/bin/tidy -quiet -errors"; - files = "\\.html$"; - }; - hunspell = - { - name = "hunspell"; - description = "Spell checker and morphological analyzer."; - package = tools.hunspell; - entry = "${hooks.hunspell.package}/bin/hunspell -l"; - files = "\\.((txt)|(html)|(xml)|(md)|(org)|(rst)|(tex)|(odf)|\\d)$"; - }; - isort = - { - name = "isort"; - description = "A Python utility / library to sort imports."; - types = [ "file" "python" ]; - package = tools.isort; - entry = - let - cmdArgs = - mkCmdArgs - (with hooks.isort.settings; [ - [ (profile != "") " --profile ${profile}" ] - ]); - in - "${hooks.isort.package}/bin/isort${cmdArgs} ${hooks.isort.settings.flags}"; - }; - juliaformatter = - { - description = "Run JuliaFormatter.jl against Julia source files"; - files = "\\.jl$"; - package = tools.julia-bin; - entry = '' - ${hooks.juliaformatter.package}/bin/julia -e ' - using Pkg - Pkg.activate(".") - using JuliaFormatter - format(ARGS) - out = Cmd(`git diff --name-only`) |> read |> String - if out == "" - exit(0) - else - @error "Some files have been formatted !!!" - write(stdout, out) - exit(1) - end' - ''; - }; - latexindent = - { - name = "latexindent"; - description = "Perl script to add indentation to LaTeX files."; - types = [ "file" "tex" ]; - package = tools.latexindent; - entry = "${hooks.latexindent.package}/bin/latexindent ${hooks.latexindent.settings.flags}"; - }; - lacheck = - let - script = pkgs.writeShellScript "precommit-mdsh" '' - for file in $(echo "$@"); do - "${hooks.lacheck.package}/bin/lacheck" "$file" - done - ''; - in - { - name = "lacheck"; - description = "A consistency checker for LaTeX documents."; - types = [ "file" "tex" ]; - package = tools.lacheck; - entry = "${script}"; - }; - lua-ls = - let - # .luarc.json has to be in a directory, - # or lua-language-server will hang forever. - luarc = pkgs.writeText ".luarc.json" (builtins.toJSON hooks.lua-ls.settings.configuration); - luarc-dir = pkgs.stdenv.mkDerivation { - name = "luarc"; - unpackPhase = "true"; - installPhase = '' - mkdir $out - cp ${luarc} $out/.luarc.json - ''; - }; - script = pkgs.writeShellApplication { - name = "lua-ls-lint"; - runtimeInputs = [ hooks.lua-ls.package pkgs.jq ]; - checkPhase = ""; # The default checkPhase depends on GHC - text = '' - set -e - export logpath="$(mktemp -d)" - lua-language-server --check $(realpath .) \ - --checklevel="${hooks.lua-ls.settings.checklevel}" \ - --configpath="${luarc-dir}/.luarc.json" \ - --logpath="$logpath" - if [[ -f $logpath/check.json ]]; then - echo "+++++++++++++++ lua-language-server diagnostics +++++++++++++++" - cat $logpath/check.json - diagnostic_count=$(jq 'length' $logpath/check.json) - if [ "$diagnostic_count" -gt 0 ]; then - exit 1 - fi - fi - ''; - }; - in - { - name = "lua-ls"; - description = "Uses the lua-language-server CLI to statically type-check and lint Lua code."; - package = tools.lua-language-server; - entry = "${script}/bin/lua-ls-lint"; - files = "\\.lua$"; - pass_filenames = false; - }; - luacheck = - { - name = "luacheck"; - description = "A tool for linting and static analysis of Lua code."; - types = [ "file" "lua" ]; - package = tools.luacheck; - entry = "${hooks.luacheck.package}/bin/luacheck"; - }; - lychee = { - name = "lychee"; - description = "A fast, async, stream-based link checker that finds broken hyperlinks and mail addresses inside Markdown, HTML, reStructuredText, or any other text file or website."; - package = tools.lychee; - entry = - let - cmdArgs = - mkCmdArgs - (with hooks.lychee.settings; [ - [ (configPath != "") " --config ${configPath}" ] - ]); - in - "${hooks.lychee.package}/bin/lychee${cmdArgs} ${hooks.lychee.settings.flags}"; - types = [ "text" ]; - }; - markdownlint = - { - name = "markdownlint"; - description = "Style checker and linter for markdown files."; - package = tools.markdownlint-cli; - entry = "${hooks.markdownlint.package}/bin/markdownlint -c ${pkgs.writeText "markdownlint.json" (builtins.toJSON hooks.markdownlint.settings.configuration)}"; - files = "\\.md$"; - }; - mdformat = { - name = "mdformat"; - description = "CommonMark compliant Markdown formatter"; - package = tools.mdformat; - entry = "${hooks.mdformat.package}/bin/mdformat"; - types = [ "markdown" ]; - }; - mdl = - { - name = "mdl"; - description = "A tool to check markdown files and flag style issues."; - package = tools.mdl; - entry = - let - cmdArgs = - mkCmdArgs - (with hooks.mdl.settings; [ - [ (configPath != "") "--config ${configPath}" ] - [ git-recurse "--git-recurse" ] - [ ignore-front-matter "--ignore-front-matter" ] - [ json "--json" ] - [ (rules != [ ]) "--rules ${lib.strings.concatStringsSep "," rules}" ] - [ (rulesets != [ ]) "--rulesets ${lib.strings.concatStringsSep "," rulesets}" ] - [ show-aliases "--show-aliases" ] - [ warnings "--warnings" ] - [ skip-default-ruleset "--skip-default-ruleset" ] - [ (style != "") "--style ${style}" ] - [ (tags != [ ]) "--tags ${lib.strings.concatStringsSep "," tags}" ] - [ verbose "--verbose" ] - ]); - in - "${hooks.mdl.package}/bin/mdl ${cmdArgs}"; - files = "\\.md$"; - }; - mdsh = - let - script = pkgs.writeShellScript "precommit-mdsh" '' - for file in $(echo "$@"); do - ${hooks.mdsh.package}/bin/mdsh -i "$file" - done - ''; - in - { - name = "mdsh"; - description = "Markdown shell pre-processor."; - package = tools.mdsh; - entry = toString script; - files = "\\.md$"; - }; - mixed-line-endings = { - name = "mixed-line-endings"; - description = "Resolve mixed line endings."; - package = tools.pre-commit-hooks; - entry = "${hooks.mixed-line-endings.package}/bin/mixed-line-ending"; - types = [ "text" ]; - }; - mix-format = { - name = "mix-format"; - description = "Runs the built-in Elixir syntax formatter"; - package = tools.elixir; - entry = "${hooks.mix-format.package}/bin/mix format"; - files = "\\.exs?$"; - }; - mix-test = { - name = "mix-test"; - description = "Runs the built-in Elixir test framework"; - package = tools.elixir; - entry = "${hooks.mix-test.package}/bin/mix test"; - files = "\\.exs?$"; - }; - mkdocs-linkcheck = { - name = "mkdocs-linkcheck"; - description = "Validate links associated with markdown-based, statically generated websites."; - package = tools.mkdocs-linkcheck; - entry = - let - binPath = migrateBinPathToPackage hooks.mkdocs-linkcheck "/bin/mkdocs-linkcheck"; - cmdArgs = - mkCmdArgs - (with hooks.mkdocs-linkcheck.settings; [ - [ local-only " --local" ] - [ recurse " --recurse" ] - [ (extension != "") " --ext ${extension}" ] - [ (method != "") " --method ${method}" ] - [ (path != "") " ${path}" ] - ]); - in - "${binPath}${cmdArgs}"; - types = [ "text" "markdown" ]; - }; - mypy = - { - name = "mypy"; - description = "Static type checker for Python"; - - package = tools.mypy; - entry = migrateBinPathToPackage hooks.mypy "/bin/mypy"; - files = "\\.py$"; - }; - name-tests-test = - { - name = "mypy"; - description = "Verify that Python test files are named correctly."; - package = tools.pre-commit-hooks; - entry = "${hooks.name-tests-test.package}/bin/tests_should_end_in_test.py"; - files = "(^|/)tests/\.+\\.py$"; - }; - nil = - { - name = "nil"; - description = "Incremental analysis assistant for writing in Nix."; - package = tools.nil; - entry = - let - script = pkgs.writeShellScript "precommit-nil" '' - errors=false - echo Checking: $@ - for file in $(echo "$@"); do - ${hooks.nil.package}/bin/nil diagnostics "$file" - exit_code=$? - - if [[ $exit_code -ne 0 ]]; then - echo \"$file\" failed with exit code: $exit_code - errors=true - fi - done - if [[ $errors == true ]]; then - exit 1 - fi - ''; - in - builtins.toString script; - files = "\\.nix$"; - }; - nixfmt = - { - name = "nixfmt-deprecated"; - description = "Deprecated Nix code prettifier. Use nixfmt-classic."; - package = tools.nixfmt; - entry = "${hooks.nixfmt.package}/bin/nixfmt ${lib.optionalString (hooks.nixfmt.settings.width != null) "--width=${toString hooks.nixfmt.settings.width}"}"; - files = "\\.nix$"; - }; - nixfmt-classic = - { - name = "nixfmt-classic"; - description = "Nix code prettifier (classic)."; - package = tools.nixfmt-classic; - entry = "${hooks.nixfmt-classic.package}/bin/nixfmt ${lib.optionalString (hooks.nixfmt-classic.settings.width != null) "--width=${toString hooks.nixfmt-classic.settings.width}"}"; - files = "\\.nix$"; - }; - nixfmt-rfc-style = - { - name = "nixfmt-rfc-style"; - description = "Nix code prettifier (RFC 166 style)."; - package = tools.nixfmt-rfc-style; - entry = "${hooks.nixfmt-rfc-style.package}/bin/nixfmt ${lib.optionalString (hooks.nixfmt-rfc-style.settings.width != null) "--width=${toString hooks.nixfmt-rfc-style.settings.width}"}"; - files = "\\.nix$"; - }; - nixpkgs-fmt = - { - name = "nixpkgs-fmt"; - description = "Nix code prettifier."; - package = tools.nixpkgs-fmt; - entry = "${hooks.nixpkgs-fmt.package}/bin/nixpkgs-fmt"; - files = "\\.nix$"; - }; - no-commit-to-branch = - { - name = "no-commit-to-branch"; - description = "Disallow committing to certain branch/branches."; - pass_filenames = false; - always_run = true; - package = tools.pre-commit-hooks; - entry = - let - cmdArgs = - mkCmdArgs - (with hooks.no-commit-to-branch.settings; [ - [ (branch != [ ]) "--branch ${lib.strings.concatStringsSep " --branch " branch}" ] - [ (pattern != [ ]) "--pattern ${lib.strings.concatStringsSep " --pattern " pattern}" ] - ]); - in - "${hooks.no-commit-to-branch.package}/bin/no-commit-to-branch ${cmdArgs}"; - }; - ocp-indent = - { - name = "ocp-indent"; - description = "A tool to indent OCaml code."; - package = tools.ocp-indent; - entry = "${hooks.ocp-indent.package}/bin/ocp-indent --inplace"; - files = "\\.mli?$"; - }; - opam-lint = - { - name = "opam lint"; - description = "OCaml package manager configuration checker."; - package = tools.opam; - entry = "${hooks.opam-lint.package}/bin/opam lint"; - files = "\\.opam$"; - }; - openapi-spec-validator = - { - name = "openapi spec validator"; - description = "A tool to validate OpenAPI spec files"; - package = tools.openapi-spec-validator; - entry = "${hooks.openapi-spec-validator.package}/bin/openapi-spec-validator"; - files = ".*openapi.*\\.(json|yaml|yml)$"; - }; - ormolu = - { - name = "ormolu"; - description = "Haskell code prettifier."; - package = tools.ormolu; - entry = - let - extensions = - lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormolu.settings.defaultExtensions); - cabalExtensions = - if hooks.ormolu.settings.cabalDefaultExtensions then "--cabal-default-extensions" else ""; - in - "${hooks.ormolu.package}/bin/ormolu --mode inplace ${extensions} ${cabalExtensions}"; - files = "\\.l?hs(-boot)?$"; - }; - php-cs-fixer = - { - name = "php-cs-fixer"; - description = "Lint PHP files."; - - package = tools.php-cs-fixer; - entry = - let - binPath = migrateBinPathToPackage hooks.php-cs-fixer "/bin/php-cs-fixer"; - in - "${binPath} fix"; - types = [ "php" ]; - }; - phpcbf = - { - name = "phpcbf"; - description = "Lint PHP files."; - - package = tools.phpcbf; - entry = migrateBinPathToPackage hooks.phpcbf "/bin/phpcbf"; - types = [ "php" ]; - }; - phpcs = - { - name = "phpcs"; - description = "Lint PHP files."; - - package = tools.phpcs; - entry = migrateBinPathToPackage hooks.phpcs "/bin/phpcs"; - types = [ "php" ]; - }; - phpstan = - { - name = "phpstan"; - description = "Static Analysis of PHP files."; - - package = tools.phpstan; - entry = - let - binPath = migrateBinPathToPackage hooks.phpstan "/bin/phpstan"; - in - "${binPath} analyse"; - types = [ "php" ]; - }; - poetry-check = { - name = "poetry check"; - description = "Check the Poetry config for errors"; - package = tools.poetry; - entry = "${hooks.poetry-check.package}/bin/poetry check"; - files = "^(poetry\\.lock$|pyproject\\.toml)$"; - pass_filenames = false; - }; - poetry-lock = { - name = "poetry lock"; - description = "Update the Poetry lock file"; - package = tools.poetry; - entry = "${hooks.poetry-lock.package}/bin/poetry lock"; - files = "^(poetry\\.lock$|pyproject\\.toml)$"; - pass_filenames = false; - }; - pre-commit-hook-ensure-sops = { - name = "pre-commit-hook-ensure-sops"; - package = tools.pre-commit-hook-ensure-sops; - entry = - ## NOTE: pre-commit-hook-ensure-sops landed in nixpkgs on 8 July 2022. Once it reaches a - ## release of NixOS, the `throwIf` piece of code below will become - ## useless. - lib.throwIf - (hooks.pre-commit-hook-ensure-sops.package == null) - "The version of nixpkgs used by git-hooks.nix does not have the `pre-commit-hook-ensure-sops` package. Please use a more recent version of nixpkgs." - '' - ${hooks.pre-commit-hook-ensure-sops.package}/bin/pre-commit-hook-ensure-sops - ''; - files = "^secrets"; - }; - # See all CLI flags for prettier [here](https://prettier.io/docs/en/cli.html). - # See all options for prettier [here](https://prettier.io/docs/en/options.html). - prettier = - { - name = "prettier"; - description = "Opinionated multi-language code formatter."; - types = [ "text" ]; - - package = tools.prettier; - entry = - let - binPath = migrateBinPathToPackage hooks.prettier "/bin/prettier"; - cmdArgs = - mkCmdArgs - (with hooks.prettier.settings; [ - [ (allow-parens != "always") "--allow-parens ${allow-parens}" ] - [ bracket-same-line "--bracket-same-line" ] - [ cache "--cache" ] - [ (cache-location != "./node_modules/.cache/prettier/.prettier-cache") "--cache-location ${cache-location}" ] - [ (cache-strategy != null) "--cache-strategy ${cache-strategy}" ] - [ check "--check" ] - [ (!color) "--no-color" ] - [ (configPath != "") "--config ${configPath}" ] - [ (config-precedence != "cli-override") "--config-precedence ${config-precedence}" ] - [ (embedded-language-formatting != "auto") "--embedded-language-formatting ${embedded-language-formatting}" ] - [ (end-of-line != "lf") "--end-of-line ${end-of-line}" ] - [ (html-whitespace-sensitivity != "css") "--html-whitespace-sensitivity ${html-whitespace-sensitivity}" ] - [ (ignore-path != [ ]) "--ignore-path ${lib.escapeShellArgs ignore-path}" ] - [ ignore-unknown "--ignore-unknown" ] - [ insert-pragma "--insert-pragma" ] - [ jsx-single-quote "--jsx-single-quote" ] - [ list-different "--list-different" ] - [ (log-level != "log") "--log-level ${log-level}" ] - [ no-bracket-spacing "--no-bracket-spacing" ] - [ no-config "--no-config" ] - [ no-editorconfig "--no-editorconfig" ] - [ no-error-on-unmatched-pattern "--no-error-on-unmatched-pattern" ] - [ no-semi "--no-semi" ] - [ (parser != "") "--parser ${parser}" ] - [ (print-width != 80) "--print-width ${toString print-width}" ] - [ (prose-wrap != "preserve") "--prose-wrap ${prose-wrap}" ] - [ (plugins != [ ]) "--plugin ${lib.strings.concatStringsSep " --plugin " plugins}" ] - [ (quote-props != "as-needed") "--quote-props ${quote-props}" ] - [ require-pragma "--require-pragma" ] - [ single-attribute-per-line "--single-attribute-per-line" ] - [ single-quote "--single-quote" ] - [ (tab-width != 2) "--tab-width ${toString tab-width}" ] - [ (trailing-comma != "all") "--trailing-comma ${trailing-comma}" ] - [ use-tabs "--use-tabs" ] - [ vue-indent-script-and-style "--vue-indent-script-and-style" ] - [ with-node-modules "--with-node-modules" ] - [ write "--write" ] - ]); - in - "${binPath} ${cmdArgs}"; - }; - pretty-format-json = - { - name = "pretty-format-json"; - description = "Formats JSON files."; - package = tools.pre-commit-hooks; - entry = - let - binPath = "${hooks.pretty-format-json.package}/bin/pretty-format-json"; - cmdArgs = mkCmdArgs (with hooks.pretty-format-json.settings; [ - [ autofix "--autofix" ] - [ (indent != null) "--indent ${toString indent}" ] - [ no-ensure-ascii "--no-ensure-ascii" ] - [ no-sort-keys "--no-sort-keys" ] - [ (top-keys != [ ]) "--top-keys ${lib.strings.concatStringsSep "," top-keys}" ] - ]); - in - "${binPath} ${cmdArgs}"; - types = [ "json" ]; - }; - proselint = - { - name = "proselint"; - description = "A linter for prose."; - types = [ "text" ]; - package = tools.proselint; - entry = - let - configFile = builtins.toFile "proselint-config.json" "${hooks.proselint.settings.config}"; - cmdArgs = - mkCmdArgs - (with hooks.proselint.settings; [ - [ (configPath != "") " --config ${configPath}" ] - [ (config != "" && configPath == "") " --config ${configFile}" ] - ]); - in - "${hooks.proselint.package}/bin/proselint${cmdArgs} ${hooks.proselint.settings.flags}"; - }; - psalm = - { - name = "psalm"; - description = "Static Analysis of PHP files."; - - package = tools.psalm; - entry = migrateBinPathToPackage hooks.psalm "/bin/psalm"; - types = [ "php" ]; - }; - purs-tidy = - { - name = "purs-tidy"; - description = "Format purescript files."; - package = tools.purs-tidy; - entry = "${hooks.purs-tidy.package}/bin/purs-tidy format-in-place"; - files = "\\.purs$"; - }; - purty = - { - name = "purty"; - description = "Format purescript files."; - package = tools.purty; - entry = "${hooks.purty.package}/bin/purty"; - files = "\\.purs$"; - }; - pylint = - { - name = "pylint"; - description = "Lint Python files."; - - package = tools.pylint; - entry = - let - binPath = migrateBinPathToPackage hooks.pylint "/bin/pylint"; - cmdArgs = - mkCmdArgs - (with hooks.pylint.settings; [ - [ reports "-ry" ] - [ (! score) "-sn" ] - ]); - in - "${binPath} ${cmdArgs}"; - types = [ "python" ]; - }; - pyright = - { - name = "pyright"; - description = "Static type checker for Python"; - - package = tools.pyright; - entry = migrateBinPathToPackage hooks.pyright "/bin/pyright"; - files = "\\.py$"; - }; - python-debug-statements = - { - name = "python-debug-statements"; - description = "Check for debugger imports and py37+ `breakpoint()` calls in python source."; - package = tools.pre-commit-hooks; - entry = "${hooks.python-debug-statements.package}/bin/debug-statement-hook"; - types = [ "python" ]; - }; - pyupgrade = - { - name = "pyupgrade"; - description = "Automatically upgrade syntax for newer versions."; - - package = tools.pyupgrade; - entry = migrateBinPathToPackage hooks.pyupgrade "/bin/pyupgrade"; - types = [ "python" ]; - }; - reuse = - { - name = "reuse"; - description = "reuse is a tool for compliance with the REUSE recommendations."; - package = tools.reuse; - entry = "${hooks.reuse.package}/bin/reuse lint ${hooks.reuse.settings.flags}"; - types = [ "file" ]; - pass_filenames = false; - }; - revive = - { - name = "revive"; - description = "A linter for Go source code."; - package = tools.revive; - entry = - let - cmdArgs = - mkCmdArgs [ - [ true "-set_exit_status" ] - [ (hooks.revive.settings.configPath != "") "-config ${hooks.revive.settings.configPath}" ] - ]; - # revive works with both files and directories; however some lints - # may fail (e.g. package-comment) if they run on an individual file - # rather than a package/directory scope; given this let's get the - # directories from each individual file. - script = pkgs.writeShellScript "precommit-revive" '' - set -e - for dir in $(echo "$@" | xargs -n1 dirname | sort -u); do - ${hooks.revive.package}/bin/revive ${cmdArgs} ./"$dir" - done - ''; - in - builtins.toString script; - files = "\\.go$"; - # to avoid multiple invocations of the same directory input, provide - # all file names in a single run. - require_serial = true; - }; - ripsecrets = - { - name = "ripsecrets"; - description = "Prevent committing secret keys into your source code"; - package = tools.ripsecrets; - entry = - let - cmdArgs = mkCmdArgs ( - with hooks.ripsecrets.settings; [ - [ true "--strict-ignore" ] - [ - (additionalPatterns != [ ]) - "--additional-pattern ${lib.strings.concatStringsSep " --additional-pattern " additionalPatterns}" - ] - ] - ); - in - "${hooks.ripsecrets.package}/bin/ripsecrets ${cmdArgs}"; - types = [ "text" ]; - }; - rome = - { - name = "rome-deprecated"; - description = ""; - types_or = [ "javascript" "jsx" "ts" "tsx" "json" ]; - package = tools.biome; - entry = - let - binPath = migrateBinPathToPackage hooks.rome "/bin/biome"; - cmdArgs = - mkCmdArgs [ - [ (hooks.rome.settings.write) "--apply" ] - [ (hooks.rome.settings.configPath != "") "--config-path ${hooks.rome.settings.configPath}" ] - ]; - in - "${binPath} check ${cmdArgs}"; - }; - ruff = - { - name = "ruff"; - description = "An extremely fast Python linter, written in Rust."; - package = tools.ruff; - entry = "${hooks.ruff.package}/bin/ruff check --fix"; - types = [ "python" ]; - }; - ruff-format = - { - name = "ruff-format"; - description = "An extremely fast Python code formatter, written in Rust."; - package = tools.ruff; - entry = "${hooks.ruff.package}/bin/ruff format"; - types = [ "python" ]; - }; - rustfmt = - let - mkAdditionalArgs = args: lib.optionalString (args != "") " -- ${args}"; - - inherit (hooks.rustfmt) packageOverrides; - wrapper = pkgs.symlinkJoin { - name = "rustfmt-wrapped"; - paths = [ packageOverrides.rustfmt ]; - nativeBuildInputs = [ pkgs.makeWrapper ]; - postBuild = '' - wrapProgram $out/bin/cargo-fmt \ - --prefix PATH : ${lib.makeBinPath (builtins.attrValues packageOverrides)} - ''; - }; - in - { - name = "rustfmt"; - description = "Format Rust code."; - package = wrapper; - packageOverrides = { inherit (tools) cargo rustfmt; }; - entry = - let - inherit (hooks) rustfmt; - inherit (rustfmt) settings; - cargoArgs = lib.cli.toGNUCommandLineShell { } { - inherit (settings) all package verbose manifest-path; - }; - rustfmtArgs = lib.cli.toGNUCommandLineShell { } { - inherit (settings) check emit config-path color files-with-diff config verbose; - }; - in - "${rustfmt.package}/bin/cargo-fmt fmt ${cargoArgs}${mkAdditionalArgs rustfmtArgs}"; - files = "\\.rs$"; - pass_filenames = false; - }; - selene = { - name = "selene"; - description = "A blazing-fast modern Lua linter written in Rust."; - types = [ "lua" ]; - package = tools.selene; - entry = "${hooks.selene.package}/bin/selene"; - }; - shellcheck = - { - name = "shellcheck"; - description = "Format shell files."; - types = [ "shell" ]; - package = tools.shellcheck; - entry = "${hooks.shellcheck.package}/bin/shellcheck"; - }; - shfmt = - { - name = "shfmt"; - description = "Format shell files."; - types = [ "shell" ]; - package = tools.shfmt; - entry = - let - simplify = if hooks.shfmt.settings.simplify then "-s" else ""; - in - "${hooks.shfmt.package}/bin/shfmt -w -l ${simplify}"; - }; - single-quoted-strings = - { - name = "single-quoted-strings"; - description = "Replace double quoted strings with single quoted strings."; - package = tools.pre-commit-hooks; - entry = "${hooks.single-quoted-strings.package}/bin/double-quote-string-fixer"; - types = [ "python" ]; - }; - sort-file-contents = - { - name = "sort-file-contents"; - description = "Sort the lines in specified files (defaults to alphabetical)."; - types = [ "text" ]; - package = tools.pre-commit-hooks; - entry = - let - cmdArgs = - mkCmdArgs - (with hooks.sort-file-contents.settings; - [ - [ ignore-case "--ignore-case" ] - [ unique "--unique" ] - ]); - in - "${hooks.sort-file-contents.package}/bin/file-contents-sorter ${cmdArgs}"; - }; - sort-requirements-txt = - { - name = "sort-requirements.txt"; - description = "Sort requirements in requirements.txt and constraints.txt files."; - package = tools.pre-commit-hooks; - entry = "${hooks.sort-requirements-txt.package}/bin/requirements-txt-fixer"; - files = "\\.*(requirements|constraints)\\.*\\.txt$"; - }; - sort-simple-yaml = - { - name = "sort-simple-yaml"; - description = "Sort simple YAML files which consist only of top-level keys, preserving comments and blocks."; - package = tools.pre-commit-hooks; - entry = "${hooks.sort-simple-yaml.package}/bin/sort-simple-yaml"; - files = "(\\.yaml$)|(\\.yml$)"; - }; - staticcheck = - { - name = "staticcheck"; - description = "State of the art linter for the Go programming language"; - package = tools.go-tools; - # staticheck works with directories. - entry = - let - script = pkgs.writeShellScript "precommit-staticcheck" '' - err=0 - for dir in $(echo "$@" | xargs -n1 dirname | sort -u); do - ${hooks.staticcheck.package}/bin/staticcheck ./"$dir" - code="$?" - if [[ "$err" -eq 0 ]]; then - err="$code" - fi - done - exit $err - ''; - in - builtins.toString script; - files = "\\.go$"; - # to avoid multiple invocations of the same directory input, provide - # all file names in a single run. - require_serial = true; - }; - statix = - { - name = "statix"; - description = "Lints and suggestions for the Nix programming language."; - package = tools.statix; - entry = - let - inherit (hooks.statix) package settings; - mkOptionName = k: - if builtins.stringLength k == 1 - then "-${k}" - else "--${k}"; - options = lib.cli.toGNUCommandLineShell - { - # instead of repeating the option name for each element, - # create a single option with a space-separated list of unique values. - mkList = k: v: if v == [ ] then [ ] else [ (mkOptionName k) ] ++ lib.unique v; - } - settings; - in - "${package}/bin/statix check ${options}"; - files = "\\.nix$"; - pass_filenames = false; - }; - stylish-haskell = - { - name = "stylish-haskell"; - description = "A simple Haskell code prettifier"; - package = tools.stylish-haskell; - entry = "${hooks.stylish-haskell.package}/bin/stylish-haskell --inplace"; - files = "\\.l?hs(-boot)?$"; - }; - stylua = - { - name = "stylua"; - description = "An Opinionated Lua Code Formatter."; - types = [ "file" "lua" ]; - package = tools.stylua; - entry = "${hooks.stylua.package}/bin/stylua --respect-ignores"; - }; - tagref = - { - name = "tagref"; - description = '' - Have tagref check all references and tags. - ''; - package = tools.tagref; - entry = "${hooks.tagref.package}/bin/tagref"; - types = [ "text" ]; - pass_filenames = false; - }; - taplo = - { - name = "taplo"; - description = "Format TOML files with taplo fmt"; - package = tools.taplo; - entry = "${hooks.taplo.package}/bin/taplo fmt"; - types = [ "toml" ]; - }; - terraform-format = - { - name = "terraform-format"; - description = "Format Terraform (`.tf`) files."; - package = tools.opentofu; - entry = "${lib.getExe hooks.terraform-format.package} fmt -check -diff"; - files = "\\.tf$"; - }; - terraform-validate = - { - name = "terraform-validate"; - description = "Validates terraform configuration files (`.tf`)."; - package = tools.terraform-validate; - entry = "${hooks.terraform-validate.package}/bin/terraform-validate"; - files = "\\.(tf(vars)?|terraform\\.lock\\.hcl)$"; - excludes = [ "\\.terraform/.*$" ]; - require_serial = true; - }; - tflint = - { - name = "tflint"; - description = "A Pluggable Terraform Linter."; - package = tools.tflint; - entry = "${hooks.tflint.package}/bin/tflint"; - files = "\\.tf$"; - }; - topiary = - { - name = "topiary"; - description = "A universal formatter engine within the Tree-sitter ecosystem, with support for many languages."; - package = tools.topiary; - entry = - ## NOTE: Topiary landed in nixpkgs on 2 Dec 2022. Once it reaches a - ## release of NixOS, the `throwIf` piece of code below will become - ## useless. - lib.throwIf - (hooks.topiary.package == null) - "The version of nixpkgs used by git-hooks.nix does not have the `topiary` package. Please use a more recent version of nixpkgs." - ( - let - topiary-inplace = pkgs.writeShellApplication { - name = "topiary-inplace"; - text = '' - for file; do - ${hooks.topiary.package}/bin/topiary --in-place --input-file "$file" - done - ''; - }; - in - "${topiary-inplace}/bin/topiary-inplace" - ); - files = "(\\.json$)|(\\.toml$)|(\\.mli?$)"; - }; - treefmt = - let - inherit (hooks.treefmt) packageOverrides settings; - wrapper = - pkgs.writeShellApplication { - name = "treefmt"; - runtimeInputs = [ - packageOverrides.treefmt - ] ++ settings.formatters; - - text = - '' - exec treefmt "$@" - ''; - }; - in - { - name = "treefmt"; - description = "One CLI to format the code tree."; - types = [ "file" ]; - pass_filenames = true; - package = wrapper; - packageOverrides = { treefmt = tools.treefmt; }; - entry = - let - cmdArgs = - mkCmdArgs - (with hooks.treefmt.settings; [ - [ fail-on-change "--fail-on-change" ] - [ no-cache "--no-cache" ] - ]); - in - "${hooks.treefmt.package}/bin/treefmt ${cmdArgs}"; - }; - trim-trailing-whitespace = - { - name = "trim-trailing-whitespace"; - description = "Trim trailing whitespace."; - types = [ "text" ]; - stages = [ "pre-commit" "pre-push" "manual" ]; - package = tools.pre-commit-hooks; - entry = "${hooks.trim-trailing-whitespace.package}/bin/trailing-whitespace-fixer"; - }; - trufflehog = - { - name = "trufflehog"; - description = "Secrets scanner"; - entry = - let - script = pkgs.writeShellScript "precommit-trufflehog" '' - set -e - ${hooks.trufflehog.package}/bin/trufflehog --no-update git "file://$(git rev-parse --show-toplevel)" --since-commit HEAD --only-verified --fail - ''; - in - builtins.toString script; - package = tools.trufflehog; - - # trufflehog expects to run across the whole repo, not particular files - pass_filenames = false; - }; - typos = - { - name = "typos"; - description = "Source code spell checker"; - package = tools.typos; - entry = - let - # Concatenate config in config file with section for ignoring words generated from list of words to ignore - configuration = "${hooks.typos.settings.configuration}" + lib.strings.optionalString (hooks.typos.settings.ignored-words != [ ]) "\n\[default.extend-words\]" + lib.strings.concatMapStrings (x: "\n${x} = \"${x}\"") hooks.typos.settings.ignored-words; - configFile = builtins.toFile "typos-config.toml" configuration; - cmdArgs = - mkCmdArgs - (with hooks.typos.settings; [ - [ binary "--binary" ] - [ (color != "auto") "--color ${color}" ] - [ (configuration != "") "--config ${configFile}" ] - [ (configPath != "" && configuration == "") "--config ${configPath}" ] - [ diff "--diff" ] - [ (exclude != "") "--exclude ${exclude} --force-exclude" ] - [ (format != "long") "--format ${format}" ] - [ hidden "--hidden" ] - [ (locale != "en") "--locale ${locale}" ] - [ no-check-filenames "--no-check-filenames" ] - [ no-check-files "--no-check-files" ] - [ no-unicode "--no-unicode" ] - [ quiet "--quiet" ] - [ verbose "--verbose" ] - [ (write && !diff) "--write-changes" ] - ]); - in - "${hooks.typos.package}/bin/typos ${cmdArgs}"; - types = [ "text" ]; - }; - typstfmt = { - name = "typstfmt"; - description = "format typst"; - package = tools.typstfmt; - entry = "${hooks.typstfmt.package}/bin/typstfmt"; - files = "\\.typ$"; - }; - typstyle = { - name = "typstyle"; - description = "Beautiful and reliable typst code formatter"; - package = tools.typstyle; - entry = - lib.throwIf - (hooks.typstyle.package == null) - "The version of nixpkgs used by git-hooks.nix must contain typstyle" - "${hooks.typstyle.package}/bin/typstyle -i"; - files = "\\.typ$"; - }; - vale = { - name = "vale"; - description = "A markup-aware linter for prose built with speed and extensibility in mind."; - package = tools.vale; - entry = - let - # TODO: was .vale.ini, threw error in Nix - configFile = builtins.toFile "vale.ini" "${hooks.vale.settings.configuration}"; - cmdArgs = - mkCmdArgs - (with hooks.vale.settings; [ - [ (configPath != "") " --config ${configPath}" ] - [ (configuration != "" && configPath == "") " --config ${configFile}" ] - ]); - in - "${hooks.vale.package}/bin/vale${cmdArgs} ${hooks.vale.settings.flags}"; - types = [ "text" ]; - }; - yamlfmt = - { - name = "yamlfmt"; - description = "Formatter for YAML files."; - types = [ "file" "yaml" ]; - package = tools.yamlfmt; - entry = - let - cmdArgs = - mkCmdArgs - (with hooks.yamlfmt.settings; [ - # Exit with non-zero status if the file is not formatted - [ lint-only "-lint" ] - # Do not print the diff - [ lint-only "-quiet" ] - # See https://github.com/google/yamlfmt/blob/main/docs/config-file.md#config-file-discovery - [ (configPath != "") "-conf ${configPath}" ] - ]); - in - "${hooks.yamlfmt.package}/bin/yamlfmt ${cmdArgs}"; - }; - yamllint = - { - name = "yamllint"; - description = "Linter for YAML files."; - types = [ "file" "yaml" ]; - package = tools.yamllint; - entry = - let - configFile = builtins.toFile "yamllint.yaml" "${hooks.yamllint.settings.configuration}"; - cmdArgs = - mkCmdArgs - (with hooks.yamllint.settings; [ - # Priorize multiline configuration over serialized configuration and configuration file - [ (configuration != "") "--config-file ${configFile}" ] - [ (configData != "" && configuration == "") "--config-data \"${configData}\"" ] - [ (configPath != "" && configData == "" && configuration == "" && preset == "default") "--config-file ${configPath}" ] - [ (format != "auto") "--format ${format}" ] - [ (preset != "default" && configuration == "") "--config-data ${preset}" ] - [ strict "--strict" ] - ]); - in - "${hooks.yamllint.package}/bin/yamllint ${cmdArgs}"; - }; - zprint = - { - name = "zprint"; - description = "Beautifully format Clojure and Clojurescript source code and s-expressions."; - package = tools.zprint; - entry = "${hooks.zprint.package}/bin/zprint '{:search-config? true}' -w"; - types_or = [ "clojure" "clojurescript" "edn" ]; - }; - - }; } diff --git a/modules/hooks/actionlint.nix b/modules/hooks/actionlint.nix new file mode 100644 index 00000000..6f82e69d --- /dev/null +++ b/modules/hooks/actionlint.nix @@ -0,0 +1,11 @@ +{ tools, lib, ... }: +{ + config = { + name = "actionlint"; + description = "Static checker for GitHub Actions workflow files"; + files = "^.github/workflows/"; + types = [ "yaml" ]; + package = tools.actionlint; + entry = "${tools.actionlint}/bin/actionlint"; + }; +} \ No newline at end of file diff --git a/modules/hooks/alejandra.nix b/modules/hooks/alejandra.nix index 4520fa37..1b1d84a9 100644 --- a/modules/hooks/alejandra.nix +++ b/modules/hooks/alejandra.nix @@ -1,6 +1,15 @@ -{ lib, ... }: +{ tools, config, lib, ... }: let inherit (lib) mkOption types; + + mkCmdArgs = predActionList: + lib.concatStringsSep + " " + (builtins.foldl' + (acc: entry: + acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) + [ ] + predActionList); in { options.settings = { @@ -33,4 +42,23 @@ in example = "quiet"; }; }; + + config = { + name = "alejandra"; + description = "The Uncompromising Nix Code Formatter"; + package = tools.alejandra; + entry = + let + cmdArgs = + mkCmdArgs (with config.settings; [ + [ check "--check" ] + [ (exclude != [ ]) "--exclude ${lib.strings.concatStringsSep " --exclude " (map lib.escapeShellArg (lib.unique exclude))}" ] + [ (verbosity == "quiet") "-q" ] + [ (verbosity == "silent") "-qq" ] + [ (threads != null) "--threads ${toString threads}" ] + ]); + in + "${tools.alejandra}/bin/alejandra ${cmdArgs}"; + files = "\\.nix$"; + }; } diff --git a/modules/hooks/annex.nix b/modules/hooks/annex.nix new file mode 100644 index 00000000..ef40734b --- /dev/null +++ b/modules/hooks/annex.nix @@ -0,0 +1,9 @@ +{ tools, lib, ... }: +{ + config = { + name = "annex"; + description = "Runs the git-annex hook for large file support"; + package = tools.git-annex; + entry = "${tools.git-annex}/bin/git-annex pre-commit"; + }; +} \ No newline at end of file diff --git a/modules/hooks/ansible-lint.nix b/modules/hooks/ansible-lint.nix index bd6d60c2..809b2387 100644 --- a/modules/hooks/ansible-lint.nix +++ b/modules/hooks/ansible-lint.nix @@ -1,6 +1,15 @@ -{ lib, ... }: +{ tools, config, lib, ... }: let inherit (lib) mkOption types; + + mkCmdArgs = predActionList: + lib.concatStringsSep + " " + (builtins.foldl' + (acc: entry: + acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) + [ ] + predActionList); in { options.settings = { @@ -17,4 +26,19 @@ in default = ""; }; }; + + config = { + name = "ansible-lint"; + description = "Ansible linter"; + package = tools.ansible-lint; + entry = + let + cmdArgs = + mkCmdArgs [ + [ (config.settings.configPath != "") "-c ${config.settings.configPath}" ] + ]; + in + "${tools.ansible-lint}/bin/ansible-lint ${cmdArgs}"; + files = if config.settings.subdir != "" then "${config.settings.subdir}/" else ""; + }; } diff --git a/modules/hooks/autoflake.nix b/modules/hooks/autoflake.nix index 2e1be5cf..4dc00c6d 100644 --- a/modules/hooks/autoflake.nix +++ b/modules/hooks/autoflake.nix @@ -1,6 +1,11 @@ -{ lib, ... }: +{ tools, config, lib, ... }: let inherit (lib) mkOption types; + + migrateBinPathToPackage = hook: binPath: + if hook.settings.binPath == null + then "${hook.package}${binPath}" + else hook.settings.binPath; in { options.settings = { @@ -21,4 +26,16 @@ in default = "--in-place --expand-star-imports --remove-duplicate-keys --remove-unused-variables"; }; }; + + config = { + name = "autoflake"; + description = "Remove unused imports and variables from Python code"; + package = tools.autoflake; + entry = + let + binPath = migrateBinPathToPackage config "/bin/autoflake"; + in + "${binPath} ${config.settings.flags}"; + types = [ "python" ]; + }; } diff --git a/modules/hooks/bats.nix b/modules/hooks/bats.nix new file mode 100644 index 00000000..1867e687 --- /dev/null +++ b/modules/hooks/bats.nix @@ -0,0 +1,11 @@ +{ tools, lib, ... }: +{ + config = { + name = "bats"; + description = "Run bash unit tests"; + types = [ "shell" ]; + types_or = [ "bats" "bash" ]; + package = tools.bats; + entry = "${tools.bats}/bin/bats -p"; + }; +} \ No newline at end of file diff --git a/modules/hooks/beautysh.nix b/modules/hooks/beautysh.nix new file mode 100644 index 00000000..8568947c --- /dev/null +++ b/modules/hooks/beautysh.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "beautysh"; + description = "Format shell files"; + types = [ "shell" ]; + package = tools.beautysh; + entry = "${tools.beautysh}/bin/beautysh"; + }; +} \ No newline at end of file diff --git a/modules/hooks/biome.nix b/modules/hooks/biome.nix index c9bd8d81..7a77b821 100644 --- a/modules/hooks/biome.nix +++ b/modules/hooks/biome.nix @@ -1,6 +1,20 @@ -{ lib, ... }: +{ tools, config, lib, ... }: let inherit (lib) mkOption types; + + mkCmdArgs = predActionList: + lib.concatStringsSep + " " + (builtins.foldl' + (acc: entry: + acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) + [ ] + predActionList); + + migrateBinPathToPackage = hook: binPath: + if hook.settings.binPath == null + then "${hook.package}${binPath}" + else hook.settings.binPath; in { options.settings = { @@ -36,4 +50,21 @@ in default = ""; }; }; + + config = { + name = "biome"; + description = "A toolchain for web projects, aimed to provide functionalities to maintain them"; + types_or = [ "javascript" "jsx" "ts" "tsx" "json" ]; + package = tools.biome; + entry = + let + binPath = migrateBinPathToPackage config "/bin/biome"; + cmdArgs = + mkCmdArgs [ + [ (config.settings.write) "--write" ] + [ (config.settings.configPath != "") "--config-path ${config.settings.configPath}" ] + ]; + in + "${binPath} check ${cmdArgs}"; + }; } diff --git a/modules/hooks/black.nix b/modules/hooks/black.nix index b2908adc..f29d2541 100644 --- a/modules/hooks/black.nix +++ b/modules/hooks/black.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ tools, config, lib, ... }: let inherit (lib) mkOption types; in @@ -11,4 +11,12 @@ in example = "--skip-magic-trailing-comma"; }; }; + + config = { + name = "black"; + description = "The uncompromising Python code formatter"; + package = tools.black; + entry = "${tools.black}/bin/black ${config.settings.flags}"; + types = [ "file" "python" ]; + }; } diff --git a/modules/hooks/cabal-fmt.nix b/modules/hooks/cabal-fmt.nix new file mode 100644 index 00000000..d4328628 --- /dev/null +++ b/modules/hooks/cabal-fmt.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "cabal-fmt"; + description = "Format Cabal files"; + package = tools.cabal-fmt; + entry = "${tools.cabal-fmt}/bin/cabal-fmt --inplace"; + files = "\\.cabal$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/cabal-gild.nix b/modules/hooks/cabal-gild.nix new file mode 100644 index 00000000..fd83ce08 --- /dev/null +++ b/modules/hooks/cabal-gild.nix @@ -0,0 +1,18 @@ +{ tools, config, lib, pkgs, ... }: +{ + config = { + name = "cabal-gild"; + description = "Format Cabal files"; + package = tools.cabal-gild; + entry = + let + script = pkgs.writeShellScript "precommit-cabal-gild" '' + for file in "$@"; do + ${tools.cabal-gild}/bin/cabal-gild --io="$file" + done + ''; + in + builtins.toString script; + files = "\\.cabal$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/cabal2nix.nix b/modules/hooks/cabal2nix.nix index daef528c..186912b6 100644 --- a/modules/hooks/cabal2nix.nix +++ b/modules/hooks/cabal2nix.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ tools, config, lib, ... }: let inherit (lib) mkOption types; in @@ -11,4 +11,13 @@ in default = "default.nix"; }; }; + + config = { + name = "cabal2nix"; + description = "Run `cabal2nix` on all `*.cabal` files to generate corresponding `.nix` files"; + package = tools.cabal2nix-dir; + entry = "${tools.cabal2nix-dir}/bin/cabal2nix-dir --outputFileName=${config.settings.outputFilename}"; + files = "\\.cabal$"; + after = [ "hpack" ]; + }; } diff --git a/modules/hooks/cargo-check.nix b/modules/hooks/cargo-check.nix new file mode 100644 index 00000000..a47ac618 --- /dev/null +++ b/modules/hooks/cargo-check.nix @@ -0,0 +1,18 @@ +{ tools, lib, rustSettings, ... }: +let + inherit (rustSettings) cargoManifestPath; + cargoManifestPathArg = + lib.optionalString + (cargoManifestPath != null) + "--manifest-path ${lib.escapeShellArg cargoManifestPath}"; +in +{ + config = { + name = "cargo-check"; + description = "Check the cargo package for errors"; + package = tools.cargo; + entry = "${tools.cargo}/bin/cargo check ${cargoManifestPathArg}"; + files = "\\.rs$"; + pass_filenames = false; + }; +} \ No newline at end of file diff --git a/modules/hooks/check-added-large-files.nix b/modules/hooks/check-added-large-files.nix new file mode 100644 index 00000000..b840e6ed --- /dev/null +++ b/modules/hooks/check-added-large-files.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "check-added-large-files"; + description = "Prevent very large files to be committed (e.g. binaries)."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/check-added-large-files"; + stages = [ "pre-commit" "pre-push" "manual" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/check-builtin-literals.nix b/modules/hooks/check-builtin-literals.nix new file mode 100644 index 00000000..67485c86 --- /dev/null +++ b/modules/hooks/check-builtin-literals.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "check-builtin-literals"; + description = "Require literal syntax when initializing empty or zero builtin types in Python."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/check-builtin-literals"; + types = [ "python" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/check-case-conflicts.nix b/modules/hooks/check-case-conflicts.nix new file mode 100644 index 00000000..9bd87209 --- /dev/null +++ b/modules/hooks/check-case-conflicts.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "check-case-conflicts"; + description = "Check for files that would conflict in case-insensitive filesystems."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/check-case-conflict"; + types = [ "file" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/check-docstring-first.nix b/modules/hooks/check-docstring-first.nix new file mode 100644 index 00000000..a6c1610f --- /dev/null +++ b/modules/hooks/check-docstring-first.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "check-docstring-above"; + description = "Check that all docstrings appear above the code."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/check-docstring-first"; + types = [ "python" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/check-executables-have-shebangs.nix b/modules/hooks/check-executables-have-shebangs.nix new file mode 100644 index 00000000..0c422c76 --- /dev/null +++ b/modules/hooks/check-executables-have-shebangs.nix @@ -0,0 +1,11 @@ +{ tools, lib, ... }: +{ + config = { + name = "check-executables-have-shebangs"; + description = "Ensure that all non-binary executables have shebangs."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/check-executables-have-shebangs"; + types = [ "text" "executable" ]; + stages = [ "pre-commit" "pre-push" "manual" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/check-json.nix b/modules/hooks/check-json.nix new file mode 100644 index 00000000..1e64c37a --- /dev/null +++ b/modules/hooks/check-json.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "check-json"; + description = "Check syntax of JSON files."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/check-json"; + types = [ "json" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/check-merge-conflicts.nix b/modules/hooks/check-merge-conflicts.nix new file mode 100644 index 00000000..ed7a10bb --- /dev/null +++ b/modules/hooks/check-merge-conflicts.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "check-merge-conflicts"; + description = "Check for files that contain merge conflict strings."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/check-merge-conflict"; + types = [ "text" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/check-python.nix b/modules/hooks/check-python.nix new file mode 100644 index 00000000..3cafc186 --- /dev/null +++ b/modules/hooks/check-python.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "check-python"; + description = "Check syntax of Python file by parsing Python abstract syntax tree."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/check-ast"; + types = [ "python" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/check-shebang-scripts-are-executable.nix b/modules/hooks/check-shebang-scripts-are-executable.nix new file mode 100644 index 00000000..2322e8ee --- /dev/null +++ b/modules/hooks/check-shebang-scripts-are-executable.nix @@ -0,0 +1,11 @@ +{ tools, lib, ... }: +{ + config = { + name = "check-shebang-scripts-are-executable"; + description = "Ensure that all (non-binary) files with a shebang are executable."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/check-shebang-scripts-are-executable"; + types = [ "text" ]; + stages = [ "pre-commit" "pre-push" "manual" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/check-symlinks.nix b/modules/hooks/check-symlinks.nix new file mode 100644 index 00000000..45eac7fa --- /dev/null +++ b/modules/hooks/check-symlinks.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "check-symlinks"; + description = "Find broken symlinks."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/check-symlinks"; + types = [ "symlink" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/check-toml.nix b/modules/hooks/check-toml.nix new file mode 100644 index 00000000..e70b767a --- /dev/null +++ b/modules/hooks/check-toml.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "check-toml"; + description = "Check syntax of TOML files."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/check-toml"; + types = [ "toml" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/check-vcs-permalinks.nix b/modules/hooks/check-vcs-permalinks.nix new file mode 100644 index 00000000..e77a3552 --- /dev/null +++ b/modules/hooks/check-vcs-permalinks.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "check-vcs-permalinks"; + description = "Ensure that links to VCS websites are permalinks."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/check-vcs-permalinks"; + types = [ "text" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/check-xml.nix b/modules/hooks/check-xml.nix new file mode 100644 index 00000000..57d2aa97 --- /dev/null +++ b/modules/hooks/check-xml.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "check-xml"; + description = "Check syntax of XML files."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/check-xml"; + types = [ "xml" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/check-yaml.nix b/modules/hooks/check-yaml.nix new file mode 100644 index 00000000..8146c6d2 --- /dev/null +++ b/modules/hooks/check-yaml.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "check-yaml"; + description = "Check syntax of YAML files."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/check-yaml --multi"; + types = [ "yaml" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/checkmake.nix b/modules/hooks/checkmake.nix new file mode 100644 index 00000000..0fcedc81 --- /dev/null +++ b/modules/hooks/checkmake.nix @@ -0,0 +1,16 @@ +{ tools, config, lib, ... }: +{ + config = { + name = "checkmake"; + description = "Experimental linter/analyzer for Makefiles"; + types = [ "makefile" ]; + package = tools.checkmake; + entry = + ## NOTE: `checkmake` 0.2.2 landed in nixpkgs on 12 April 2023. Once + ## this gets into a NixOS release, the following code will be useless. + lib.throwIf + (config.package == null) + "The version of nixpkgs used by git-hooks.nix must have `checkmake` in version at least 0.2.2 for it to work on non-Linux systems." + "${tools.checkmake}/bin/checkmake"; + }; +} \ No newline at end of file diff --git a/modules/hooks/chktex.nix b/modules/hooks/chktex.nix new file mode 100644 index 00000000..213b0eb1 --- /dev/null +++ b/modules/hooks/chktex.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "chktex"; + description = "LaTeX semantic checker"; + types = [ "file" "tex" ]; + package = tools.chktex; + entry = "${tools.chktex}/bin/chktex"; + }; +} \ No newline at end of file diff --git a/modules/hooks/circleci.nix b/modules/hooks/circleci.nix new file mode 100644 index 00000000..b4dca521 --- /dev/null +++ b/modules/hooks/circleci.nix @@ -0,0 +1,24 @@ +{ tools, lib, pkgs, ... }: +{ + config = { + name = "circleci"; + description = "Validate CircleCI config files."; + package = tools.circleci-cli; + entry = builtins.toString (pkgs.writeShellScript "precommit-circleci" '' + set -e + failed=false + for file in "$@"; do + if ! ${tools.circleci-cli}/bin/circleci config validate "$file" 2>&1 + then + echo "Config file at $file is invalid, check the errors above." + failed=true + fi + done + if [[ $failed == "true" ]]; then + exit 1 + fi + ''); + files = "^.circleci/"; + types = [ "yaml" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/clang-format.nix b/modules/hooks/clang-format.nix new file mode 100644 index 00000000..910cabb5 --- /dev/null +++ b/modules/hooks/clang-format.nix @@ -0,0 +1,22 @@ +{ tools, lib, ... }: +{ + config = { + name = "clang-format"; + description = "Format your code using `clang-format`."; + package = tools.clang-tools; + entry = "${tools.clang-tools}/bin/clang-format -style=file -i"; + # Source: + # https://github.com/pre-commit/mirrors-clang-format/blob/46516e8f532c8f2d55e801c34a740ebb8036365c/.pre-commit-hooks.yaml + types_or = [ + "c" + "c++" + "c#" + "cuda" + "java" + "javascript" + "json" + "objective-c" + "proto" + ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/clang-tidy.nix b/modules/hooks/clang-tidy.nix new file mode 100644 index 00000000..9a63083f --- /dev/null +++ b/modules/hooks/clang-tidy.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "clang-tidy"; + description = "Static analyzer for C++ code."; + package = tools.clang-tools; + entry = "${tools.clang-tools}/bin/clang-tidy --fix"; + types_or = [ "c" "c++" "c#" "objective-c" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/clippy.nix b/modules/hooks/clippy.nix index 29974d97..bdd1e773 100644 --- a/modules/hooks/clippy.nix +++ b/modules/hooks/clippy.nix @@ -1,6 +1,22 @@ -{ config, lib, ... }: +{ config, lib, pkgs, rustSettings, ... }: let inherit (lib) mkOption types; + inherit (rustSettings) cargoManifestPath; + + cargoManifestPathArg = + lib.optionalString + (cargoManifestPath != null) + "--manifest-path ${lib.escapeShellArg cargoManifestPath}"; + + wrapper = pkgs.symlinkJoin { + name = "clippy-wrapped"; + paths = [ config.packageOverrides.clippy ]; + nativeBuildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/cargo-clippy \ + --prefix PATH : ${lib.makeBinPath [ config.packageOverrides.cargo ]} + ''; + }; in { options = { @@ -39,8 +55,17 @@ in }; }; - config.extraPackages = [ - config.packageOverrides.cargo - config.packageOverrides.clippy - ]; + config = { + name = "clippy"; + description = "Lint Rust code."; + package = wrapper; + packageOverrides = { cargo = config.packageOverrides.cargo; clippy = config.packageOverrides.clippy; }; + entry = "${wrapper}/bin/cargo-clippy clippy ${cargoManifestPathArg} ${lib.optionalString config.settings.offline "--offline"} ${lib.optionalString config.settings.allFeatures "--all-features"} ${config.settings.extraArgs} -- ${lib.optionalString config.settings.denyWarnings "-D warnings"}"; + files = "\\.rs$"; + pass_filenames = false; + extraPackages = [ + config.packageOverrides.cargo + config.packageOverrides.clippy + ]; + }; } diff --git a/modules/hooks/cljfmt.nix b/modules/hooks/cljfmt.nix new file mode 100644 index 00000000..8adde7b8 --- /dev/null +++ b/modules/hooks/cljfmt.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "cljfmt"; + description = "A tool for formatting Clojure code."; + package = tools.cljfmt; + entry = "${tools.cljfmt}/bin/cljfmt fix"; + types_or = [ "clojure" "clojurescript" "edn" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/cmake-format.nix b/modules/hooks/cmake-format.nix index e5069ca7..050fc8f2 100644 --- a/modules/hooks/cmake-format.nix +++ b/modules/hooks/cmake-format.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ tools, config, lib, ... }: let inherit (lib) mkOption types; in @@ -11,4 +11,20 @@ in example = ".cmake-format.json"; }; }; + + config = { + name = "cmake-format"; + description = "A tool for formatting CMake-files."; + package = tools.cmake-format; + entry = + let + maybeConfigPath = + if config.settings.configPath == "" + # Searches automatically for the config path. + then "" + else "-C ${config.settings.configPath}"; + in + "${tools.cmake-format}/bin/cmake-format --check ${maybeConfigPath}"; + files = "\\.cmake$|CMakeLists.txt"; + }; } diff --git a/modules/hooks/commitizen.nix b/modules/hooks/commitizen.nix new file mode 100644 index 00000000..8d2cf049 --- /dev/null +++ b/modules/hooks/commitizen.nix @@ -0,0 +1,12 @@ +{ tools, lib, ... }: +{ + config = { + name = "commitizen check"; + description = '' + Check whether the current commit message follows committing rules. + ''; + package = tools.commitizen; + entry = "${tools.commitizen}/bin/cz check --allow-abort --commit-msg-file"; + stages = [ "commit-msg" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/conform.nix b/modules/hooks/conform.nix new file mode 100644 index 00000000..dd06f1ac --- /dev/null +++ b/modules/hooks/conform.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "conform enforce"; + description = "Policy enforcement for commits."; + package = tools.conform; + entry = "${tools.conform}/bin/conform enforce --commit-msg-file"; + stages = [ "commit-msg" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/convco.nix b/modules/hooks/convco.nix new file mode 100644 index 00000000..d478b15f --- /dev/null +++ b/modules/hooks/convco.nix @@ -0,0 +1,20 @@ +{ tools, lib, pkgs, ... }: +{ + config = { + name = "convco"; + package = tools.convco; + entry = + let + convco = tools.convco; + script = pkgs.writeShellScript "precommit-convco" '' + cat $1 | ${convco}/bin/convco check --from-stdin + ''; + # need version >= 0.4.0 for the --from-stdin flag + toolVersionCheck = lib.versionAtLeast convco.version "0.4.0"; + in + lib.throwIf (convco == null || !toolVersionCheck) "The version of Nixpkgs used by git-hooks.nix does not have the `convco` package (>=0.4.0). Please use a more recent version of Nixpkgs." + builtins.toString + script; + stages = [ "commit-msg" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/credo.nix b/modules/hooks/credo.nix index f6caaeb1..283241ef 100644 --- a/modules/hooks/credo.nix +++ b/modules/hooks/credo.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ tools, config, lib, ... }: let inherit (lib) mkOption types; in @@ -11,4 +11,14 @@ in default = true; }; }; + + config = { + name = "credo"; + description = "Runs a static code analysis using Credo"; + package = tools.elixir; + entry = + let strict = if config.settings.strict then "--strict" else ""; + in "${tools.elixir}/bin/mix credo ${strict}"; + files = "\\.exs?$"; + }; } diff --git a/modules/hooks/crystal.nix b/modules/hooks/crystal.nix new file mode 100644 index 00000000..7872940f --- /dev/null +++ b/modules/hooks/crystal.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "crystal"; + description = "A tool that automatically formats Crystal source code"; + package = tools.crystal; + entry = "${tools.crystal}/bin/crystal tool format"; + files = "\.cr$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/cspell.nix b/modules/hooks/cspell.nix new file mode 100644 index 00000000..12c0dd41 --- /dev/null +++ b/modules/hooks/cspell.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "cspell"; + description = "A Spell Checker for Code"; + package = tools.cspell; + entry = "${tools.cspell}/bin/cspell --no-summary"; + types = [ "text" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/dart-analyze.nix b/modules/hooks/dart-analyze.nix new file mode 100644 index 00000000..c34ccd9a --- /dev/null +++ b/modules/hooks/dart-analyze.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "dart analyze"; + description = "Dart analyzer"; + package = tools.dart; + entry = "${tools.dart}/bin/dart analyze"; + types = [ "dart" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/dart-format.nix b/modules/hooks/dart-format.nix new file mode 100644 index 00000000..512959ec --- /dev/null +++ b/modules/hooks/dart-format.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "dart format"; + description = "Dart formatter"; + package = tools.dart; + entry = "${tools.dart}/bin/dart format"; + types = [ "dart" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/deadnix.nix b/modules/hooks/deadnix.nix index 2d618371..a9f13d81 100644 --- a/modules/hooks/deadnix.nix +++ b/modules/hooks/deadnix.nix @@ -1,6 +1,15 @@ -{ lib, ... }: +{ tools, config, lib, ... }: let inherit (lib) mkOption types; + + mkCmdArgs = predActionList: + lib.concatStringsSep + " " + (builtins.foldl' + (acc: entry: + acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) + [ ] + predActionList); in { options.settings = { @@ -53,4 +62,25 @@ in default = false; }; }; + + config = { + name = "deadnix"; + description = "Scan Nix files for dead code (unused variable bindings)."; + package = tools.deadnix; + entry = + let + cmdArgs = + mkCmdArgs (with config.settings; [ + [ noLambdaArg "--no-lambda-arg" ] + [ noLambdaPatternNames "--no-lambda-pattern-names" ] + [ noUnderscore "--no-underscore" ] + [ quiet "--quiet" ] + [ hidden "--hidden" ] + [ edit "--edit" ] + [ (exclude != [ ]) "--exclude ${lib.escapeShellArgs exclude}" ] + ]); + in + "${tools.deadnix}/bin/deadnix ${cmdArgs} --fail"; + files = "\\.nix$"; + }; } diff --git a/modules/hooks/denofmt.nix b/modules/hooks/denofmt.nix index 20875dbf..2ee19653 100644 --- a/modules/hooks/denofmt.nix +++ b/modules/hooks/denofmt.nix @@ -1,6 +1,15 @@ -{ lib, ... }: +{ tools, config, lib, ... }: let inherit (lib) mkOption types; + + mkCmdArgs = predActionList: + lib.concatStringsSep + " " + (builtins.foldl' + (acc: entry: + acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) + [ ] + predActionList); in { options.settings = { @@ -19,4 +28,20 @@ in default = ""; }; }; + + config = { + name = "denofmt"; + description = "Auto-format JavaScript, TypeScript, Markdown, and JSON files."; + types_or = [ "javascript" "jsx" "ts" "tsx" "markdown" "json" ]; + package = tools.deno; + entry = + let + cmdArgs = + mkCmdArgs [ + [ (!config.settings.write) "--check" ] + [ (config.settings.configPath != "") "-c ${config.settings.configPath}" ] + ]; + in + "${tools.deno}/bin/deno fmt ${cmdArgs}"; + }; } diff --git a/modules/hooks/denolint.nix b/modules/hooks/denolint.nix index 1b7d6860..d72851b2 100644 --- a/modules/hooks/denolint.nix +++ b/modules/hooks/denolint.nix @@ -1,6 +1,15 @@ -{ lib, ... }: +{ tools, config, lib, ... }: let inherit (lib) mkOption types; + + mkCmdArgs = predActionList: + lib.concatStringsSep + " " + (builtins.foldl' + (acc: entry: + acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) + [ ] + predActionList); in { options.settings = { @@ -20,4 +29,21 @@ in default = ""; }; }; + + config = { + name = "denolint"; + description = "Lint JavaScript/TypeScript source code."; + types_or = [ "javascript" "jsx" "ts" "tsx" ]; + package = tools.deno; + entry = + let + cmdArgs = + mkCmdArgs [ + [ (config.settings.format == "compact") "--compact" ] + [ (config.settings.format == "json") "--json" ] + [ (config.settings.configPath != "") "-c ${config.settings.configPath}" ] + ]; + in + "${tools.deno}/bin/deno lint ${cmdArgs}"; + }; } diff --git a/modules/hooks/detect-aws-credentials.nix b/modules/hooks/detect-aws-credentials.nix new file mode 100644 index 00000000..352dcf25 --- /dev/null +++ b/modules/hooks/detect-aws-credentials.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "detect-aws-credentials"; + description = "Detect AWS credentials from the AWS cli credentials file."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/detect-aws-credentials --allow-missing-credentials"; + types = [ "text" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/detect-private-keys.nix b/modules/hooks/detect-private-keys.nix new file mode 100644 index 00000000..daa8e735 --- /dev/null +++ b/modules/hooks/detect-private-keys.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "detect-private-keys"; + description = "Detect the presence of private keys."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/detect-private-key"; + types = [ "text" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/dhall-format.nix b/modules/hooks/dhall-format.nix new file mode 100644 index 00000000..4909e142 --- /dev/null +++ b/modules/hooks/dhall-format.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "dhall-format"; + description = "Dhall code formatter."; + package = tools.dhall; + entry = "${tools.dhall}/bin/dhall format"; + files = "\.dhall$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/dialyzer.nix b/modules/hooks/dialyzer.nix new file mode 100644 index 00000000..73ef07c1 --- /dev/null +++ b/modules/hooks/dialyzer.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "dialyzer"; + description = "Runs a static code analysis using Dialyzer"; + package = tools.elixir; + entry = "${tools.elixir}/bin/mix dialyzer"; + files = "\.exs?$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/dune-opam-sync.nix b/modules/hooks/dune-opam-sync.nix new file mode 100644 index 00000000..a5c66cff --- /dev/null +++ b/modules/hooks/dune-opam-sync.nix @@ -0,0 +1,14 @@ +{ tools, lib, ... }: +{ + config = { + name = "dune/opam sync"; + description = "Check that Dune-generated OPAM files are in sync."; + package = tools.dune-build-opam-files; + entry = "${tools.dune-build-opam-files}/bin/dune-build-opam-files"; + files = "(\.opam$)|(\.opam.template$)|((^|/)dune-project$)"; + ## We don't pass filenames because they can only be misleading. Indeed, + ## we need to re-run `dune build` for every `*.opam` file, but also when + ## the `dune-project` file has changed. + pass_filenames = false; + }; +} \ No newline at end of file diff --git a/modules/hooks/eclint.nix b/modules/hooks/eclint.nix index 6b1055ba..cad96591 100644 --- a/modules/hooks/eclint.nix +++ b/modules/hooks/eclint.nix @@ -1,6 +1,15 @@ -{ lib, ... }: +{ tools, config, lib, ... }: let inherit (lib) mkOption types; + + mkCmdArgs = predActionList: + lib.concatStringsSep + " " + (builtins.foldl' + (acc: entry: + acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) + [ ] + predActionList); in { options.settings = { @@ -35,4 +44,24 @@ in default = 0; }; }; + + config = { + name = "eclint"; + description = "EditorConfig linter written in Go."; + types = [ "file" ]; + package = tools.eclint; + entry = + let + cmdArgs = + mkCmdArgs + (with config.settings; [ + [ fix "-fix" ] + [ summary "-summary" ] + [ (color != "auto") "-color ${color}" ] + [ (exclude != [ ]) "-exclude ${lib.escapeShellArgs exclude}" ] + [ (verbosity != 0) "-verbosity ${toString verbosity}" ] + ]); + in + "${tools.eclint}/bin/eclint ${cmdArgs}"; + }; } diff --git a/modules/hooks/editorconfig-checker.nix b/modules/hooks/editorconfig-checker.nix new file mode 100644 index 00000000..cdb7adb5 --- /dev/null +++ b/modules/hooks/editorconfig-checker.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "editorconfig-checker"; + description = "Verify that the files are in harmony with the `.editorconfig`."; + package = tools.editorconfig-checker; + entry = "${tools.editorconfig-checker}/bin/editorconfig-checker"; + types = [ "file" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/elm-format.nix b/modules/hooks/elm-format.nix new file mode 100644 index 00000000..cbe60e91 --- /dev/null +++ b/modules/hooks/elm-format.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "elm-format"; + description = "Format Elm files."; + package = tools.elm-format; + entry = "${tools.elm-format}/bin/elm-format --yes --elm-version=0.19"; + files = "\.elm$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/elm-review.nix b/modules/hooks/elm-review.nix new file mode 100644 index 00000000..c429b366 --- /dev/null +++ b/modules/hooks/elm-review.nix @@ -0,0 +1,11 @@ +{ tools, lib, ... }: +{ + config = { + name = "elm-review"; + description = "Analyzes Elm projects, to help find mistakes before your users find them."; + package = tools.elm-review; + entry = "${tools.elm-review}/bin/elm-review"; + files = "\.elm$"; + pass_filenames = false; + }; +} \ No newline at end of file diff --git a/modules/hooks/elm-test.nix b/modules/hooks/elm-test.nix new file mode 100644 index 00000000..fc3d2509 --- /dev/null +++ b/modules/hooks/elm-test.nix @@ -0,0 +1,11 @@ +{ tools, lib, ... }: +{ + config = { + name = "elm-test"; + description = "Run unit tests and fuzz tests for Elm code."; + package = tools.elm-test; + entry = "${tools.elm-test}/bin/elm-test"; + files = "\.elm$"; + pass_filenames = false; + }; +} \ No newline at end of file diff --git a/modules/hooks/end-of-file-fixer.nix b/modules/hooks/end-of-file-fixer.nix new file mode 100644 index 00000000..ef6e2f33 --- /dev/null +++ b/modules/hooks/end-of-file-fixer.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "end-of-file-fixer"; + description = "Ensures that a file is either empty, or ends with a single newline."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/end-of-file-fixer"; + types = [ "text" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/eslint.nix b/modules/hooks/eslint.nix index 3af6de10..a62512b7 100644 --- a/modules/hooks/eslint.nix +++ b/modules/hooks/eslint.nix @@ -1,6 +1,11 @@ -{ lib, ... }: +{ tools, config, lib, ... }: let inherit (lib) mkOption types; + + migrateBinPathToPackage = hook: binPath: + if hook.settings.binPath == null + then "${hook.package}${binPath}" + else hook.settings.binPath; in { options.settings = { @@ -29,4 +34,16 @@ in default = "\\.js$"; }; }; + + config = { + name = "eslint"; + description = "Find and fix problems in your JavaScript code."; + package = tools.eslint; + entry = + let + binPath = migrateBinPathToPackage config "/bin/eslint"; + in + "${binPath} --fix"; + files = "${config.settings.extensions}"; + }; } diff --git a/modules/hooks/fix-byte-order-marker.nix b/modules/hooks/fix-byte-order-marker.nix new file mode 100644 index 00000000..d9d85cf2 --- /dev/null +++ b/modules/hooks/fix-byte-order-marker.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "fix-byte-order-marker"; + description = "Remove UTF-8 byte order marker."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/fix-byte-order-marker"; + types = [ "text" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/fix-encoding-pragma.nix b/modules/hooks/fix-encoding-pragma.nix new file mode 100644 index 00000000..a686d315 --- /dev/null +++ b/modules/hooks/fix-encoding-pragma.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "fix-encoding-pragma"; + description = "Adds # -*- coding: utf-8 -*- to the top of Python files.'"; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/fix-encoding-pragma"; + types = [ "python" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/flake-checker.nix b/modules/hooks/flake-checker.nix new file mode 100644 index 00000000..067d3ed8 --- /dev/null +++ b/modules/hooks/flake-checker.nix @@ -0,0 +1,11 @@ +{ tools, lib, ... }: +{ + config = { + name = "flake-checker"; + description = "Run health checks on your flake-powered Nix projects."; + package = tools.flake-checker; + entry = "${tools.flake-checker}/bin/flake-checker -f"; + files = "(^flake\.nix$|^flake\.lock$)"; + pass_filenames = false; + }; +} \ No newline at end of file diff --git a/modules/hooks/flake8.nix b/modules/hooks/flake8.nix index d2e388a4..1e4fb428 100644 --- a/modules/hooks/flake8.nix +++ b/modules/hooks/flake8.nix @@ -1,6 +1,16 @@ -{ lib, ... }: +{ tools, config, lib, ... }: let inherit (lib) mkOption types; + + migrateBinPathToPackage = hook: binPath: + if hook.settings.binPath == null + then "${hook.package}${binPath}" + else hook.settings.binPath; + + extendIgnoreStr = + if lib.lists.length config.settings.extendIgnore > 0 + then "--extend-ignore " + builtins.concatStringsSep "," config.settings.extendIgnore + else ""; in { options.settings = { @@ -27,4 +37,16 @@ in default = "default"; }; }; + + config = { + name = "flake8"; + description = "Check the style and quality of Python files."; + package = tools.flake8; + entry = + let + binPath = migrateBinPathToPackage config "/bin/flake8"; + in + "${binPath} --format ${config.settings.format} ${extendIgnoreStr}"; + types = [ "python" ]; + }; } diff --git a/modules/hooks/flynt.nix b/modules/hooks/flynt.nix index 5b15ea45..df882f9e 100644 --- a/modules/hooks/flynt.nix +++ b/modules/hooks/flynt.nix @@ -1,6 +1,20 @@ -{ lib, ... }: +{ tools, config, lib, ... }: let inherit (lib) mkOption types; + + mkCmdArgs = predActionList: + lib.concatStringsSep + " " + (builtins.foldl' + (acc: entry: + acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) + [ ] + predActionList); + + migrateBinPathToPackage = hook: binPath: + if hook.settings.binPath == null + then "${hook.package}${binPath}" + else hook.settings.binPath; in { options.settings = { @@ -71,4 +85,29 @@ in default = false; }; }; + + config = { + name = "flynt"; + description = "CLI tool to convert a python project's %-formatted strings to f-strings."; + package = tools.flynt; + entry = + let + binPath = migrateBinPathToPackage config "/bin/flynt"; + cmdArgs = + mkCmdArgs (with config.settings; [ + [ aggressive "--aggressive" ] + [ dry-run "--dry-run" ] + [ (exclude != [ ]) "--exclude ${lib.escapeShellArgs exclude}" ] + [ fail-on-change "--fail-on-change" ] + [ (line-length != null) "--line-length ${toString line-length}" ] + [ no-multiline "--no-multiline" ] + [ quiet "--quiet" ] + [ string "--string" ] + [ transform-concats "--transform-concats" ] + [ verbose "--verbose" ] + ]); + in + "${binPath} ${cmdArgs}"; + types = [ "python" ]; + }; } diff --git a/modules/hooks/forbid-new-submodules.nix b/modules/hooks/forbid-new-submodules.nix new file mode 100644 index 00000000..30aa1f15 --- /dev/null +++ b/modules/hooks/forbid-new-submodules.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "forbid-new-submodules"; + description = "Prevent addition of new Git submodules."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/forbid-new-submodules"; + types = [ "directory" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/fourmolu.nix b/modules/hooks/fourmolu.nix index 3c119e2a..b9c9042c 100644 --- a/modules/hooks/fourmolu.nix +++ b/modules/hooks/fourmolu.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ tools, config, lib, ... }: let inherit (lib) mkOption types; in @@ -10,4 +10,15 @@ in default = [ ]; }; }; + + config = { + name = "fourmolu"; + description = "Haskell code prettifier."; + package = tools.fourmolu; + entry = + "${tools.fourmolu}/bin/fourmolu --mode inplace ${ + lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) config.settings.defaultExtensions) + }"; + files = "\\.l?hs(-boot)?$"; + }; } diff --git a/modules/hooks/fprettify.nix b/modules/hooks/fprettify.nix new file mode 100644 index 00000000..c5f8c698 --- /dev/null +++ b/modules/hooks/fprettify.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "fprettify"; + description = "Auto-formatter for modern Fortran code."; + types = [ "fortran " ]; + package = tools.fprettify; + entry = "${tools.fprettify}/bin/fprettify"; + }; +} \ No newline at end of file diff --git a/modules/hooks/gitlint.nix b/modules/hooks/gitlint.nix new file mode 100644 index 00000000..6d254ce0 --- /dev/null +++ b/modules/hooks/gitlint.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "gitlint"; + description = "Linting for your git commit messages"; + package = tools.gitlint; + entry = "${tools.gitlint}/bin/gitlint --staged --msg-filename"; + stages = [ "commit-msg" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/gofmt.nix b/modules/hooks/gofmt.nix new file mode 100644 index 00000000..1092b9cf --- /dev/null +++ b/modules/hooks/gofmt.nix @@ -0,0 +1,27 @@ +{ tools, lib, pkgs, ... }: +{ + config = { + name = "gofmt"; + description = "A tool that automatically formats Go source code"; + package = tools.go; + entry = + let + script = pkgs.writeShellScript "precommit-gofmt" '' + set -e + failed=false + for file in "$@"; do + # redirect stderr so that violations and summaries are properly interleaved. + if ! ${tools.go}/bin/gofmt -l -w "$file" 2>&1 + then + failed=true + fi + done + if [[ $failed == "true" ]]; then + exit 1 + fi + ''; + in + builtins.toString script; + files = "\\.go$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/golangci-lint.nix b/modules/hooks/golangci-lint.nix new file mode 100644 index 00000000..9cc59f8a --- /dev/null +++ b/modules/hooks/golangci-lint.nix @@ -0,0 +1,22 @@ +{ tools, lib, pkgs, ... }: +{ + config = { + name = "golangci-lint"; + description = "Fast linters runner for Go."; + package = tools.golangci-lint; + entry = + let + script = pkgs.writeShellScript "precommit-golangci-lint" '' + set -e + for dir in $(echo "$@" | xargs -n1 dirname | sort -u); do + ${tools.golangci-lint}/bin/golangci-lint run ./"$dir" + done + ''; + in + builtins.toString script; + files = "\\.go$"; + # to avoid multiple invocations of the same directory input, provide + # all file names in a single run. + require_serial = true; + }; +} \ No newline at end of file diff --git a/modules/hooks/golines.nix b/modules/hooks/golines.nix index 74df9a1b..228a0875 100644 --- a/modules/hooks/golines.nix +++ b/modules/hooks/golines.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ tools, config, lib, pkgs, ... }: let inherit (lib) mkOption types; in @@ -11,4 +11,29 @@ in example = "-m 120"; }; }; + + config = { + name = "golines"; + description = "A golang formatter that fixes long lines"; + package = tools.golines; + entry = + let + script = pkgs.writeShellScript "precommit-golines" '' + set -e + failed=false + for file in "$@"; do + # redirect stderr so that violations and summaries are properly interleaved. + if ! ${tools.golines}/bin/golines ${config.settings.flags} -w "$file" 2>&1 + then + failed=true + fi + done + if [[ $failed == "true" ]]; then + exit 1 + fi + ''; + in + builtins.toString script; + files = "\\.go$"; + }; } diff --git a/modules/hooks/gotest.nix b/modules/hooks/gotest.nix new file mode 100644 index 00000000..7baa138d --- /dev/null +++ b/modules/hooks/gotest.nix @@ -0,0 +1,44 @@ +{ tools, lib, pkgs, ... }: +{ + config = { + name = "gotest"; + description = "Run go tests"; + package = tools.go; + entry = + let + script = pkgs.writeShellScript "precommit-gotest" '' + set -e + # find all directories that contain tests + dirs=() + for file in "$@"; do + # either the file is a test + if [[ "$file" = *_test.go ]]; then + dirs+=("$(dirname "$file")") + continue + fi + + # or the file has an associated test + filename="''${file%.go}" + test_file="''${filename}_test.go" + if [[ -f "$test_file" ]]; then + dirs+=("$(dirname "$test_file")") + continue + fi + done + + # ensure we are not duplicating dir entries + IFS=$'\n' sorted_dirs=($(sort -u <<<"''${dirs[*]}")); unset IFS + + # test each directory one by one + for dir in "''${sorted_dirs[@]}"; do + ${tools.go}/bin/go test "./$dir" + done + ''; + in + builtins.toString script; + files = "\.go$"; + # to avoid multiple invocations of the same directory input, provide + # all file names in a single run. + require_serial = true; + }; +} \ No newline at end of file diff --git a/modules/hooks/govet.nix b/modules/hooks/govet.nix new file mode 100644 index 00000000..0d7a4dd2 --- /dev/null +++ b/modules/hooks/govet.nix @@ -0,0 +1,23 @@ +{ tools, lib, pkgs, ... }: +{ + config = { + name = "govet"; + description = "Checks correctness of Go programs."; + package = tools.go; + entry = + let + # go vet requires package (directory) names as inputs. + script = pkgs.writeShellScript "precommit-govet" '' + set -e + for dir in $(echo "$@" | xargs -n1 dirname | sort -u); do + ${tools.go}/bin/go vet -C ./"$dir" + done + ''; + in + builtins.toString script; + # to avoid multiple invocations of the same directory input, provide + # all file names in a single run. + require_serial = true; + files = "\.go$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/gptcommit.nix b/modules/hooks/gptcommit.nix new file mode 100644 index 00000000..9f34e991 --- /dev/null +++ b/modules/hooks/gptcommit.nix @@ -0,0 +1,19 @@ +{ tools, lib, pkgs, ... }: +{ + config = { + name = "gptcommit"; + description = "Generate a commit message using GPT3."; + package = tools.gptcommit; + entry = + let + script = pkgs.writeShellScript "precommit-gptcomit" '' + ${tools.gptcommit}/bin/gptcommit prepare-commit-msg --commit-source \ + "$PRE_COMMIT_COMMIT_MSG_SOURCE" --commit-msg-file "$1" + ''; + in + lib.throwIf (tools.gptcommit == null) "The version of Nixpkgs used by git-hooks.nix does not have the `gptcommit` package. Please use a more recent version of Nixpkgs." + toString + script; + stages = [ "prepare-commit-msg" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/hadolint.nix b/modules/hooks/hadolint.nix new file mode 100644 index 00000000..68339323 --- /dev/null +++ b/modules/hooks/hadolint.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "hadolint"; + description = "Dockerfile linter, validate inline bash."; + package = tools.hadolint; + entry = "${tools.hadolint}/bin/hadolint"; + files = "Dockerfile$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/headache.nix b/modules/hooks/headache.nix index 98c2d833..2c5dac10 100644 --- a/modules/hooks/headache.nix +++ b/modules/hooks/headache.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ tools, config, lib, ... }: let inherit (lib) mkOption types; in @@ -10,4 +10,20 @@ in default = ".header"; }; }; + + config = { + name = "headache"; + description = "Lightweight tool for managing headers in source code files."; + ## NOTE: Supported `files` are taken from + ## https://github.com/Frama-C/headache/blob/master/config_builtin.txt + files = "(\\.ml[ily]?$)|(\\.fmli?$)|(\\.[chy]$)|(\\.tex$)|(Makefile)|(README)|(LICENSE)"; + package = tools.headache; + entry = + ## NOTE: `headache` made into in nixpkgs on 12 April 2023. At the + ## next NixOS release, the following code will become irrelevant. + lib.throwIf + (tools.headache == null) + "The version of nixpkgs used by git-hooks.nix does not have `ocamlPackages.headache`. Please use a more recent version of nixpkgs." + "${tools.headache}/bin/headache -h ${config.settings.header-file}"; + }; } diff --git a/modules/hooks/hindent.nix b/modules/hooks/hindent.nix new file mode 100644 index 00000000..13885f21 --- /dev/null +++ b/modules/hooks/hindent.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "hindent"; + description = "Haskell code prettifier."; + package = tools.hindent; + entry = "${tools.hindent}/bin/hindent"; + files = "\.l?hs$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/html-tidy.nix b/modules/hooks/html-tidy.nix new file mode 100644 index 00000000..079380b8 --- /dev/null +++ b/modules/hooks/html-tidy.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "html-tidy"; + description = "Tidy HTML files."; + package = tools.html-tidy; + entry = "${tools.html-tidy}/bin/tidy -modify -indent -quiet"; + types = [ "html" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/hunspell.nix b/modules/hooks/hunspell.nix new file mode 100644 index 00000000..66f18791 --- /dev/null +++ b/modules/hooks/hunspell.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "hunspell"; + description = "Spell checker and morphological analyzer."; + package = tools.hunspell; + entry = "${tools.hunspell}/bin/hunspell -l"; + types = [ "text" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/juliaformatter.nix b/modules/hooks/juliaformatter.nix new file mode 100644 index 00000000..72a88508 --- /dev/null +++ b/modules/hooks/juliaformatter.nix @@ -0,0 +1,11 @@ +{ tools, lib, ... }: +{ + config = { + name = "juliaformatter"; + description = "Format Julia files."; + package = tools.julia-bin; + entry = "${tools.julia-bin}/bin/julia -e 'using JuliaFormatter; format(".")'"; + files = "\.jl$"; + pass_filenames = false; + }; +} \ No newline at end of file diff --git a/modules/hooks/luacheck.nix b/modules/hooks/luacheck.nix new file mode 100644 index 00000000..136dc80e --- /dev/null +++ b/modules/hooks/luacheck.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "luacheck"; + description = "A tool for linting and static analysis of Lua code."; + package = tools.luacheck; + entry = "${tools.luacheck}/bin/luacheck"; + types = [ "lua" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/mdformat.nix b/modules/hooks/mdformat.nix new file mode 100644 index 00000000..240409ce --- /dev/null +++ b/modules/hooks/mdformat.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "mdformat"; + description = "CommonMark compliant Markdown formatter."; + package = tools.mdformat; + entry = "${tools.mdformat}/bin/mdformat"; + types = [ "markdown" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/mdsh.nix b/modules/hooks/mdsh.nix new file mode 100644 index 00000000..3a2450b7 --- /dev/null +++ b/modules/hooks/mdsh.nix @@ -0,0 +1,11 @@ +{ tools, lib, ... }: +{ + config = { + name = "mdsh"; + description = "Markdown shell pre-processor."; + package = tools.mdsh; + entry = "${tools.mdsh}/bin/mdsh"; + files = "\.md$"; + pass_filenames = false; + }; +} \ No newline at end of file diff --git a/modules/hooks/mix-format.nix b/modules/hooks/mix-format.nix new file mode 100644 index 00000000..a7a6f2d3 --- /dev/null +++ b/modules/hooks/mix-format.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "mix-format"; + description = "Format Elixir files with mix format."; + package = tools.elixir; + entry = "${tools.elixir}/bin/mix format"; + files = "\.exs?$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/mix-test.nix b/modules/hooks/mix-test.nix new file mode 100644 index 00000000..50bf4667 --- /dev/null +++ b/modules/hooks/mix-test.nix @@ -0,0 +1,11 @@ +{ tools, lib, ... }: +{ + config = { + name = "mix-test"; + description = "Run Elixir tests with mix test."; + package = tools.elixir; + entry = "${tools.elixir}/bin/mix test"; + files = "\.exs?$"; + pass_filenames = false; + }; +} \ No newline at end of file diff --git a/modules/hooks/mixed-line-endings.nix b/modules/hooks/mixed-line-endings.nix new file mode 100644 index 00000000..14a96d6d --- /dev/null +++ b/modules/hooks/mixed-line-endings.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "mixed-line-ending"; + description = "Check for mixed line endings."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/mixed-line-ending"; + types = [ "text" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/name-tests-test.nix b/modules/hooks/name-tests-test.nix new file mode 100644 index 00000000..2c9f0f9c --- /dev/null +++ b/modules/hooks/name-tests-test.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "name-tests-test"; + description = "Verify Python test files are named correctly."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/name-tests-test"; + files = "(^|/)tests/.+\.py$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/nil.nix b/modules/hooks/nil.nix new file mode 100644 index 00000000..cb91912f --- /dev/null +++ b/modules/hooks/nil.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "nil"; + description = "Incremental analysis assistant for writing in Nix."; + package = tools.nil; + entry = "${tools.nil}/bin/nil"; + files = "\.nix$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/nixpkgs-fmt.nix b/modules/hooks/nixpkgs-fmt.nix new file mode 100644 index 00000000..73266c15 --- /dev/null +++ b/modules/hooks/nixpkgs-fmt.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "nixpkgs-fmt"; + description = "Nix code formatter for nixpkgs."; + package = tools.nixpkgs-fmt; + entry = "${tools.nixpkgs-fmt}/bin/nixpkgs-fmt"; + files = "\.nix$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/ocp-indent.nix b/modules/hooks/ocp-indent.nix new file mode 100644 index 00000000..ef6aef3a --- /dev/null +++ b/modules/hooks/ocp-indent.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "ocp-indent"; + description = "A simple tool and library to indent OCaml code."; + package = tools.ocp-indent; + entry = "${tools.ocp-indent}/bin/ocp-indent --inplace"; + files = "\.mli?$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/opam-lint.nix b/modules/hooks/opam-lint.nix new file mode 100644 index 00000000..244f366c --- /dev/null +++ b/modules/hooks/opam-lint.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "opam lint"; + description = "Lint opam package definition files."; + package = tools.opam; + entry = "${tools.opam}/bin/opam lint"; + files = "opam$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/openapi-spec-validator.nix b/modules/hooks/openapi-spec-validator.nix new file mode 100644 index 00000000..6115da55 --- /dev/null +++ b/modules/hooks/openapi-spec-validator.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "openapi-spec-validator"; + description = "Validate OpenAPI specifications."; + package = tools.openapi-spec-validator; + entry = "${tools.openapi-spec-validator}/bin/openapi-spec-validator"; + files = "\.ya?ml$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/poetry-check.nix b/modules/hooks/poetry-check.nix new file mode 100644 index 00000000..153bd9a7 --- /dev/null +++ b/modules/hooks/poetry-check.nix @@ -0,0 +1,11 @@ +{ tools, lib, ... }: +{ + config = { + name = "poetry-check"; + description = "Check the validity of the pyproject.toml file."; + package = tools.poetry; + entry = "${tools.poetry}/bin/poetry check"; + files = "pyproject\.toml$"; + pass_filenames = false; + }; +} \ No newline at end of file diff --git a/modules/hooks/poetry-lock.nix b/modules/hooks/poetry-lock.nix new file mode 100644 index 00000000..8718b45f --- /dev/null +++ b/modules/hooks/poetry-lock.nix @@ -0,0 +1,11 @@ +{ tools, lib, ... }: +{ + config = { + name = "poetry-lock"; + description = "Update the poetry.lock file."; + package = tools.poetry; + entry = "${tools.poetry}/bin/poetry lock"; + files = "pyproject\.toml$"; + pass_filenames = false; + }; +} \ No newline at end of file diff --git a/modules/hooks/pre-commit-hook-ensure-sops.nix b/modules/hooks/pre-commit-hook-ensure-sops.nix new file mode 100644 index 00000000..894ef33c --- /dev/null +++ b/modules/hooks/pre-commit-hook-ensure-sops.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "pre-commit-hook-ensure-sops"; + description = "Ensure that sops files are encrypted."; + package = tools.pre-commit-hook-ensure-sops; + entry = "${tools.pre-commit-hook-ensure-sops}/bin/pre-commit-hook-ensure-sops"; + files = "\.sops\.(ya?ml|json)$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/purs-tidy.nix b/modules/hooks/purs-tidy.nix new file mode 100644 index 00000000..0a685382 --- /dev/null +++ b/modules/hooks/purs-tidy.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "purs-tidy"; + description = "Format PureScript files with purs-tidy."; + package = tools.purs-tidy; + entry = "${tools.purs-tidy}/bin/purs-tidy format-in-place"; + files = "\.purs$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/python-debug-statements.nix b/modules/hooks/python-debug-statements.nix new file mode 100644 index 00000000..188ea3cf --- /dev/null +++ b/modules/hooks/python-debug-statements.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "debug-statements"; + description = "Check for debugger imports and py37+ `breakpoint()` calls in python source."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/debug-statement-hook"; + types = [ "python" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/rome.nix b/modules/hooks/rome.nix index ba743dd4..fd04098d 100644 --- a/modules/hooks/rome.nix +++ b/modules/hooks/rome.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ config, lib, tools, ... }: let inherit (lib) mkOption types; in @@ -36,4 +36,21 @@ in default = ""; }; }; + + config = { + name = "rome-deprecated"; + description = ""; + types_or = [ "javascript" "jsx" "ts" "tsx" "json" ]; + package = tools.biome; + entry = + let + binPath = migrateBinPathToPackage config "/bin/biome"; + cmdArgs = + mkCmdArgs [ + [ (config.settings.write) "--apply" ] + [ (config.settings.configPath != "") "--config-path ${config.settings.configPath}" ] + ]; + in + "${binPath} check ${cmdArgs}"; + }; } diff --git a/modules/hooks/ruff-format.nix b/modules/hooks/ruff-format.nix new file mode 100644 index 00000000..b3907bcf --- /dev/null +++ b/modules/hooks/ruff-format.nix @@ -0,0 +1,11 @@ +{ tools, lib, ... }: +{ + config = { + name = "ruff-format"; + description = "An extremely fast Python formatter, written in Rust."; + package = tools.ruff; + entry = "${tools.ruff}/bin/ruff format"; + types = [ "python" ]; + require_serial = true; + }; +} \ No newline at end of file diff --git a/modules/hooks/ruff.nix b/modules/hooks/ruff.nix new file mode 100644 index 00000000..ef0c0476 --- /dev/null +++ b/modules/hooks/ruff.nix @@ -0,0 +1,11 @@ +{ tools, lib, ... }: +{ + config = { + name = "ruff"; + description = "An extremely fast Python linter, written in Rust."; + package = tools.ruff; + entry = "${tools.ruff}/bin/ruff check --fix"; + types = [ "python" ]; + require_serial = true; + }; +} \ No newline at end of file diff --git a/modules/hooks/selene.nix b/modules/hooks/selene.nix new file mode 100644 index 00000000..2103633e --- /dev/null +++ b/modules/hooks/selene.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "selene"; + description = "A blazing-fast modern Lua linter."; + package = tools.selene; + entry = "${tools.selene}/bin/selene"; + types = [ "lua" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/shellcheck.nix b/modules/hooks/shellcheck.nix new file mode 100644 index 00000000..7951e8f4 --- /dev/null +++ b/modules/hooks/shellcheck.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "shellcheck"; + description = "ShellCheck is a static analysis tool for shell scripts."; + package = tools.shellcheck; + entry = "${tools.shellcheck}/bin/shellcheck"; + types = [ "shell" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/single-quoted-strings.nix b/modules/hooks/single-quoted-strings.nix new file mode 100644 index 00000000..e838e7b1 --- /dev/null +++ b/modules/hooks/single-quoted-strings.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "single-quoted-strings"; + description = "Replace double quoted strings with single quoted strings."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/single-quoted-strings"; + types = [ "python" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/sort-requirements-txt.nix b/modules/hooks/sort-requirements-txt.nix new file mode 100644 index 00000000..0c26d6c7 --- /dev/null +++ b/modules/hooks/sort-requirements-txt.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "sort-requirements-txt"; + description = "Sort the lines in specified files (defaults to alphabetical)."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/requirements-txt-fixer"; + files = "requirements.*\.txt$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/sort-simple-yaml.nix b/modules/hooks/sort-simple-yaml.nix new file mode 100644 index 00000000..ce73e0d6 --- /dev/null +++ b/modules/hooks/sort-simple-yaml.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "sort-simple-yaml"; + description = "Sort simple YAML files."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/sort-simple-yaml"; + files = "\.ya?ml$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/staticcheck.nix b/modules/hooks/staticcheck.nix new file mode 100644 index 00000000..758f0bc2 --- /dev/null +++ b/modules/hooks/staticcheck.nix @@ -0,0 +1,11 @@ +{ tools, lib, ... }: +{ + config = { + name = "staticcheck"; + description = "A state of the art linter for the Go programming language."; + package = tools.go-tools; + entry = "${tools.go-tools}/bin/staticcheck"; + types = [ "go" ]; + require_serial = true; + }; +} \ No newline at end of file diff --git a/modules/hooks/stylish-haskell.nix b/modules/hooks/stylish-haskell.nix new file mode 100644 index 00000000..2cb7c69d --- /dev/null +++ b/modules/hooks/stylish-haskell.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "stylish-haskell"; + description = "A simple Haskell code prettifier."; + package = tools.stylish-haskell; + entry = "${tools.stylish-haskell}/bin/stylish-haskell --inplace"; + files = "\.l?hs$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/stylua.nix b/modules/hooks/stylua.nix new file mode 100644 index 00000000..6c9be792 --- /dev/null +++ b/modules/hooks/stylua.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "stylua"; + description = "An opinionated code formatter for Lua."; + package = tools.stylua; + entry = "${tools.stylua}/bin/stylua"; + types = [ "lua" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/tagref.nix b/modules/hooks/tagref.nix new file mode 100644 index 00000000..03f736e4 --- /dev/null +++ b/modules/hooks/tagref.nix @@ -0,0 +1,11 @@ +{ tools, lib, ... }: +{ + config = { + name = "tagref"; + description = "Have tagref check all references and tags."; + package = tools.tagref; + entry = "${tools.tagref}/bin/tagref"; + types = [ "text" ]; + pass_filenames = false; + }; +} \ No newline at end of file diff --git a/modules/hooks/taplo.nix b/modules/hooks/taplo.nix new file mode 100644 index 00000000..a9084f3b --- /dev/null +++ b/modules/hooks/taplo.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "taplo"; + description = "Format TOML files with taplo fmt."; + package = tools.taplo; + entry = "${tools.taplo}/bin/taplo format"; + types = [ "toml" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/terraform-format.nix b/modules/hooks/terraform-format.nix new file mode 100644 index 00000000..46364e77 --- /dev/null +++ b/modules/hooks/terraform-format.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "terraform-format"; + description = "Format terraform files."; + package = tools.terraform; + entry = "${tools.terraform}/bin/terraform fmt"; + files = "\.tf$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/terraform-validate.nix b/modules/hooks/terraform-validate.nix new file mode 100644 index 00000000..3058d4ec --- /dev/null +++ b/modules/hooks/terraform-validate.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "terraform-validate"; + description = "Validate terraform files."; + package = tools.terraform-validate; + entry = "${tools.terraform-validate}/bin/terraform-validate"; + files = "\.tf$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/tflint.nix b/modules/hooks/tflint.nix new file mode 100644 index 00000000..9beada60 --- /dev/null +++ b/modules/hooks/tflint.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "tflint"; + description = "A Pluggable Terraform Linter."; + package = tools.tflint; + entry = "${tools.tflint}/bin/tflint"; + files = "\.tf$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/topiary.nix b/modules/hooks/topiary.nix new file mode 100644 index 00000000..0d7df05b --- /dev/null +++ b/modules/hooks/topiary.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "topiary"; + description = "A universal formatter engine."; + package = tools.topiary; + entry = "${tools.topiary}/bin/topiary format"; + pass_filenames = false; + }; +} \ No newline at end of file diff --git a/modules/hooks/trim-trailing-whitespace.nix b/modules/hooks/trim-trailing-whitespace.nix new file mode 100644 index 00000000..590b705d --- /dev/null +++ b/modules/hooks/trim-trailing-whitespace.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "trailing-whitespace"; + description = "Trim trailing whitespace."; + package = tools.pre-commit-hooks; + entry = "${tools.pre-commit-hooks}/bin/trailing-whitespace-fixer"; + types = [ "text" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/trufflehog.nix b/modules/hooks/trufflehog.nix new file mode 100644 index 00000000..b0f662ae --- /dev/null +++ b/modules/hooks/trufflehog.nix @@ -0,0 +1,16 @@ +{ tools, lib, pkgs, ... }: +{ + config = { + name = "trufflehog"; + description = "Detect secrets in your data."; + package = tools.trufflehog; + entry = + let + script = pkgs.writeShellScript "precommit-trufflehog" '' + trufflehog git file://$(git rev-parse --show-toplevel) --since-commit HEAD --only-verified --fail + ''; + in + "${tools.trufflehog}/bin/trufflehog git file://$(git rev-parse --show-toplevel) --since-commit HEAD --only-verified --fail"; + types = [ "text" ]; + }; +} \ No newline at end of file diff --git a/modules/hooks/typstfmt.nix b/modules/hooks/typstfmt.nix new file mode 100644 index 00000000..ef8e3798 --- /dev/null +++ b/modules/hooks/typstfmt.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "typstfmt"; + description = "Format Typst files."; + package = tools.typstfmt; + entry = "${tools.typstfmt}/bin/typstfmt"; + files = "\.typ$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/typstyle.nix b/modules/hooks/typstyle.nix new file mode 100644 index 00000000..dcd14919 --- /dev/null +++ b/modules/hooks/typstyle.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "typstyle"; + description = "Format Typst files with typstyle."; + package = tools.typstyle; + entry = "${tools.typstyle}/bin/typstyle"; + files = "\.typ$"; + }; +} \ No newline at end of file diff --git a/modules/hooks/zprint.nix b/modules/hooks/zprint.nix new file mode 100644 index 00000000..190c190b --- /dev/null +++ b/modules/hooks/zprint.nix @@ -0,0 +1,10 @@ +{ tools, lib, ... }: +{ + config = { + name = "zprint"; + description = "Clojure/ClojureScript source code formatting."; + package = tools.zprint; + entry = "${tools.zprint}/bin/zprint '{:search-config? true}' -w"; + types_or = [ "clojure" "clojurescript" "edn" ]; + }; +} \ No newline at end of file From 06ac11645fadb299c5d169cb6d2d88f13a3073be Mon Sep 17 00:00:00 2001 From: Sander Date: Mon, 26 May 2025 00:59:08 +0200 Subject: [PATCH 04/13] hooks: pass in tools --- modules/hooks.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hooks.nix b/modules/hooks.nix index d65041f7..ebb26aaf 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -61,7 +61,7 @@ in config.hookModule = { imports = [ ./hook.nix ]; - config._module.args.default_stages = cfg.default_stages; + config._module.args = { inherit (cfg) default_stages tools; }; }; config._module.args.hookModule = config.hookModule; From b20d9995ddffc1ad059db29483489dd63a05fd8f Mon Sep 17 00:00:00 2001 From: Sander Date: Mon, 26 May 2025 00:59:47 +0200 Subject: [PATCH 05/13] hooks: add default to each hook --- modules/hooks.nix | 304 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 304 insertions(+) diff --git a/modules/hooks.nix b/modules/hooks.nix index ebb26aaf..68228122 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -90,342 +90,399 @@ in type = types.submodule { imports = [ hookModule ./hooks/actionlint.nix ]; }; + default = { }; }; alejandra = mkOption { description = "alejandra hook"; type = types.submodule { imports = [ hookModule ./hooks/alejandra.nix ]; }; + default = { }; }; annex = mkOption { description = "annex hook"; type = types.submodule { imports = [ hookModule ./hooks/annex.nix ]; }; + default = { }; }; ansible-lint = mkOption { description = "ansible-lint hook"; type = types.submodule { imports = [ hookModule ./hooks/ansible-lint.nix ]; }; + default = { }; }; autoflake = mkOption { description = "autoflake hook"; type = types.submodule { imports = [ hookModule ./hooks/autoflake.nix ]; }; + default = { }; }; bats = mkOption { description = "bats hook"; type = types.submodule { imports = [ hookModule ./hooks/bats.nix ]; }; + default = { }; }; beautysh = mkOption { description = "beautysh hook"; type = types.submodule { imports = [ hookModule ./hooks/beautysh.nix ]; }; + default = { }; }; biome = mkOption { description = "biome hook"; type = types.submodule { imports = [ hookModule ./hooks/biome.nix ]; }; + default = { }; }; black = mkOption { description = "black hook"; type = types.submodule { imports = [ hookModule ./hooks/black.nix ]; }; + default = { }; }; cabal-fmt = mkOption { description = "cabal-fmt hook"; type = types.submodule { imports = [ hookModule ./hooks/cabal-fmt.nix ]; }; + default = { }; }; cabal-gild = mkOption { description = "cabal-gild hook"; type = types.submodule { imports = [ hookModule ./hooks/cabal-gild.nix ]; }; + default = { }; }; cabal2nix = mkOption { description = "cabal2nix hook"; type = types.submodule { imports = [ hookModule ./hooks/cabal2nix.nix ]; }; + default = { }; }; cargo-check = mkOption { description = "cargo-check hook"; type = types.submodule { imports = [ hookModule ./hooks/cargo-check.nix ]; }; + default = { }; }; check-added-large-files = mkOption { description = "check-added-large-files hook"; type = types.submodule { imports = [ hookModule ./hooks/check-added-large-files.nix ]; }; + default = { }; }; check-builtin-literals = mkOption { description = "check-builtin-literals hook"; type = types.submodule { imports = [ hookModule ./hooks/check-builtin-literals.nix ]; }; + default = { }; }; check-case-conflicts = mkOption { description = "check-case-conflicts hook"; type = types.submodule { imports = [ hookModule ./hooks/check-case-conflicts.nix ]; }; + default = { }; }; check-docstring-first = mkOption { description = "check-docstring-first hook"; type = types.submodule { imports = [ hookModule ./hooks/check-docstring-first.nix ]; }; + default = { }; }; check-executables-have-shebangs = mkOption { description = "check-executables-have-shebangs hook"; type = types.submodule { imports = [ hookModule ./hooks/check-executables-have-shebangs.nix ]; }; + default = { }; }; check-json = mkOption { description = "check-json hook"; type = types.submodule { imports = [ hookModule ./hooks/check-json.nix ]; }; + default = { }; }; check-merge-conflicts = mkOption { description = "check-merge-conflicts hook"; type = types.submodule { imports = [ hookModule ./hooks/check-merge-conflicts.nix ]; }; + default = { }; }; check-python = mkOption { description = "check-python hook"; type = types.submodule { imports = [ hookModule ./hooks/check-python.nix ]; }; + default = { }; }; check-shebang-scripts-are-executable = mkOption { description = "check-shebang-scripts-are-executable hook"; type = types.submodule { imports = [ hookModule ./hooks/check-shebang-scripts-are-executable.nix ]; }; + default = { }; }; check-symlinks = mkOption { description = "check-symlinks hook"; type = types.submodule { imports = [ hookModule ./hooks/check-symlinks.nix ]; }; + default = { }; }; check-toml = mkOption { description = "check-toml hook"; type = types.submodule { imports = [ hookModule ./hooks/check-toml.nix ]; }; + default = { }; }; check-vcs-permalinks = mkOption { description = "check-vcs-permalinks hook"; type = types.submodule { imports = [ hookModule ./hooks/check-vcs-permalinks.nix ]; }; + default = { }; }; check-xml = mkOption { description = "check-xml hook"; type = types.submodule { imports = [ hookModule ./hooks/check-xml.nix ]; }; + default = { }; }; check-yaml = mkOption { description = "check-yaml hook"; type = types.submodule { imports = [ hookModule ./hooks/check-yaml.nix ]; }; + default = { }; }; checkmake = mkOption { description = "checkmake hook"; type = types.submodule { imports = [ hookModule ./hooks/checkmake.nix ]; }; + default = { }; }; chktex = mkOption { description = "chktex hook"; type = types.submodule { imports = [ hookModule ./hooks/chktex.nix ]; }; + default = { }; }; circleci = mkOption { description = "circleci hook"; type = types.submodule { imports = [ hookModule ./hooks/circleci.nix ]; }; + default = { }; }; clang-format = mkOption { description = "clang-format hook"; type = types.submodule { imports = [ hookModule ./hooks/clang-format.nix ]; }; + default = { }; }; clang-tidy = mkOption { description = "clang-tidy hook"; type = types.submodule { imports = [ hookModule ./hooks/clang-tidy.nix ]; }; + default = { }; }; clippy = mkOption { description = "clippy hook"; type = types.submodule { imports = [ hookModule ./hooks/clippy.nix ]; }; + default = { }; }; cmake-format = mkOption { description = "cmake-format hook"; type = types.submodule { imports = [ hookModule ./hooks/cmake-format.nix ]; }; + default = { }; }; credo = mkOption { description = "credo hook"; type = types.submodule { imports = [ hookModule ./hooks/credo.nix ]; }; + default = { }; }; deadnix = mkOption { description = "deadnix hook"; type = types.submodule { imports = [ hookModule ./hooks/deadnix.nix ]; }; + default = { }; }; denofmt = mkOption { description = "denofmt hook"; type = types.submodule { imports = [ hookModule ./hooks/denofmt.nix ]; }; + default = { }; }; denolint = mkOption { description = "denolint hook"; type = types.submodule { imports = [ hookModule ./hooks/denolint.nix ]; }; + default = { }; }; dune-fmt = mkOption { description = "dune-fmt hook"; type = types.submodule { imports = [ hookModule ./hooks/dune-fmt.nix ]; }; + default = { }; }; eclint = mkOption { description = "eclint hook"; type = types.submodule { imports = [ hookModule ./hooks/eclint.nix ]; }; + default = { }; }; eslint = mkOption { description = "eslint hook"; type = types.submodule { imports = [ hookModule ./hooks/eslint.nix ]; }; + default = { }; }; flake8 = mkOption { description = "flake8 hook"; type = types.submodule { imports = [ hookModule ./hooks/flake8.nix ]; }; + default = { }; }; flynt = mkOption { description = "flynt hook"; type = types.submodule { imports = [ hookModule ./hooks/flynt.nix ]; }; + default = { }; }; fourmolu = mkOption { description = "fourmolu hook"; type = types.submodule { imports = [ hookModule ./hooks/fourmolu.nix ]; }; + default = { }; }; golines = mkOption { description = "golines hook"; type = types.submodule { imports = [ hookModule ./hooks/golines.nix ]; }; + default = { }; }; headache = mkOption { description = "headache hook"; type = types.submodule { imports = [ hookModule ./hooks/headache.nix ]; }; + default = { }; }; hlint = mkOption { description = "hlint hook"; type = types.submodule { imports = [ hookModule ./hooks/hlint.nix ]; }; + default = { }; }; hpack = mkOption { description = "hpack hook"; type = types.submodule { imports = [ hookModule ./hooks/hpack.nix ]; }; + default = { }; }; isort = mkOption { description = "isort hook"; type = types.submodule { imports = [ hookModule ./hooks/isort.nix ]; }; + default = { }; }; latexindent = mkOption { description = "latexindent hook"; type = types.submodule { imports = [ hookModule ./hooks/latexindent.nix ]; }; + default = { }; }; lacheck = mkOption { description = "lacheck hook"; type = types.submodule { imports = [ hookModule ./hooks/lacheck.nix ]; }; + default = { }; }; lua-ls = mkOption { description = "lua-ls hook"; type = types.submodule { imports = [ hookModule ./hooks/lua-ls.nix ]; }; + default = { }; }; lychee = mkOption { description = "lychee hook"; type = types.submodule { imports = [ hookModule ./hooks/lychee.nix ]; }; + default = { }; }; markdownlint = mkOption { description = "markdownlint hook"; type = types.submodule { imports = [ hookModule ./hooks/markdownlint.nix ]; }; + default = { }; }; mdl = mkOption { description = "mdl hook"; type = types.submodule { imports = [ hookModule ./hooks/mdl.nix ]; }; + default = { }; }; mkdocs-linkcheck = mkOption { description = "mkdocs-linkcheck hook"; type = types.submodule { imports = [ hookModule ./hooks/mkdocs-linkcheck.nix ]; }; + default = { }; }; mypy = mkOption { description = "mypy hook"; type = types.submodule { imports = [ hookModule ./hooks/mypy.nix ]; }; + default = { }; }; nixfmt = mkOption { description = "Deprecated nixfmt hook. Use nixfmt-classic or nixfmt-rfc-style instead."; @@ -433,54 +490,70 @@ in type = types.submodule { imports = [ hookModule ./hooks/nixfmt.nix ]; }; + default = { }; }; nixfmt-classic = mkOption { description = "nixfmt (classic) hook"; type = types.submodule { imports = [ hookModule ./hooks/nixfmt-classic.nix ]; }; + default = { }; }; nixfmt-rfc-style = mkOption { description = "nixfmt (RFC 166 style) hook"; type = types.submodule { imports = [ hookModule ./hooks/nixfmt-rfc-style.nix ]; }; + default = { }; + }; + nixpkgs-fmt = mkOption { + description = "nixpkgs-fmt hook"; + type = types.submodule { + imports = [ hookModule ./hooks/nixpkgs-fmt.nix ]; + }; + default = { }; }; no-commit-to-branch = mkOption { description = "no-commit-to-branch-hook"; type = types.submodule { imports = [ hookModule ./hooks/no-commit-to-branch.nix ]; }; + default = { }; }; ormolu = mkOption { description = "ormolu hook"; type = types.submodule { imports = [ hookModule ./hooks/ormolu.nix ]; }; + default = { }; }; php-cs-fixer = mkOption { description = "php-cs-fixer hook"; type = types.submodule { imports = [ hookModule ./hooks/php-cs-fixer.nix ]; }; + default = { }; }; phpcbf = mkOption { description = "phpcbf hook"; type = types.submodule { imports = [ hookModule ./hooks/phpcbf.nix ]; }; + default = { }; }; phpcs = mkOption { description = "phpcs hook"; type = types.submodule { imports = [ hookModule ./hooks/phpcs.nix ]; }; + default = { }; }; phpstan = mkOption { description = "phpstan hook"; type = types.submodule { imports = [ hookModule ./hooks/phpstan.nix ]; }; + default = { }; }; # See all CLI flags for prettier [here](https://prettier.io/docs/en/cli.html). # See all options for prettier [here](https://prettier.io/docs/en/options.html). @@ -489,6 +562,7 @@ in type = types.submodule { imports = [ hookModule ./hooks/prettier.nix ]; }; + default = { }; }; pretty-format-json = mkOption { @@ -496,54 +570,63 @@ in type = types.submodule { imports = [ hookModule ./hooks/pretty-format-json.nix ]; }; + default = { }; }; proselint = mkOption { description = "proselint hook"; type = types.submodule { imports = [ hookModule ./hooks/proselint.nix ]; }; + default = { }; }; psalm = mkOption { description = "psalm hook"; type = types.submodule { imports = [ hookModule ./hooks/psalm.nix ]; }; + default = { }; }; pylint = mkOption { description = "pylint hook"; type = types.submodule { imports = [ hookModule ./hooks/pylint.nix ]; }; + default = { }; }; pyright = mkOption { description = "pyright hook"; type = types.submodule { imports = [ hookModule ./hooks/pyright.nix ]; }; + default = { }; }; pyupgrade = mkOption { description = "pyupgrade hook"; type = types.submodule { imports = [ hookModule ./hooks/pyupgrade.nix ]; }; + default = { }; }; reuse = mkOption { description = "reuse hook"; type = types.submodule { imports = [ hookModule ./hooks/reuse.nix ]; }; + default = { }; }; revive = mkOption { description = "revive hook"; type = types.submodule { imports = [ hookModule ./hooks/revive.nix ]; }; + default = { }; }; ripsecrets = mkOption { description = "ripsecrets hook"; type = types.submodule { imports = [ hookModule ./hooks/ripsecrets.nix ]; }; + default = { }; }; rome = mkOption { description = "Deprecated rome hook. Use biome instead."; @@ -551,6 +634,7 @@ in type = types.submodule { imports = [ hookModule ./hooks/rome.nix ]; }; + default = { }; }; rustfmt = mkOption { description = '' @@ -567,24 +651,28 @@ in modules = [ hookModule ./hooks/rustfmt.nix ]; specialArgs = { rustSettings = config.settings.rust; }; }; + default = { }; }; shfmt = mkOption { description = "shfmt hook"; type = types.submodule { imports = [ hookModule ./hooks/shfmt.nix ]; }; + default = { }; }; statix = mkOption { description = "statix hook"; type = types.submodule { imports = [ hookModule ./hooks/statix.nix ]; }; + default = { }; }; sort-file-contents = mkOption { description = "sort-file-contents-hook"; type = types.submodule { imports = [ hookModule ./hooks/sort-file-contents.nix ]; }; + default = { }; }; treefmt = mkOption { description = '' @@ -608,30 +696,246 @@ in type = types.submodule { imports = [ hookModule ./hooks/treefmt.nix ]; }; + default = { }; }; typos = mkOption { description = "typos hook"; type = types.submodule { imports = [ hookModule ./hooks/typos.nix ]; }; + default = { }; }; vale = mkOption { description = "vale hook"; type = types.submodule { imports = [ hookModule ./hooks/vale.nix ]; }; + default = { }; }; yamlfmt = mkOption { description = "yamlfmt hook"; type = types.submodule { imports = [ hookModule ./hooks/yamlfmt.nix ]; }; + default = { }; }; yamllint = mkOption { description = "yamllint hook"; type = types.submodule { imports = [ hookModule ./hooks/yamllint.nix ]; }; + default = { }; + }; + # Add missing hooks that were migrated but not yet added to options + cljfmt = mkOption { + description = "cljfmt hook"; + type = types.submodule { + imports = [ hookModule ./hooks/cljfmt.nix ]; + }; + default = { }; + }; + commitizen = mkOption { + description = "commitizen hook"; + type = types.submodule { + imports = [ hookModule ./hooks/commitizen.nix ]; + }; + default = { }; + }; + conform = mkOption { + description = "conform hook"; + type = types.submodule { + imports = [ hookModule ./hooks/conform.nix ]; + }; + default = { }; + }; + convco = mkOption { + description = "convco hook"; + type = types.submodule { + imports = [ hookModule ./hooks/convco.nix ]; + }; + default = { }; + }; + crystal = mkOption { + description = "crystal hook"; + type = types.submodule { + imports = [ hookModule ./hooks/crystal.nix ]; + }; + default = { }; + }; + cspell = mkOption { + description = "cspell hook"; + type = types.submodule { + imports = [ hookModule ./hooks/cspell.nix ]; + }; + default = { }; + }; + dart-analyze = mkOption { + description = "dart-analyze hook"; + type = types.submodule { + imports = [ hookModule ./hooks/dart-analyze.nix ]; + }; + default = { }; + }; + dart-format = mkOption { + description = "dart-format hook"; + type = types.submodule { + imports = [ hookModule ./hooks/dart-format.nix ]; + }; + default = { }; + }; + detect-aws-credentials = mkOption { + description = "detect-aws-credentials hook"; + type = types.submodule { + imports = [ hookModule ./hooks/detect-aws-credentials.nix ]; + }; + default = { }; + }; + detect-private-keys = mkOption { + description = "detect-private-keys hook"; + type = types.submodule { + imports = [ hookModule ./hooks/detect-private-keys.nix ]; + }; + default = { }; + }; + dhall-format = mkOption { + description = "dhall-format hook"; + type = types.submodule { + imports = [ hookModule ./hooks/dhall-format.nix ]; + }; + default = { }; + }; + dialyzer = mkOption { + description = "dialyzer hook"; + type = types.submodule { + imports = [ hookModule ./hooks/dialyzer.nix ]; + }; + default = { }; + }; + dune-opam-sync = mkOption { + description = "dune-opam-sync hook"; + type = types.submodule { + imports = [ hookModule ./hooks/dune-opam-sync.nix ]; + }; + default = { }; + }; + editorconfig-checker = mkOption { + description = "editorconfig-checker hook"; + type = types.submodule { + imports = [ hookModule ./hooks/editorconfig-checker.nix ]; + }; + default = { }; + }; + elm-format = mkOption { + description = "elm-format hook"; + type = types.submodule { + imports = [ hookModule ./hooks/elm-format.nix ]; + }; + default = { }; + }; + elm-review = mkOption { + description = "elm-review hook"; + type = types.submodule { + imports = [ hookModule ./hooks/elm-review.nix ]; + }; + default = { }; + }; + elm-test = mkOption { + description = "elm-test hook"; + type = types.submodule { + imports = [ hookModule ./hooks/elm-test.nix ]; + }; + default = { }; + }; + end-of-file-fixer = mkOption { + description = "end-of-file-fixer hook"; + type = types.submodule { + imports = [ hookModule ./hooks/end-of-file-fixer.nix ]; + }; + default = { }; + }; + fix-byte-order-marker = mkOption { + description = "fix-byte-order-marker hook"; + type = types.submodule { + imports = [ hookModule ./hooks/fix-byte-order-marker.nix ]; + }; + default = { }; + }; + fix-encoding-pragma = mkOption { + description = "fix-encoding-pragma hook"; + type = types.submodule { + imports = [ hookModule ./hooks/fix-encoding-pragma.nix ]; + }; + default = { }; + }; + flake-checker = mkOption { + description = "flake-checker hook"; + type = types.submodule { + imports = [ hookModule ./hooks/flake-checker.nix ]; + }; + default = { }; + }; + forbid-new-submodules = mkOption { + description = "forbid-new-submodules hook"; + type = types.submodule { + imports = [ hookModule ./hooks/forbid-new-submodules.nix ]; + }; + default = { }; + }; + fprettify = mkOption { + description = "fprettify hook"; + type = types.submodule { + imports = [ hookModule ./hooks/fprettify.nix ]; + }; + default = { }; + }; + gitlint = mkOption { + description = "gitlint hook"; + type = types.submodule { + imports = [ hookModule ./hooks/gitlint.nix ]; + }; + default = { }; + }; + gofmt = mkOption { + description = "gofmt hook"; + type = types.submodule { + imports = [ hookModule ./hooks/gofmt.nix ]; + }; + default = { }; + }; + golangci-lint = mkOption { + description = "golangci-lint hook"; + type = types.submodule { + imports = [ hookModule ./hooks/golangci-lint.nix ]; + }; + default = { }; + }; + gotest = mkOption { + description = "gotest hook"; + type = types.submodule { + imports = [ hookModule ./hooks/gotest.nix ]; + }; + default = { }; + }; + govet = mkOption { + description = "govet hook"; + type = types.submodule { + imports = [ hookModule ./hooks/govet.nix ]; + }; + default = { }; + }; + gptcommit = mkOption { + description = "gptcommit hook"; + type = types.submodule { + imports = [ hookModule ./hooks/gptcommit.nix ]; + }; + default = { }; + }; + hadolint = mkOption { + description = "hadolint hook"; + type = types.submodule { + imports = [ hookModule ./hooks/hadolint.nix ]; + }; + default = { }; }; }; From 44c436e8ae5740c123aa0348b4933644242e5ffe Mon Sep 17 00:00:00 2001 From: Sander Date: Mon, 26 May 2025 01:06:26 +0200 Subject: [PATCH 06/13] hooks: sort hooks --- modules/hooks.nix | 445 +++++++++++++++++++++++----------------------- 1 file changed, 222 insertions(+), 223 deletions(-) diff --git a/modules/hooks.nix b/modules/hooks.nix index 68228122..ddf89845 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -288,6 +288,13 @@ in }; default = { }; }; + cljfmt = mkOption { + description = "cljfmt hook"; + type = types.submodule { + imports = [ hookModule ./hooks/cljfmt.nix ]; + }; + default = { }; + }; circleci = mkOption { description = "circleci hook"; type = types.submodule { @@ -323,6 +330,27 @@ in }; default = { }; }; + commitizen = mkOption { + description = "commitizen hook"; + type = types.submodule { + imports = [ hookModule ./hooks/commitizen.nix ]; + }; + default = { }; + }; + conform = mkOption { + description = "conform hook"; + type = types.submodule { + imports = [ hookModule ./hooks/conform.nix ]; + }; + default = { }; + }; + convco = mkOption { + description = "convco hook"; + type = types.submodule { + imports = [ hookModule ./hooks/convco.nix ]; + }; + default = { }; + }; credo = mkOption { description = "credo hook"; type = types.submodule { @@ -330,6 +358,34 @@ in }; default = { }; }; + crystal = mkOption { + description = "crystal hook"; + type = types.submodule { + imports = [ hookModule ./hooks/crystal.nix ]; + }; + default = { }; + }; + cspell = mkOption { + description = "cspell hook"; + type = types.submodule { + imports = [ hookModule ./hooks/cspell.nix ]; + }; + default = { }; + }; + dart-analyze = mkOption { + description = "dart-analyze hook"; + type = types.submodule { + imports = [ hookModule ./hooks/dart-analyze.nix ]; + }; + default = { }; + }; + dart-format = mkOption { + description = "dart-format hook"; + type = types.submodule { + imports = [ hookModule ./hooks/dart-format.nix ]; + }; + default = { }; + }; deadnix = mkOption { description = "deadnix hook"; type = types.submodule { @@ -337,6 +393,34 @@ in }; default = { }; }; + detect-aws-credentials = mkOption { + description = "detect-aws-credentials hook"; + type = types.submodule { + imports = [ hookModule ./hooks/detect-aws-credentials.nix ]; + }; + default = { }; + }; + detect-private-keys = mkOption { + description = "detect-private-keys hook"; + type = types.submodule { + imports = [ hookModule ./hooks/detect-private-keys.nix ]; + }; + default = { }; + }; + dhall-format = mkOption { + description = "dhall-format hook"; + type = types.submodule { + imports = [ hookModule ./hooks/dhall-format.nix ]; + }; + default = { }; + }; + dialyzer = mkOption { + description = "dialyzer hook"; + type = types.submodule { + imports = [ hookModule ./hooks/dialyzer.nix ]; + }; + default = { }; + }; denofmt = mkOption { description = "denofmt hook"; type = types.submodule { @@ -358,6 +442,13 @@ in }; default = { }; }; + dune-opam-sync = mkOption { + description = "dune-opam-sync hook"; + type = types.submodule { + imports = [ hookModule ./hooks/dune-opam-sync.nix ]; + }; + default = { }; + }; eclint = mkOption { description = "eclint hook"; type = types.submodule { @@ -365,6 +456,41 @@ in }; default = { }; }; + editorconfig-checker = mkOption { + description = "editorconfig-checker hook"; + type = types.submodule { + imports = [ hookModule ./hooks/editorconfig-checker.nix ]; + }; + default = { }; + }; + elm-format = mkOption { + description = "elm-format hook"; + type = types.submodule { + imports = [ hookModule ./hooks/elm-format.nix ]; + }; + default = { }; + }; + elm-review = mkOption { + description = "elm-review hook"; + type = types.submodule { + imports = [ hookModule ./hooks/elm-review.nix ]; + }; + default = { }; + }; + elm-test = mkOption { + description = "elm-test hook"; + type = types.submodule { + imports = [ hookModule ./hooks/elm-test.nix ]; + }; + default = { }; + }; + end-of-file-fixer = mkOption { + description = "end-of-file-fixer hook"; + type = types.submodule { + imports = [ hookModule ./hooks/end-of-file-fixer.nix ]; + }; + default = { }; + }; eslint = mkOption { description = "eslint hook"; type = types.submodule { @@ -379,6 +505,27 @@ in }; default = { }; }; + fix-byte-order-marker = mkOption { + description = "fix-byte-order-marker hook"; + type = types.submodule { + imports = [ hookModule ./hooks/fix-byte-order-marker.nix ]; + }; + default = { }; + }; + fix-encoding-pragma = mkOption { + description = "fix-encoding-pragma hook"; + type = types.submodule { + imports = [ hookModule ./hooks/fix-encoding-pragma.nix ]; + }; + default = { }; + }; + flake-checker = mkOption { + description = "flake-checker hook"; + type = types.submodule { + imports = [ hookModule ./hooks/flake-checker.nix ]; + }; + default = { }; + }; flynt = mkOption { description = "flynt hook"; type = types.submodule { @@ -393,6 +540,41 @@ in }; default = { }; }; + forbid-new-submodules = mkOption { + description = "forbid-new-submodules hook"; + type = types.submodule { + imports = [ hookModule ./hooks/forbid-new-submodules.nix ]; + }; + default = { }; + }; + fprettify = mkOption { + description = "fprettify hook"; + type = types.submodule { + imports = [ hookModule ./hooks/fprettify.nix ]; + }; + default = { }; + }; + gitlint = mkOption { + description = "gitlint hook"; + type = types.submodule { + imports = [ hookModule ./hooks/gitlint.nix ]; + }; + default = { }; + }; + gofmt = mkOption { + description = "gofmt hook"; + type = types.submodule { + imports = [ hookModule ./hooks/gofmt.nix ]; + }; + default = { }; + }; + golangci-lint = mkOption { + description = "golangci-lint hook"; + type = types.submodule { + imports = [ hookModule ./hooks/golangci-lint.nix ]; + }; + default = { }; + }; golines = mkOption { description = "golines hook"; type = types.submodule { @@ -400,6 +582,34 @@ in }; default = { }; }; + gotest = mkOption { + description = "gotest hook"; + type = types.submodule { + imports = [ hookModule ./hooks/gotest.nix ]; + }; + default = { }; + }; + govet = mkOption { + description = "govet hook"; + type = types.submodule { + imports = [ hookModule ./hooks/govet.nix ]; + }; + default = { }; + }; + gptcommit = mkOption { + description = "gptcommit hook"; + type = types.submodule { + imports = [ hookModule ./hooks/gptcommit.nix ]; + }; + default = { }; + }; + hadolint = mkOption { + description = "hadolint hook"; + type = types.submodule { + imports = [ hookModule ./hooks/hadolint.nix ]; + }; + default = { }; + }; headache = mkOption { description = "headache hook"; type = types.submodule { @@ -428,17 +638,17 @@ in }; default = { }; }; - latexindent = mkOption { - description = "latexindent hook"; + lacheck = mkOption { + description = "lacheck hook"; type = types.submodule { - imports = [ hookModule ./hooks/latexindent.nix ]; + imports = [ hookModule ./hooks/lacheck.nix ]; }; default = { }; }; - lacheck = mkOption { - description = "lacheck hook"; + latexindent = mkOption { + description = "latexindent hook"; type = types.submodule { - imports = [ hookModule ./hooks/lacheck.nix ]; + imports = [ hookModule ./hooks/latexindent.nix ]; }; default = { }; }; @@ -660,17 +870,17 @@ in }; default = { }; }; - statix = mkOption { - description = "statix hook"; + sort-file-contents = mkOption { + description = "sort-file-contents-hook"; type = types.submodule { - imports = [ hookModule ./hooks/statix.nix ]; + imports = [ hookModule ./hooks/sort-file-contents.nix ]; }; default = { }; }; - sort-file-contents = mkOption { - description = "sort-file-contents-hook"; + statix = mkOption { + description = "statix hook"; type = types.submodule { - imports = [ hookModule ./hooks/sort-file-contents.nix ]; + imports = [ hookModule ./hooks/statix.nix ]; }; default = { }; }; @@ -726,217 +936,6 @@ in }; default = { }; }; - # Add missing hooks that were migrated but not yet added to options - cljfmt = mkOption { - description = "cljfmt hook"; - type = types.submodule { - imports = [ hookModule ./hooks/cljfmt.nix ]; - }; - default = { }; - }; - commitizen = mkOption { - description = "commitizen hook"; - type = types.submodule { - imports = [ hookModule ./hooks/commitizen.nix ]; - }; - default = { }; - }; - conform = mkOption { - description = "conform hook"; - type = types.submodule { - imports = [ hookModule ./hooks/conform.nix ]; - }; - default = { }; - }; - convco = mkOption { - description = "convco hook"; - type = types.submodule { - imports = [ hookModule ./hooks/convco.nix ]; - }; - default = { }; - }; - crystal = mkOption { - description = "crystal hook"; - type = types.submodule { - imports = [ hookModule ./hooks/crystal.nix ]; - }; - default = { }; - }; - cspell = mkOption { - description = "cspell hook"; - type = types.submodule { - imports = [ hookModule ./hooks/cspell.nix ]; - }; - default = { }; - }; - dart-analyze = mkOption { - description = "dart-analyze hook"; - type = types.submodule { - imports = [ hookModule ./hooks/dart-analyze.nix ]; - }; - default = { }; - }; - dart-format = mkOption { - description = "dart-format hook"; - type = types.submodule { - imports = [ hookModule ./hooks/dart-format.nix ]; - }; - default = { }; - }; - detect-aws-credentials = mkOption { - description = "detect-aws-credentials hook"; - type = types.submodule { - imports = [ hookModule ./hooks/detect-aws-credentials.nix ]; - }; - default = { }; - }; - detect-private-keys = mkOption { - description = "detect-private-keys hook"; - type = types.submodule { - imports = [ hookModule ./hooks/detect-private-keys.nix ]; - }; - default = { }; - }; - dhall-format = mkOption { - description = "dhall-format hook"; - type = types.submodule { - imports = [ hookModule ./hooks/dhall-format.nix ]; - }; - default = { }; - }; - dialyzer = mkOption { - description = "dialyzer hook"; - type = types.submodule { - imports = [ hookModule ./hooks/dialyzer.nix ]; - }; - default = { }; - }; - dune-opam-sync = mkOption { - description = "dune-opam-sync hook"; - type = types.submodule { - imports = [ hookModule ./hooks/dune-opam-sync.nix ]; - }; - default = { }; - }; - editorconfig-checker = mkOption { - description = "editorconfig-checker hook"; - type = types.submodule { - imports = [ hookModule ./hooks/editorconfig-checker.nix ]; - }; - default = { }; - }; - elm-format = mkOption { - description = "elm-format hook"; - type = types.submodule { - imports = [ hookModule ./hooks/elm-format.nix ]; - }; - default = { }; - }; - elm-review = mkOption { - description = "elm-review hook"; - type = types.submodule { - imports = [ hookModule ./hooks/elm-review.nix ]; - }; - default = { }; - }; - elm-test = mkOption { - description = "elm-test hook"; - type = types.submodule { - imports = [ hookModule ./hooks/elm-test.nix ]; - }; - default = { }; - }; - end-of-file-fixer = mkOption { - description = "end-of-file-fixer hook"; - type = types.submodule { - imports = [ hookModule ./hooks/end-of-file-fixer.nix ]; - }; - default = { }; - }; - fix-byte-order-marker = mkOption { - description = "fix-byte-order-marker hook"; - type = types.submodule { - imports = [ hookModule ./hooks/fix-byte-order-marker.nix ]; - }; - default = { }; - }; - fix-encoding-pragma = mkOption { - description = "fix-encoding-pragma hook"; - type = types.submodule { - imports = [ hookModule ./hooks/fix-encoding-pragma.nix ]; - }; - default = { }; - }; - flake-checker = mkOption { - description = "flake-checker hook"; - type = types.submodule { - imports = [ hookModule ./hooks/flake-checker.nix ]; - }; - default = { }; - }; - forbid-new-submodules = mkOption { - description = "forbid-new-submodules hook"; - type = types.submodule { - imports = [ hookModule ./hooks/forbid-new-submodules.nix ]; - }; - default = { }; - }; - fprettify = mkOption { - description = "fprettify hook"; - type = types.submodule { - imports = [ hookModule ./hooks/fprettify.nix ]; - }; - default = { }; - }; - gitlint = mkOption { - description = "gitlint hook"; - type = types.submodule { - imports = [ hookModule ./hooks/gitlint.nix ]; - }; - default = { }; - }; - gofmt = mkOption { - description = "gofmt hook"; - type = types.submodule { - imports = [ hookModule ./hooks/gofmt.nix ]; - }; - default = { }; - }; - golangci-lint = mkOption { - description = "golangci-lint hook"; - type = types.submodule { - imports = [ hookModule ./hooks/golangci-lint.nix ]; - }; - default = { }; - }; - gotest = mkOption { - description = "gotest hook"; - type = types.submodule { - imports = [ hookModule ./hooks/gotest.nix ]; - }; - default = { }; - }; - govet = mkOption { - description = "govet hook"; - type = types.submodule { - imports = [ hookModule ./hooks/govet.nix ]; - }; - default = { }; - }; - gptcommit = mkOption { - description = "gptcommit hook"; - type = types.submodule { - imports = [ hookModule ./hooks/gptcommit.nix ]; - }; - default = { }; - }; - hadolint = mkOption { - description = "hadolint hook"; - type = types.submodule { - imports = [ hookModule ./hooks/hadolint.nix ]; - }; - default = { }; - }; }; config.warnings = From d90f75121625d779d75f6952d70a2385eb7bc4ba Mon Sep 17 00:00:00 2001 From: Sander Date: Mon, 26 May 2025 01:10:52 +0200 Subject: [PATCH 07/13] hooks: pass common functions to the hook module --- modules/hooks.nix | 13 +++++-------- modules/hooks/alejandra.nix | 11 +---------- modules/hooks/ansible-lint.nix | 11 +---------- modules/hooks/autoflake.nix | 7 +------ modules/hooks/biome.nix | 16 +--------------- modules/hooks/deadnix.nix | 11 +---------- modules/hooks/denofmt.nix | 11 +---------- modules/hooks/denolint.nix | 11 +---------- modules/hooks/eclint.nix | 11 +---------- modules/hooks/eslint.nix | 7 +------ modules/hooks/flake8.nix | 9 ++------- modules/hooks/flynt.nix | 16 +--------------- modules/hooks/rome.nix | 2 +- 13 files changed, 18 insertions(+), 118 deletions(-) diff --git a/modules/hooks.nix b/modules/hooks.nix index ddf89845..845e27d3 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -1,13 +1,7 @@ { config, lib, pkgs, hookModule, ... }: let - inherit (config) hooks tools settings; cfg = config; - inherit (lib) flatten mapAttrs mapAttrsToList mkDefault mkOption mkRemovedOptionModule mkRenamedOptionModule types; - - cargoManifestPathArg = - lib.optionalString - (settings.rust.cargoManifestPath != null) - "--manifest-path ${lib.escapeShellArg settings.rust.cargoManifestPath}"; + inherit (lib) flatten mapAttrsToList mkOption mkRemovedOptionModule mkRenamedOptionModule types; mkCmdArgs = predActionList: lib.concatStringsSep @@ -61,7 +55,10 @@ in config.hookModule = { imports = [ ./hook.nix ]; - config._module.args = { inherit (cfg) default_stages tools; }; + config._module.args = { + inherit (cfg) default_stages tools; + inherit mkCmdArgs migrateBinPathToPackage; + }; }; config._module.args.hookModule = config.hookModule; diff --git a/modules/hooks/alejandra.nix b/modules/hooks/alejandra.nix index 1b1d84a9..6a314061 100644 --- a/modules/hooks/alejandra.nix +++ b/modules/hooks/alejandra.nix @@ -1,15 +1,6 @@ -{ tools, config, lib, ... }: +{ tools, config, lib, mkCmdArgs, ... }: let inherit (lib) mkOption types; - - mkCmdArgs = predActionList: - lib.concatStringsSep - " " - (builtins.foldl' - (acc: entry: - acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) - [ ] - predActionList); in { options.settings = { diff --git a/modules/hooks/ansible-lint.nix b/modules/hooks/ansible-lint.nix index 809b2387..b5971a15 100644 --- a/modules/hooks/ansible-lint.nix +++ b/modules/hooks/ansible-lint.nix @@ -1,15 +1,6 @@ -{ tools, config, lib, ... }: +{ tools, config, lib, mkCmdArgs, ... }: let inherit (lib) mkOption types; - - mkCmdArgs = predActionList: - lib.concatStringsSep - " " - (builtins.foldl' - (acc: entry: - acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) - [ ] - predActionList); in { options.settings = { diff --git a/modules/hooks/autoflake.nix b/modules/hooks/autoflake.nix index 4dc00c6d..06efd292 100644 --- a/modules/hooks/autoflake.nix +++ b/modules/hooks/autoflake.nix @@ -1,11 +1,6 @@ -{ tools, config, lib, ... }: +{ tools, config, lib, migrateBinPathToPackage, ... }: let inherit (lib) mkOption types; - - migrateBinPathToPackage = hook: binPath: - if hook.settings.binPath == null - then "${hook.package}${binPath}" - else hook.settings.binPath; in { options.settings = { diff --git a/modules/hooks/biome.nix b/modules/hooks/biome.nix index 7a77b821..1f0d894f 100644 --- a/modules/hooks/biome.nix +++ b/modules/hooks/biome.nix @@ -1,20 +1,6 @@ -{ tools, config, lib, ... }: +{ tools, config, lib, mkCmdArgs, migrateBinPathToPackage, ... }: let inherit (lib) mkOption types; - - mkCmdArgs = predActionList: - lib.concatStringsSep - " " - (builtins.foldl' - (acc: entry: - acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) - [ ] - predActionList); - - migrateBinPathToPackage = hook: binPath: - if hook.settings.binPath == null - then "${hook.package}${binPath}" - else hook.settings.binPath; in { options.settings = { diff --git a/modules/hooks/deadnix.nix b/modules/hooks/deadnix.nix index a9f13d81..7113616b 100644 --- a/modules/hooks/deadnix.nix +++ b/modules/hooks/deadnix.nix @@ -1,15 +1,6 @@ -{ tools, config, lib, ... }: +{ tools, config, lib, mkCmdArgs, ... }: let inherit (lib) mkOption types; - - mkCmdArgs = predActionList: - lib.concatStringsSep - " " - (builtins.foldl' - (acc: entry: - acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) - [ ] - predActionList); in { options.settings = { diff --git a/modules/hooks/denofmt.nix b/modules/hooks/denofmt.nix index 2ee19653..3a868fc9 100644 --- a/modules/hooks/denofmt.nix +++ b/modules/hooks/denofmt.nix @@ -1,15 +1,6 @@ -{ tools, config, lib, ... }: +{ tools, config, lib, mkCmdArgs, ... }: let inherit (lib) mkOption types; - - mkCmdArgs = predActionList: - lib.concatStringsSep - " " - (builtins.foldl' - (acc: entry: - acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) - [ ] - predActionList); in { options.settings = { diff --git a/modules/hooks/denolint.nix b/modules/hooks/denolint.nix index d72851b2..c7f33df5 100644 --- a/modules/hooks/denolint.nix +++ b/modules/hooks/denolint.nix @@ -1,15 +1,6 @@ -{ tools, config, lib, ... }: +{ tools, config, lib, mkCmdArgs, ... }: let inherit (lib) mkOption types; - - mkCmdArgs = predActionList: - lib.concatStringsSep - " " - (builtins.foldl' - (acc: entry: - acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) - [ ] - predActionList); in { options.settings = { diff --git a/modules/hooks/eclint.nix b/modules/hooks/eclint.nix index cad96591..44bd4531 100644 --- a/modules/hooks/eclint.nix +++ b/modules/hooks/eclint.nix @@ -1,15 +1,6 @@ -{ tools, config, lib, ... }: +{ tools, config, lib, mkCmdArgs, ... }: let inherit (lib) mkOption types; - - mkCmdArgs = predActionList: - lib.concatStringsSep - " " - (builtins.foldl' - (acc: entry: - acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) - [ ] - predActionList); in { options.settings = { diff --git a/modules/hooks/eslint.nix b/modules/hooks/eslint.nix index a62512b7..31ea1bec 100644 --- a/modules/hooks/eslint.nix +++ b/modules/hooks/eslint.nix @@ -1,11 +1,6 @@ -{ tools, config, lib, ... }: +{ tools, config, lib, migrateBinPathToPackage, ... }: let inherit (lib) mkOption types; - - migrateBinPathToPackage = hook: binPath: - if hook.settings.binPath == null - then "${hook.package}${binPath}" - else hook.settings.binPath; in { options.settings = { diff --git a/modules/hooks/flake8.nix b/modules/hooks/flake8.nix index 1e4fb428..274b761b 100644 --- a/modules/hooks/flake8.nix +++ b/modules/hooks/flake8.nix @@ -1,12 +1,7 @@ -{ tools, config, lib, ... }: +{ tools, config, lib, migrateBinPathToPackage, ... }: let inherit (lib) mkOption types; - - migrateBinPathToPackage = hook: binPath: - if hook.settings.binPath == null - then "${hook.package}${binPath}" - else hook.settings.binPath; - + extendIgnoreStr = if lib.lists.length config.settings.extendIgnore > 0 then "--extend-ignore " + builtins.concatStringsSep "," config.settings.extendIgnore diff --git a/modules/hooks/flynt.nix b/modules/hooks/flynt.nix index df882f9e..a60e2f3c 100644 --- a/modules/hooks/flynt.nix +++ b/modules/hooks/flynt.nix @@ -1,20 +1,6 @@ -{ tools, config, lib, ... }: +{ tools, config, lib, mkCmdArgs, migrateBinPathToPackage, ... }: let inherit (lib) mkOption types; - - mkCmdArgs = predActionList: - lib.concatStringsSep - " " - (builtins.foldl' - (acc: entry: - acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) - [ ] - predActionList); - - migrateBinPathToPackage = hook: binPath: - if hook.settings.binPath == null - then "${hook.package}${binPath}" - else hook.settings.binPath; in { options.settings = { diff --git a/modules/hooks/rome.nix b/modules/hooks/rome.nix index fd04098d..f752a1be 100644 --- a/modules/hooks/rome.nix +++ b/modules/hooks/rome.nix @@ -1,4 +1,4 @@ -{ config, lib, tools, ... }: +{ config, lib, tools, mkCmdArgs, migrateBinPathToPackage, ... }: let inherit (lib) mkOption types; in From 38ee671f1d2cf6da9a697a8ac0a4c4316b06a930 Mon Sep 17 00:00:00 2001 From: Sander Date: Mon, 26 May 2025 01:52:25 +0200 Subject: [PATCH 08/13] hooks: implement mkHook --- modules/hooks.nix | 989 ++++++++-------------------------------------- 1 file changed, 159 insertions(+), 830 deletions(-) diff --git a/modules/hooks.nix b/modules/hooks.nix index 845e27d3..82916565 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -3,19 +3,22 @@ let cfg = config; inherit (lib) flatten mapAttrsToList mkOption mkRemovedOptionModule mkRenamedOptionModule types; - mkCmdArgs = predActionList: - lib.concatStringsSep - " " - (builtins.foldl' - (acc: entry: - acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) - [ ] - predActionList); - - migrateBinPathToPackage = hook: binPath: - if hook.settings.binPath == null - then "${hook.package}${binPath}" - else hook.settings.binPath; + # Helper function to create hook options with unified descriptions + # Takes an attribute set: { name, description, modules, [specialArgs], [visible], ... } + mkHook = { name, description, modules, specialArgs ? { }, ... }@args: + let + optionArgs = builtins.removeAttrs args [ "name" "description" "modules" "specialArgs" ]; + in + mkOption ({ + inherit description; + type = types.submoduleWith ({ + inherit specialArgs; + modules = [ hookModule ] ++ modules ++ [ + { config.description = lib.mkDefault description; } + ]; + }); + default = { }; + } // optionArgs); in { imports = @@ -57,7 +60,20 @@ in imports = [ ./hook.nix ]; config._module.args = { inherit (cfg) default_stages tools; - inherit mkCmdArgs migrateBinPathToPackage; + mkCmdArgs = predActionList: + lib.concatStringsSep + " " + (builtins.foldl' + (acc: entry: + acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) + [ ] + predActionList); + + migrateBinPathToPackage = hook: binPath: + if hook.settings.binPath == null + then "${hook.package}${binPath}" + else hook.settings.binPath; + }; }; config._module.args.hookModule = config.hookModule; @@ -82,770 +98,130 @@ in # PLEASE keep this sorted alphabetically. options.hooks = { - actionlint = mkOption { - description = "actionlint hook"; - type = types.submodule { - imports = [ hookModule ./hooks/actionlint.nix ]; - }; - default = { }; - }; - alejandra = mkOption { - description = "alejandra hook"; - type = types.submodule { - imports = [ hookModule ./hooks/alejandra.nix ]; - }; - default = { }; - }; - annex = mkOption { - description = "annex hook"; - type = types.submodule { - imports = [ hookModule ./hooks/annex.nix ]; - }; - default = { }; - }; - ansible-lint = mkOption { - description = "ansible-lint hook"; - type = types.submodule { - imports = [ hookModule ./hooks/ansible-lint.nix ]; - }; - default = { }; - }; - autoflake = mkOption { - description = "autoflake hook"; - type = types.submodule { - imports = [ hookModule ./hooks/autoflake.nix ]; - }; - default = { }; - }; - bats = mkOption { - description = "bats hook"; - type = types.submodule { - imports = [ hookModule ./hooks/bats.nix ]; - }; - default = { }; - }; - beautysh = mkOption { - description = "beautysh hook"; - type = types.submodule { - imports = [ hookModule ./hooks/beautysh.nix ]; - }; - default = { }; - }; - biome = mkOption { - description = "biome hook"; - type = types.submodule { - imports = [ hookModule ./hooks/biome.nix ]; - }; - default = { }; - }; - black = mkOption { - description = "black hook"; - type = types.submodule { - imports = [ hookModule ./hooks/black.nix ]; - }; - default = { }; - }; - cabal-fmt = mkOption { - description = "cabal-fmt hook"; - type = types.submodule { - imports = [ hookModule ./hooks/cabal-fmt.nix ]; - }; - default = { }; - }; - cabal-gild = mkOption { - description = "cabal-gild hook"; - type = types.submodule { - imports = [ hookModule ./hooks/cabal-gild.nix ]; - }; - default = { }; - }; - cabal2nix = mkOption { - description = "cabal2nix hook"; - type = types.submodule { - imports = [ hookModule ./hooks/cabal2nix.nix ]; - }; - default = { }; - }; - cargo-check = mkOption { - description = "cargo-check hook"; - type = types.submodule { - imports = [ hookModule ./hooks/cargo-check.nix ]; - }; - default = { }; - }; - check-added-large-files = mkOption { - description = "check-added-large-files hook"; - type = types.submodule { - imports = [ hookModule ./hooks/check-added-large-files.nix ]; - }; - default = { }; - }; - check-builtin-literals = mkOption { - description = "check-builtin-literals hook"; - type = types.submodule { - imports = [ hookModule ./hooks/check-builtin-literals.nix ]; - }; - default = { }; - }; - check-case-conflicts = mkOption { - description = "check-case-conflicts hook"; - type = types.submodule { - imports = [ hookModule ./hooks/check-case-conflicts.nix ]; - }; - default = { }; - }; - check-docstring-first = mkOption { - description = "check-docstring-first hook"; - type = types.submodule { - imports = [ hookModule ./hooks/check-docstring-first.nix ]; - }; - default = { }; - }; - check-executables-have-shebangs = mkOption { - description = "check-executables-have-shebangs hook"; - type = types.submodule { - imports = [ hookModule ./hooks/check-executables-have-shebangs.nix ]; - }; - default = { }; - }; - check-json = mkOption { - description = "check-json hook"; - type = types.submodule { - imports = [ hookModule ./hooks/check-json.nix ]; - }; - default = { }; - }; - check-merge-conflicts = mkOption { - description = "check-merge-conflicts hook"; - type = types.submodule { - imports = [ hookModule ./hooks/check-merge-conflicts.nix ]; - }; - default = { }; - }; - check-python = mkOption { - description = "check-python hook"; - type = types.submodule { - imports = [ hookModule ./hooks/check-python.nix ]; - }; - default = { }; - }; - check-shebang-scripts-are-executable = mkOption { - description = "check-shebang-scripts-are-executable hook"; - type = types.submodule { - imports = [ hookModule ./hooks/check-shebang-scripts-are-executable.nix ]; - }; - default = { }; - }; - check-symlinks = mkOption { - description = "check-symlinks hook"; - type = types.submodule { - imports = [ hookModule ./hooks/check-symlinks.nix ]; - }; - default = { }; - }; - check-toml = mkOption { - description = "check-toml hook"; - type = types.submodule { - imports = [ hookModule ./hooks/check-toml.nix ]; - }; - default = { }; - }; - check-vcs-permalinks = mkOption { - description = "check-vcs-permalinks hook"; - type = types.submodule { - imports = [ hookModule ./hooks/check-vcs-permalinks.nix ]; - }; - default = { }; - }; - check-xml = mkOption { - description = "check-xml hook"; - type = types.submodule { - imports = [ hookModule ./hooks/check-xml.nix ]; - }; - default = { }; - }; - check-yaml = mkOption { - description = "check-yaml hook"; - type = types.submodule { - imports = [ hookModule ./hooks/check-yaml.nix ]; - }; - default = { }; - }; - checkmake = mkOption { - description = "checkmake hook"; - type = types.submodule { - imports = [ hookModule ./hooks/checkmake.nix ]; - }; - default = { }; - }; - chktex = mkOption { - description = "chktex hook"; - type = types.submodule { - imports = [ hookModule ./hooks/chktex.nix ]; - }; - default = { }; - }; - cljfmt = mkOption { - description = "cljfmt hook"; - type = types.submodule { - imports = [ hookModule ./hooks/cljfmt.nix ]; - }; - default = { }; - }; - circleci = mkOption { - description = "circleci hook"; - type = types.submodule { - imports = [ hookModule ./hooks/circleci.nix ]; - }; - default = { }; - }; - clang-format = mkOption { - description = "clang-format hook"; - type = types.submodule { - imports = [ hookModule ./hooks/clang-format.nix ]; - }; - default = { }; - }; - clang-tidy = mkOption { - description = "clang-tidy hook"; - type = types.submodule { - imports = [ hookModule ./hooks/clang-tidy.nix ]; - }; - default = { }; - }; - clippy = mkOption { - description = "clippy hook"; - type = types.submodule { - imports = [ hookModule ./hooks/clippy.nix ]; - }; - default = { }; - }; - cmake-format = mkOption { - description = "cmake-format hook"; - type = types.submodule { - imports = [ hookModule ./hooks/cmake-format.nix ]; - }; - default = { }; - }; - commitizen = mkOption { - description = "commitizen hook"; - type = types.submodule { - imports = [ hookModule ./hooks/commitizen.nix ]; - }; - default = { }; - }; - conform = mkOption { - description = "conform hook"; - type = types.submodule { - imports = [ hookModule ./hooks/conform.nix ]; - }; - default = { }; - }; - convco = mkOption { - description = "convco hook"; - type = types.submodule { - imports = [ hookModule ./hooks/convco.nix ]; - }; - default = { }; - }; - credo = mkOption { - description = "credo hook"; - type = types.submodule { - imports = [ hookModule ./hooks/credo.nix ]; - }; - default = { }; - }; - crystal = mkOption { - description = "crystal hook"; - type = types.submodule { - imports = [ hookModule ./hooks/crystal.nix ]; - }; - default = { }; - }; - cspell = mkOption { - description = "cspell hook"; - type = types.submodule { - imports = [ hookModule ./hooks/cspell.nix ]; - }; - default = { }; - }; - dart-analyze = mkOption { - description = "dart-analyze hook"; - type = types.submodule { - imports = [ hookModule ./hooks/dart-analyze.nix ]; - }; - default = { }; - }; - dart-format = mkOption { - description = "dart-format hook"; - type = types.submodule { - imports = [ hookModule ./hooks/dart-format.nix ]; - }; - default = { }; - }; - deadnix = mkOption { - description = "deadnix hook"; - type = types.submodule { - imports = [ hookModule ./hooks/deadnix.nix ]; - }; - default = { }; - }; - detect-aws-credentials = mkOption { - description = "detect-aws-credentials hook"; - type = types.submodule { - imports = [ hookModule ./hooks/detect-aws-credentials.nix ]; - }; - default = { }; - }; - detect-private-keys = mkOption { - description = "detect-private-keys hook"; - type = types.submodule { - imports = [ hookModule ./hooks/detect-private-keys.nix ]; - }; - default = { }; - }; - dhall-format = mkOption { - description = "dhall-format hook"; - type = types.submodule { - imports = [ hookModule ./hooks/dhall-format.nix ]; - }; - default = { }; - }; - dialyzer = mkOption { - description = "dialyzer hook"; - type = types.submodule { - imports = [ hookModule ./hooks/dialyzer.nix ]; - }; - default = { }; - }; - denofmt = mkOption { - description = "denofmt hook"; - type = types.submodule { - imports = [ hookModule ./hooks/denofmt.nix ]; - }; - default = { }; - }; - denolint = mkOption { - description = "denolint hook"; - type = types.submodule { - imports = [ hookModule ./hooks/denolint.nix ]; - }; - default = { }; - }; - dune-fmt = mkOption { - description = "dune-fmt hook"; - type = types.submodule { - imports = [ hookModule ./hooks/dune-fmt.nix ]; - }; - default = { }; - }; - dune-opam-sync = mkOption { - description = "dune-opam-sync hook"; - type = types.submodule { - imports = [ hookModule ./hooks/dune-opam-sync.nix ]; - }; - default = { }; - }; - eclint = mkOption { - description = "eclint hook"; - type = types.submodule { - imports = [ hookModule ./hooks/eclint.nix ]; - }; - default = { }; - }; - editorconfig-checker = mkOption { - description = "editorconfig-checker hook"; - type = types.submodule { - imports = [ hookModule ./hooks/editorconfig-checker.nix ]; - }; - default = { }; - }; - elm-format = mkOption { - description = "elm-format hook"; - type = types.submodule { - imports = [ hookModule ./hooks/elm-format.nix ]; - }; - default = { }; - }; - elm-review = mkOption { - description = "elm-review hook"; - type = types.submodule { - imports = [ hookModule ./hooks/elm-review.nix ]; - }; - default = { }; - }; - elm-test = mkOption { - description = "elm-test hook"; - type = types.submodule { - imports = [ hookModule ./hooks/elm-test.nix ]; - }; - default = { }; - }; - end-of-file-fixer = mkOption { - description = "end-of-file-fixer hook"; - type = types.submodule { - imports = [ hookModule ./hooks/end-of-file-fixer.nix ]; - }; - default = { }; - }; - eslint = mkOption { - description = "eslint hook"; - type = types.submodule { - imports = [ hookModule ./hooks/eslint.nix ]; - }; - default = { }; - }; - flake8 = mkOption { - description = "flake8 hook"; - type = types.submodule { - imports = [ hookModule ./hooks/flake8.nix ]; - }; - default = { }; - }; - fix-byte-order-marker = mkOption { - description = "fix-byte-order-marker hook"; - type = types.submodule { - imports = [ hookModule ./hooks/fix-byte-order-marker.nix ]; - }; - default = { }; - }; - fix-encoding-pragma = mkOption { - description = "fix-encoding-pragma hook"; - type = types.submodule { - imports = [ hookModule ./hooks/fix-encoding-pragma.nix ]; - }; - default = { }; - }; - flake-checker = mkOption { - description = "flake-checker hook"; - type = types.submodule { - imports = [ hookModule ./hooks/flake-checker.nix ]; - }; - default = { }; - }; - flynt = mkOption { - description = "flynt hook"; - type = types.submodule { - imports = [ hookModule ./hooks/flynt.nix ]; - }; - default = { }; - }; - fourmolu = mkOption { - description = "fourmolu hook"; - type = types.submodule { - imports = [ hookModule ./hooks/fourmolu.nix ]; - }; - default = { }; - }; - forbid-new-submodules = mkOption { - description = "forbid-new-submodules hook"; - type = types.submodule { - imports = [ hookModule ./hooks/forbid-new-submodules.nix ]; - }; - default = { }; - }; - fprettify = mkOption { - description = "fprettify hook"; - type = types.submodule { - imports = [ hookModule ./hooks/fprettify.nix ]; - }; - default = { }; - }; - gitlint = mkOption { - description = "gitlint hook"; - type = types.submodule { - imports = [ hookModule ./hooks/gitlint.nix ]; - }; - default = { }; - }; - gofmt = mkOption { - description = "gofmt hook"; - type = types.submodule { - imports = [ hookModule ./hooks/gofmt.nix ]; - }; - default = { }; - }; - golangci-lint = mkOption { - description = "golangci-lint hook"; - type = types.submodule { - imports = [ hookModule ./hooks/golangci-lint.nix ]; - }; - default = { }; - }; - golines = mkOption { - description = "golines hook"; - type = types.submodule { - imports = [ hookModule ./hooks/golines.nix ]; - }; - default = { }; - }; - gotest = mkOption { - description = "gotest hook"; - type = types.submodule { - imports = [ hookModule ./hooks/gotest.nix ]; - }; - default = { }; - }; - govet = mkOption { - description = "govet hook"; - type = types.submodule { - imports = [ hookModule ./hooks/govet.nix ]; - }; - default = { }; - }; - gptcommit = mkOption { - description = "gptcommit hook"; - type = types.submodule { - imports = [ hookModule ./hooks/gptcommit.nix ]; - }; - default = { }; - }; - hadolint = mkOption { - description = "hadolint hook"; - type = types.submodule { - imports = [ hookModule ./hooks/hadolint.nix ]; - }; - default = { }; - }; - headache = mkOption { - description = "headache hook"; - type = types.submodule { - imports = [ hookModule ./hooks/headache.nix ]; - }; - default = { }; - }; - hlint = mkOption { - description = "hlint hook"; - type = types.submodule { - imports = [ hookModule ./hooks/hlint.nix ]; - }; - default = { }; - }; - hpack = mkOption { - description = "hpack hook"; - type = types.submodule { - imports = [ hookModule ./hooks/hpack.nix ]; - }; - default = { }; - }; - isort = mkOption { - description = "isort hook"; - type = types.submodule { - imports = [ hookModule ./hooks/isort.nix ]; - }; - default = { }; - }; - lacheck = mkOption { - description = "lacheck hook"; - type = types.submodule { - imports = [ hookModule ./hooks/lacheck.nix ]; - }; - default = { }; - }; - latexindent = mkOption { - description = "latexindent hook"; - type = types.submodule { - imports = [ hookModule ./hooks/latexindent.nix ]; - }; - default = { }; - }; - lua-ls = mkOption { - description = "lua-ls hook"; - type = types.submodule { - imports = [ hookModule ./hooks/lua-ls.nix ]; - }; - default = { }; - }; - lychee = mkOption { - description = "lychee hook"; - type = types.submodule { - imports = [ hookModule ./hooks/lychee.nix ]; - }; - default = { }; - }; - markdownlint = mkOption { - description = "markdownlint hook"; - type = types.submodule { - imports = [ hookModule ./hooks/markdownlint.nix ]; - }; - default = { }; - }; - mdl = mkOption { - description = "mdl hook"; - type = types.submodule { - imports = [ hookModule ./hooks/mdl.nix ]; - }; - default = { }; - }; - mkdocs-linkcheck = mkOption { - description = "mkdocs-linkcheck hook"; - type = types.submodule { - imports = [ hookModule ./hooks/mkdocs-linkcheck.nix ]; - }; - default = { }; - }; - mypy = mkOption { - description = "mypy hook"; - type = types.submodule { - imports = [ hookModule ./hooks/mypy.nix ]; - }; - default = { }; - }; - nixfmt = mkOption { + actionlint = mkHook { name = "actionlint"; description = "Static checker for GitHub Actions workflow files"; modules = [ ./hooks/actionlint.nix ]; }; + alejandra = mkHook { name = "alejandra"; description = "The Uncompromising Nix Code Formatter"; modules = [ ./hooks/alejandra.nix ]; }; + annex = mkHook { name = "annex"; description = "Runs the git-annex hook for large file support"; modules = [ ./hooks/annex.nix ]; }; + ansible-lint = mkHook { name = "ansible-lint"; description = "Ansible linter"; modules = [ ./hooks/ansible-lint.nix ]; }; + autoflake = mkHook { name = "autoflake"; description = "Remove unused imports and variables from Python code"; modules = [ ./hooks/autoflake.nix ]; }; + bats = mkHook { name = "bats"; description = "Run bash unit tests"; modules = [ ./hooks/bats.nix ]; }; + beautysh = mkHook { name = "beautysh"; description = "Format shell files"; modules = [ ./hooks/beautysh.nix ]; }; + biome = mkHook { name = "biome"; description = "A toolchain for web projects, aimed to provide functionalities to maintain them"; modules = [ ./hooks/biome.nix ]; }; + black = mkHook { name = "black"; description = "The uncompromising Python code formatter"; modules = [ ./hooks/black.nix ]; }; + cabal-fmt = mkHook { name = "cabal-fmt"; description = "Format Cabal files"; modules = [ ./hooks/cabal-fmt.nix ]; }; + cabal-gild = mkHook { name = "cabal-gild"; description = "Format Cabal files"; modules = [ ./hooks/cabal-gild.nix ]; }; + cabal2nix = mkHook { name = "cabal2nix"; description = "Run `cabal2nix` on all `*.cabal` files to generate corresponding `.nix` files"; modules = [ ./hooks/cabal2nix.nix ]; }; + cargo-check = mkHook { name = "cargo-check"; description = "Check the cargo package for errors"; modules = [ ./hooks/cargo-check.nix ]; }; + check-added-large-files = mkHook { name = "check-added-large-files"; description = "Prevent very large files to be committed (e.g. binaries)."; modules = [ ./hooks/check-added-large-files.nix ]; }; + check-builtin-literals = mkHook { name = "check-builtin-literals"; description = "Require literal syntax when initializing empty or zero builtin types in Python."; modules = [ ./hooks/check-builtin-literals.nix ]; }; + check-case-conflicts = mkHook { name = "check-case-conflicts"; description = "Check for files that would conflict in case-insensitive filesystems."; modules = [ ./hooks/check-case-conflicts.nix ]; }; + check-docstring-first = mkHook { name = "check-docstring-first"; description = "Check that all docstrings appear above the code."; modules = [ ./hooks/check-docstring-first.nix ]; }; + check-executables-have-shebangs = mkHook { name = "check-executables-have-shebangs"; description = "Ensure that all non-binary executables have shebangs."; modules = [ ./hooks/check-executables-have-shebangs.nix ]; }; + check-json = mkHook { name = "check-json"; description = "Check syntax of JSON files."; modules = [ ./hooks/check-json.nix ]; }; + check-merge-conflicts = mkHook { name = "check-merge-conflicts"; description = "Check for files that contain merge conflict strings."; modules = [ ./hooks/check-merge-conflicts.nix ]; }; + check-python = mkHook { name = "check-python"; description = "Check syntax of Python file by parsing Python abstract syntax tree."; modules = [ ./hooks/check-python.nix ]; }; + check-shebang-scripts-are-executable = mkHook { name = "check-shebang-scripts-are-executable"; description = "Ensure that all (non-binary) files with a shebang are executable."; modules = [ ./hooks/check-shebang-scripts-are-executable.nix ]; }; + check-symlinks = mkHook { name = "check-symlinks"; description = "Find broken symlinks."; modules = [ ./hooks/check-symlinks.nix ]; }; + check-toml = mkHook { name = "check-toml"; description = "Check syntax of TOML files."; modules = [ ./hooks/check-toml.nix ]; }; + check-vcs-permalinks = mkHook { name = "check-vcs-permalinks"; description = "Ensure that links to VCS websites are permalinks."; modules = [ ./hooks/check-vcs-permalinks.nix ]; }; + check-xml = mkHook { name = "check-xml"; description = "Check syntax of XML files."; modules = [ ./hooks/check-xml.nix ]; }; + check-yaml = mkHook { name = "check-yaml"; description = "Check syntax of YAML files."; modules = [ ./hooks/check-yaml.nix ]; }; + checkmake = mkHook { name = "checkmake"; description = "Experimental linter/analyzer for Makefiles"; modules = [ ./hooks/checkmake.nix ]; }; + chktex = mkHook { name = "chktex"; description = "LaTeX semantic checker"; modules = [ ./hooks/chktex.nix ]; }; + cljfmt = mkHook { name = "cljfmt"; description = "A tool for formatting Clojure code."; modules = [ ./hooks/cljfmt.nix ]; }; + circleci = mkHook { name = "circleci"; description = "Validate CircleCI config files."; modules = [ ./hooks/circleci.nix ]; }; + clang-format = mkHook { name = "clang-format"; description = "Format your code using `clang-format`."; modules = [ ./hooks/clang-format.nix ]; }; + clang-tidy = mkHook { name = "clang-tidy"; description = "Static analyzer for C++ code."; modules = [ ./hooks/clang-tidy.nix ]; }; + clippy = mkHook { name = "clippy"; description = "Lint Rust code."; modules = [ ./hooks/clippy.nix ]; }; + cmake-format = mkHook { name = "cmake-format"; description = "A tool for formatting CMake-files."; modules = [ ./hooks/cmake-format.nix ]; }; + commitizen = mkHook { name = "commitizen"; description = "Check whether the current commit message follows committing rules."; modules = [ ./hooks/commitizen.nix ]; }; + conform = mkHook { name = "conform"; description = "Policy enforcement for commits."; modules = [ ./hooks/conform.nix ]; }; + convco = mkHook { name = "convco"; description = "A tool for checking and creating conventional commits"; modules = [ ./hooks/convco.nix ]; }; + credo = mkHook { name = "credo"; description = "Runs a static code analysis using Credo"; modules = [ ./hooks/credo.nix ]; }; + crystal = mkHook { name = "crystal"; description = "A tool that automatically formats Crystal source code"; modules = [ ./hooks/crystal.nix ]; }; + cspell = mkHook { name = "cspell"; description = "A Spell Checker for Code"; modules = [ ./hooks/cspell.nix ]; }; + dart-analyze = mkHook { name = "dart-analyze"; description = "Dart analyzer"; modules = [ ./hooks/dart-analyze.nix ]; }; + dart-format = mkHook { name = "dart-format"; description = "Dart formatter"; modules = [ ./hooks/dart-format.nix ]; }; + deadnix = mkHook { name = "deadnix"; description = "Scan Nix files for dead code (unused variable bindings)."; modules = [ ./hooks/deadnix.nix ]; }; + detect-aws-credentials = mkHook { name = "detect-aws-credentials"; description = "Detect AWS credentials from the AWS cli credentials file."; modules = [ ./hooks/detect-aws-credentials.nix ]; }; + detect-private-keys = mkHook { name = "detect-private-keys"; description = "Detect the presence of private keys."; modules = [ ./hooks/detect-private-keys.nix ]; }; + dhall-format = mkHook { name = "dhall-format"; description = "Dhall code formatter."; modules = [ ./hooks/dhall-format.nix ]; }; + dialyzer = mkHook { name = "dialyzer"; description = "Runs a static code analysis using Dialyzer"; modules = [ ./hooks/dialyzer.nix ]; }; + denofmt = mkHook { name = "denofmt"; description = "Auto-format JavaScript, TypeScript, Markdown, and JSON files."; modules = [ ./hooks/denofmt.nix ]; }; + denolint = mkHook { name = "denolint"; description = "Lint JavaScript/TypeScript source code."; modules = [ ./hooks/denolint.nix ]; }; + dune-fmt = mkHook { name = "dune-fmt"; description = "Runs dune-build-opam-files to ensure OCaml and Dune are in sync"; modules = [ ./hooks/dune-fmt.nix ]; }; + dune-opam-sync = mkHook { name = "dune-opam-sync"; description = "Check that Dune-generated OPAM files are in sync."; modules = [ ./hooks/dune-opam-sync.nix ]; }; + eclint = mkHook { name = "eclint"; description = "EditorConfig linter written in Go."; modules = [ ./hooks/eclint.nix ]; }; + editorconfig-checker = mkHook { name = "editorconfig-checker"; description = "Verify that the files are in harmony with the `.editorconfig`."; modules = [ ./hooks/editorconfig-checker.nix ]; }; + elm-format = mkHook { name = "elm-format"; description = "Format Elm files."; modules = [ ./hooks/elm-format.nix ]; }; + elm-review = mkHook { name = "elm-review"; description = "Analyzes Elm projects, to help find mistakes before your users find them."; modules = [ ./hooks/elm-review.nix ]; }; + elm-test = mkHook { name = "elm-test"; description = "Run unit tests and fuzz tests for Elm code."; modules = [ ./hooks/elm-test.nix ]; }; + end-of-file-fixer = mkHook { name = "end-of-file-fixer"; description = "Ensures that a file is either empty, or ends with a single newline."; modules = [ ./hooks/end-of-file-fixer.nix ]; }; + eslint = mkHook { name = "eslint"; description = "Find and fix problems in your JavaScript code."; modules = [ ./hooks/eslint.nix ]; }; + flake8 = mkHook { name = "flake8"; description = "Check the style and quality of Python files."; modules = [ ./hooks/flake8.nix ]; }; + fix-byte-order-marker = mkHook { name = "fix-byte-order-marker"; description = "Remove UTF-8 byte order marker."; modules = [ ./hooks/fix-byte-order-marker.nix ]; }; + fix-encoding-pragma = mkHook { name = "fix-encoding-pragma"; description = "Adds # -*- coding: utf-8 -*- to the top of Python files."; modules = [ ./hooks/fix-encoding-pragma.nix ]; }; + flake-checker = mkHook { name = "flake-checker"; description = "Run health checks on your flake-powered Nix projects."; modules = [ ./hooks/flake-checker.nix ]; }; + flynt = mkHook { name = "flynt"; description = "CLI tool to convert a python project's %-formatted strings to f-strings."; modules = [ ./hooks/flynt.nix ]; }; + fourmolu = mkHook { name = "fourmolu"; description = "Haskell code prettifier."; modules = [ ./hooks/fourmolu.nix ]; }; + forbid-new-submodules = mkHook { name = "forbid-new-submodules"; description = "Prevent addition of new Git submodules."; modules = [ ./hooks/forbid-new-submodules.nix ]; }; + fprettify = mkHook { name = "fprettify"; description = "Auto-formatter for modern Fortran code."; modules = [ ./hooks/fprettify.nix ]; }; + gitlint = mkHook { name = "gitlint"; description = "Linting for your git commit messages"; modules = [ ./hooks/gitlint.nix ]; }; + gofmt = mkHook { name = "gofmt"; description = "A tool that automatically formats Go source code"; modules = [ ./hooks/gofmt.nix ]; }; + golangci-lint = mkHook { name = "golangci-lint"; description = "Fast linters runner for Go."; modules = [ ./hooks/golangci-lint.nix ]; }; + golines = mkHook { name = "golines"; description = "A golang formatter that fixes long lines"; modules = [ ./hooks/golines.nix ]; }; + gotest = mkHook { name = "gotest"; description = "Run go tests"; modules = [ ./hooks/gotest.nix ]; }; + govet = mkHook { name = "govet"; description = "Checks correctness of Go programs."; modules = [ ./hooks/govet.nix ]; }; + gptcommit = mkHook { name = "gptcommit"; description = "Generate a commit message using GPT3."; modules = [ ./hooks/gptcommit.nix ]; }; + hadolint = mkHook { name = "hadolint"; description = "Dockerfile linter, validate inline bash."; modules = [ ./hooks/hadolint.nix ]; }; + headache = mkHook { name = "headache"; description = "Lightweight tool for managing headers in source code files."; modules = [ ./hooks/headache.nix ]; }; + hlint = mkHook { name = "hlint"; description = "Haskell linter"; modules = [ ./hooks/hlint.nix ]; }; + hpack = mkHook { name = "hpack"; description = "A modern format for Haskell packages"; modules = [ ./hooks/hpack.nix ]; }; + isort = mkHook { name = "isort"; description = "A Python utility/library to sort imports."; modules = [ ./hooks/isort.nix ]; }; + lacheck = mkHook { name = "lacheck"; description = "LaTeX checker"; modules = [ ./hooks/lacheck.nix ]; }; + latexindent = mkHook { name = "latexindent"; description = "Perl script to add indentation to LaTeX files"; modules = [ ./hooks/latexindent.nix ]; }; + lua-ls = mkHook { name = "lua-ls"; description = "Lua language server"; modules = [ ./hooks/lua-ls.nix ]; }; + lychee = mkHook { name = "lychee"; description = "Fast, async, stream-based link checker"; modules = [ ./hooks/lychee.nix ]; }; + markdownlint = mkHook { name = "markdownlint"; description = "Markdown linter"; modules = [ ./hooks/markdownlint.nix ]; }; + mdl = mkHook { name = "mdl"; description = "Markdown linter"; modules = [ ./hooks/mdl.nix ]; }; + mkdocs-linkcheck = mkHook { name = "mkdocs-linkcheck"; description = "MkDocs link checker"; modules = [ ./hooks/mkdocs-linkcheck.nix ]; }; + mypy = mkHook { name = "mypy"; description = "Optional static type checker for Python"; modules = [ ./hooks/mypy.nix ]; }; + nixfmt = mkHook { + name = "nixfmt"; description = "Deprecated nixfmt hook. Use nixfmt-classic or nixfmt-rfc-style instead."; + modules = [ ./hooks/nixfmt.nix ]; visible = false; - type = types.submodule { - imports = [ hookModule ./hooks/nixfmt.nix ]; - }; - default = { }; - }; - nixfmt-classic = mkOption { - description = "nixfmt (classic) hook"; - type = types.submodule { - imports = [ hookModule ./hooks/nixfmt-classic.nix ]; - }; - default = { }; - }; - nixfmt-rfc-style = mkOption { - description = "nixfmt (RFC 166 style) hook"; - type = types.submodule { - imports = [ hookModule ./hooks/nixfmt-rfc-style.nix ]; - }; - default = { }; - }; - nixpkgs-fmt = mkOption { - description = "nixpkgs-fmt hook"; - type = types.submodule { - imports = [ hookModule ./hooks/nixpkgs-fmt.nix ]; - }; - default = { }; - }; - no-commit-to-branch = mkOption { - description = "no-commit-to-branch-hook"; - type = types.submodule { - imports = [ hookModule ./hooks/no-commit-to-branch.nix ]; - }; - default = { }; - }; - ormolu = mkOption { - description = "ormolu hook"; - type = types.submodule { - imports = [ hookModule ./hooks/ormolu.nix ]; - }; - default = { }; - }; - php-cs-fixer = mkOption { - description = "php-cs-fixer hook"; - type = types.submodule { - imports = [ hookModule ./hooks/php-cs-fixer.nix ]; - }; - default = { }; - }; - phpcbf = mkOption { - description = "phpcbf hook"; - type = types.submodule { - imports = [ hookModule ./hooks/phpcbf.nix ]; - }; - default = { }; - }; - phpcs = mkOption { - description = "phpcs hook"; - type = types.submodule { - imports = [ hookModule ./hooks/phpcs.nix ]; - }; - default = { }; - }; - phpstan = mkOption { - description = "phpstan hook"; - type = types.submodule { - imports = [ hookModule ./hooks/phpstan.nix ]; - }; - default = { }; }; + nixfmt-classic = mkHook { name = "nixfmt-classic"; description = "nixfmt (classic)"; modules = [ ./hooks/nixfmt-classic.nix ]; }; + nixfmt-rfc-style = mkHook { name = "nixfmt-rfc-style"; description = "nixfmt (RFC 166 style)"; modules = [ ./hooks/nixfmt-rfc-style.nix ]; }; + nixpkgs-fmt = mkHook { name = "nixpkgs-fmt"; description = "Nix code formatter for nixpkgs."; modules = [ ./hooks/nixpkgs-fmt.nix ]; }; + no-commit-to-branch = mkHook { name = "no-commit-to-branch"; description = "Protect specific branches from direct checkins"; modules = [ ./hooks/no-commit-to-branch.nix ]; }; + ormolu = mkHook { name = "ormolu"; description = "Haskell source code formatter"; modules = [ ./hooks/ormolu.nix ]; }; + php-cs-fixer = mkHook { name = "php-cs-fixer"; description = "PHP coding standards fixer"; modules = [ ./hooks/php-cs-fixer.nix ]; }; + phpcbf = mkHook { name = "phpcbf"; description = "PHP code beautifier and fixer"; modules = [ ./hooks/phpcbf.nix ]; }; + phpcs = mkHook { name = "phpcs"; description = "PHP code sniffer"; modules = [ ./hooks/phpcs.nix ]; }; + phpstan = mkHook { name = "phpstan"; description = "PHP static analysis tool"; modules = [ ./hooks/phpstan.nix ]; }; # See all CLI flags for prettier [here](https://prettier.io/docs/en/cli.html). # See all options for prettier [here](https://prettier.io/docs/en/options.html). - prettier = mkOption { - description = "prettier hook"; - type = types.submodule { - imports = [ hookModule ./hooks/prettier.nix ]; - }; - default = { }; - }; - pretty-format-json = mkOption - { - description = "pretty-format-json hook"; - type = types.submodule { - imports = [ hookModule ./hooks/pretty-format-json.nix ]; - }; - default = { }; - }; - proselint = mkOption { - description = "proselint hook"; - type = types.submodule { - imports = [ hookModule ./hooks/proselint.nix ]; - }; - default = { }; - }; - psalm = mkOption { - description = "psalm hook"; - type = types.submodule { - imports = [ hookModule ./hooks/psalm.nix ]; - }; - default = { }; - }; - pylint = mkOption { - description = "pylint hook"; - type = types.submodule { - imports = [ hookModule ./hooks/pylint.nix ]; - }; - default = { }; - }; - pyright = mkOption { - description = "pyright hook"; - type = types.submodule { - imports = [ hookModule ./hooks/pyright.nix ]; - }; - default = { }; - }; - pyupgrade = mkOption { - description = "pyupgrade hook"; - type = types.submodule { - imports = [ hookModule ./hooks/pyupgrade.nix ]; - }; - default = { }; - }; - reuse = mkOption { - description = "reuse hook"; - type = types.submodule { - imports = [ hookModule ./hooks/reuse.nix ]; - }; - default = { }; - }; - revive = mkOption { - description = "revive hook"; - type = types.submodule { - imports = [ hookModule ./hooks/revive.nix ]; - }; - default = { }; - }; - ripsecrets = mkOption { - description = "ripsecrets hook"; - type = types.submodule { - imports = [ hookModule ./hooks/ripsecrets.nix ]; - }; - default = { }; - }; - rome = mkOption { + prettier = mkHook { name = "prettier"; description = "Prettier code formatter"; modules = [ ./hooks/prettier.nix ]; }; + pretty-format-json = mkHook { name = "pretty-format-json"; description = "Pretty format JSON"; modules = [ ./hooks/pretty-format-json.nix ]; }; + proselint = mkHook { name = "proselint"; description = "A linter for prose"; modules = [ ./hooks/proselint.nix ]; }; + psalm = mkHook { name = "psalm"; description = "PHP static analysis tool"; modules = [ ./hooks/psalm.nix ]; }; + pylint = mkHook { name = "pylint"; description = "Python static code analysis tool"; modules = [ ./hooks/pylint.nix ]; }; + pyright = mkHook { name = "pyright"; description = "Static type checker for Python"; modules = [ ./hooks/pyright.nix ]; }; + pyupgrade = mkHook { name = "pyupgrade"; description = "Upgrade syntax for newer versions of Python"; modules = [ ./hooks/pyupgrade.nix ]; }; + reuse = mkHook { name = "reuse"; description = "REUSE is a tool for compliance with the REUSE recommendations"; modules = [ ./hooks/reuse.nix ]; }; + revive = mkHook { name = "revive"; description = "Fast, configurable, extensible, flexible, and beautiful linter for Go"; modules = [ ./hooks/revive.nix ]; }; + ripsecrets = mkHook { name = "ripsecrets"; description = "Prevent committing secret keys into your source code"; modules = [ ./hooks/ripsecrets.nix ]; }; + rome = mkHook { + name = "rome"; description = "Deprecated rome hook. Use biome instead."; + modules = [ ./hooks/rome.nix ]; visible = false; - type = types.submodule { - imports = [ hookModule ./hooks/rome.nix ]; - }; - default = { }; }; - rustfmt = mkOption { + rustfmt = mkHook { + name = "rustfmt"; description = '' - Additional rustfmt settings + Rust code formatter Override the `rustfmt` and `cargo` packages by setting `hooks.rustfmt.packageOverrides`. @@ -854,36 +230,16 @@ in hooks.rustfmt.packageOverrides.rustfmt = pkgs.rustfmt; ``` ''; - type = types.submoduleWith { - modules = [ hookModule ./hooks/rustfmt.nix ]; - specialArgs = { rustSettings = config.settings.rust; }; - }; - default = { }; - }; - shfmt = mkOption { - description = "shfmt hook"; - type = types.submodule { - imports = [ hookModule ./hooks/shfmt.nix ]; - }; - default = { }; - }; - sort-file-contents = mkOption { - description = "sort-file-contents-hook"; - type = types.submodule { - imports = [ hookModule ./hooks/sort-file-contents.nix ]; - }; - default = { }; - }; - statix = mkOption { - description = "statix hook"; - type = types.submodule { - imports = [ hookModule ./hooks/statix.nix ]; - }; - default = { }; - }; - treefmt = mkOption { + modules = [ ./hooks/rustfmt.nix ]; + specialArgs = { rustSettings = config.settings.rust; }; + }; + shfmt = mkHook { name = "shfmt"; description = "A shell parser, formatter, and interpreter"; modules = [ ./hooks/shfmt.nix ]; }; + sort-file-contents = mkHook { name = "sort-file-contents"; description = "Sort file contents"; modules = [ ./hooks/sort-file-contents.nix ]; }; + statix = mkHook { name = "statix"; description = "Lints and suggestions for the Nix programming language"; modules = [ ./hooks/statix.nix ]; }; + treefmt = mkHook { + name = "treefmt"; description = '' - Treefmt hook. + One CLI to format the code tree Include any additional formatters configured by treefmt as `hooks.treefmt.settings.formatters`. @@ -900,39 +256,12 @@ in hooks.treefmt.packageOverrides.treefmt = pkgs.treefmt; ``` ''; - type = types.submodule { - imports = [ hookModule ./hooks/treefmt.nix ]; - }; - default = { }; - }; - typos = mkOption { - description = "typos hook"; - type = types.submodule { - imports = [ hookModule ./hooks/typos.nix ]; - }; - default = { }; - }; - vale = mkOption { - description = "vale hook"; - type = types.submodule { - imports = [ hookModule ./hooks/vale.nix ]; - }; - default = { }; - }; - yamlfmt = mkOption { - description = "yamlfmt hook"; - type = types.submodule { - imports = [ hookModule ./hooks/yamlfmt.nix ]; - }; - default = { }; - }; - yamllint = mkOption { - description = "yamllint hook"; - type = types.submodule { - imports = [ hookModule ./hooks/yamllint.nix ]; - }; - default = { }; + modules = [ ./hooks/treefmt.nix ]; }; + typos = mkHook { name = "typos"; description = "Source code spell checker"; modules = [ ./hooks/typos.nix ]; }; + vale = mkHook { name = "vale"; description = "A command-line tool that brings code-like linting to prose"; modules = [ ./hooks/vale.nix ]; }; + yamlfmt = mkHook { name = "yamlfmt"; description = "YAML formatter"; modules = [ ./hooks/yamlfmt.nix ]; }; + yamllint = mkHook { name = "yamllint"; description = "YAML linter"; modules = [ ./hooks/yamllint.nix ]; }; }; config.warnings = From 2e72b55616c6a8fe72fa2a9dd7eb530e5e4cf2f3 Mon Sep 17 00:00:00 2001 From: Sander Date: Mon, 26 May 2025 02:33:44 +0200 Subject: [PATCH 09/13] hooks: simplify the mkHook function --- modules/hooks.nix | 311 ++++++++++++++++------------------ modules/hooks/cargo-check.nix | 6 +- modules/hooks/clippy.nix | 6 +- modules/hooks/rustfmt.nix | 4 +- 4 files changed, 153 insertions(+), 174 deletions(-) diff --git a/modules/hooks.nix b/modules/hooks.nix index 82916565..ce59aac0 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -5,20 +5,18 @@ let # Helper function to create hook options with unified descriptions # Takes an attribute set: { name, description, modules, [specialArgs], [visible], ... } - mkHook = { name, description, modules, specialArgs ? { }, ... }@args: - let - optionArgs = builtins.removeAttrs args [ "name" "description" "modules" "specialArgs" ]; - in - mkOption ({ + mkHook = module: description: + mkOption { inherit description; type = types.submoduleWith ({ - inherit specialArgs; - modules = [ hookModule ] ++ modules ++ [ - { config.description = lib.mkDefault description; } + modules = [ hookModule ] ++ [ + module + # Set name and description + ({ name, ... }: { config = { inherit name description; }; }) ]; }); default = { }; - } // optionArgs); + }; in { imports = @@ -59,7 +57,7 @@ in config.hookModule = { imports = [ ./hook.nix ]; config._module.args = { - inherit (cfg) default_stages tools; + inherit (cfg) default_stages settings tools; mkCmdArgs = predActionList: lib.concatStringsSep " " @@ -98,170 +96,151 @@ in # PLEASE keep this sorted alphabetically. options.hooks = { - actionlint = mkHook { name = "actionlint"; description = "Static checker for GitHub Actions workflow files"; modules = [ ./hooks/actionlint.nix ]; }; - alejandra = mkHook { name = "alejandra"; description = "The Uncompromising Nix Code Formatter"; modules = [ ./hooks/alejandra.nix ]; }; - annex = mkHook { name = "annex"; description = "Runs the git-annex hook for large file support"; modules = [ ./hooks/annex.nix ]; }; - ansible-lint = mkHook { name = "ansible-lint"; description = "Ansible linter"; modules = [ ./hooks/ansible-lint.nix ]; }; - autoflake = mkHook { name = "autoflake"; description = "Remove unused imports and variables from Python code"; modules = [ ./hooks/autoflake.nix ]; }; - bats = mkHook { name = "bats"; description = "Run bash unit tests"; modules = [ ./hooks/bats.nix ]; }; - beautysh = mkHook { name = "beautysh"; description = "Format shell files"; modules = [ ./hooks/beautysh.nix ]; }; - biome = mkHook { name = "biome"; description = "A toolchain for web projects, aimed to provide functionalities to maintain them"; modules = [ ./hooks/biome.nix ]; }; - black = mkHook { name = "black"; description = "The uncompromising Python code formatter"; modules = [ ./hooks/black.nix ]; }; - cabal-fmt = mkHook { name = "cabal-fmt"; description = "Format Cabal files"; modules = [ ./hooks/cabal-fmt.nix ]; }; - cabal-gild = mkHook { name = "cabal-gild"; description = "Format Cabal files"; modules = [ ./hooks/cabal-gild.nix ]; }; - cabal2nix = mkHook { name = "cabal2nix"; description = "Run `cabal2nix` on all `*.cabal` files to generate corresponding `.nix` files"; modules = [ ./hooks/cabal2nix.nix ]; }; - cargo-check = mkHook { name = "cargo-check"; description = "Check the cargo package for errors"; modules = [ ./hooks/cargo-check.nix ]; }; - check-added-large-files = mkHook { name = "check-added-large-files"; description = "Prevent very large files to be committed (e.g. binaries)."; modules = [ ./hooks/check-added-large-files.nix ]; }; - check-builtin-literals = mkHook { name = "check-builtin-literals"; description = "Require literal syntax when initializing empty or zero builtin types in Python."; modules = [ ./hooks/check-builtin-literals.nix ]; }; - check-case-conflicts = mkHook { name = "check-case-conflicts"; description = "Check for files that would conflict in case-insensitive filesystems."; modules = [ ./hooks/check-case-conflicts.nix ]; }; - check-docstring-first = mkHook { name = "check-docstring-first"; description = "Check that all docstrings appear above the code."; modules = [ ./hooks/check-docstring-first.nix ]; }; - check-executables-have-shebangs = mkHook { name = "check-executables-have-shebangs"; description = "Ensure that all non-binary executables have shebangs."; modules = [ ./hooks/check-executables-have-shebangs.nix ]; }; - check-json = mkHook { name = "check-json"; description = "Check syntax of JSON files."; modules = [ ./hooks/check-json.nix ]; }; - check-merge-conflicts = mkHook { name = "check-merge-conflicts"; description = "Check for files that contain merge conflict strings."; modules = [ ./hooks/check-merge-conflicts.nix ]; }; - check-python = mkHook { name = "check-python"; description = "Check syntax of Python file by parsing Python abstract syntax tree."; modules = [ ./hooks/check-python.nix ]; }; - check-shebang-scripts-are-executable = mkHook { name = "check-shebang-scripts-are-executable"; description = "Ensure that all (non-binary) files with a shebang are executable."; modules = [ ./hooks/check-shebang-scripts-are-executable.nix ]; }; - check-symlinks = mkHook { name = "check-symlinks"; description = "Find broken symlinks."; modules = [ ./hooks/check-symlinks.nix ]; }; - check-toml = mkHook { name = "check-toml"; description = "Check syntax of TOML files."; modules = [ ./hooks/check-toml.nix ]; }; - check-vcs-permalinks = mkHook { name = "check-vcs-permalinks"; description = "Ensure that links to VCS websites are permalinks."; modules = [ ./hooks/check-vcs-permalinks.nix ]; }; - check-xml = mkHook { name = "check-xml"; description = "Check syntax of XML files."; modules = [ ./hooks/check-xml.nix ]; }; - check-yaml = mkHook { name = "check-yaml"; description = "Check syntax of YAML files."; modules = [ ./hooks/check-yaml.nix ]; }; - checkmake = mkHook { name = "checkmake"; description = "Experimental linter/analyzer for Makefiles"; modules = [ ./hooks/checkmake.nix ]; }; - chktex = mkHook { name = "chktex"; description = "LaTeX semantic checker"; modules = [ ./hooks/chktex.nix ]; }; - cljfmt = mkHook { name = "cljfmt"; description = "A tool for formatting Clojure code."; modules = [ ./hooks/cljfmt.nix ]; }; - circleci = mkHook { name = "circleci"; description = "Validate CircleCI config files."; modules = [ ./hooks/circleci.nix ]; }; - clang-format = mkHook { name = "clang-format"; description = "Format your code using `clang-format`."; modules = [ ./hooks/clang-format.nix ]; }; - clang-tidy = mkHook { name = "clang-tidy"; description = "Static analyzer for C++ code."; modules = [ ./hooks/clang-tidy.nix ]; }; - clippy = mkHook { name = "clippy"; description = "Lint Rust code."; modules = [ ./hooks/clippy.nix ]; }; - cmake-format = mkHook { name = "cmake-format"; description = "A tool for formatting CMake-files."; modules = [ ./hooks/cmake-format.nix ]; }; - commitizen = mkHook { name = "commitizen"; description = "Check whether the current commit message follows committing rules."; modules = [ ./hooks/commitizen.nix ]; }; - conform = mkHook { name = "conform"; description = "Policy enforcement for commits."; modules = [ ./hooks/conform.nix ]; }; - convco = mkHook { name = "convco"; description = "A tool for checking and creating conventional commits"; modules = [ ./hooks/convco.nix ]; }; - credo = mkHook { name = "credo"; description = "Runs a static code analysis using Credo"; modules = [ ./hooks/credo.nix ]; }; - crystal = mkHook { name = "crystal"; description = "A tool that automatically formats Crystal source code"; modules = [ ./hooks/crystal.nix ]; }; - cspell = mkHook { name = "cspell"; description = "A Spell Checker for Code"; modules = [ ./hooks/cspell.nix ]; }; - dart-analyze = mkHook { name = "dart-analyze"; description = "Dart analyzer"; modules = [ ./hooks/dart-analyze.nix ]; }; - dart-format = mkHook { name = "dart-format"; description = "Dart formatter"; modules = [ ./hooks/dart-format.nix ]; }; - deadnix = mkHook { name = "deadnix"; description = "Scan Nix files for dead code (unused variable bindings)."; modules = [ ./hooks/deadnix.nix ]; }; - detect-aws-credentials = mkHook { name = "detect-aws-credentials"; description = "Detect AWS credentials from the AWS cli credentials file."; modules = [ ./hooks/detect-aws-credentials.nix ]; }; - detect-private-keys = mkHook { name = "detect-private-keys"; description = "Detect the presence of private keys."; modules = [ ./hooks/detect-private-keys.nix ]; }; - dhall-format = mkHook { name = "dhall-format"; description = "Dhall code formatter."; modules = [ ./hooks/dhall-format.nix ]; }; - dialyzer = mkHook { name = "dialyzer"; description = "Runs a static code analysis using Dialyzer"; modules = [ ./hooks/dialyzer.nix ]; }; - denofmt = mkHook { name = "denofmt"; description = "Auto-format JavaScript, TypeScript, Markdown, and JSON files."; modules = [ ./hooks/denofmt.nix ]; }; - denolint = mkHook { name = "denolint"; description = "Lint JavaScript/TypeScript source code."; modules = [ ./hooks/denolint.nix ]; }; - dune-fmt = mkHook { name = "dune-fmt"; description = "Runs dune-build-opam-files to ensure OCaml and Dune are in sync"; modules = [ ./hooks/dune-fmt.nix ]; }; - dune-opam-sync = mkHook { name = "dune-opam-sync"; description = "Check that Dune-generated OPAM files are in sync."; modules = [ ./hooks/dune-opam-sync.nix ]; }; - eclint = mkHook { name = "eclint"; description = "EditorConfig linter written in Go."; modules = [ ./hooks/eclint.nix ]; }; - editorconfig-checker = mkHook { name = "editorconfig-checker"; description = "Verify that the files are in harmony with the `.editorconfig`."; modules = [ ./hooks/editorconfig-checker.nix ]; }; - elm-format = mkHook { name = "elm-format"; description = "Format Elm files."; modules = [ ./hooks/elm-format.nix ]; }; - elm-review = mkHook { name = "elm-review"; description = "Analyzes Elm projects, to help find mistakes before your users find them."; modules = [ ./hooks/elm-review.nix ]; }; - elm-test = mkHook { name = "elm-test"; description = "Run unit tests and fuzz tests for Elm code."; modules = [ ./hooks/elm-test.nix ]; }; - end-of-file-fixer = mkHook { name = "end-of-file-fixer"; description = "Ensures that a file is either empty, or ends with a single newline."; modules = [ ./hooks/end-of-file-fixer.nix ]; }; - eslint = mkHook { name = "eslint"; description = "Find and fix problems in your JavaScript code."; modules = [ ./hooks/eslint.nix ]; }; - flake8 = mkHook { name = "flake8"; description = "Check the style and quality of Python files."; modules = [ ./hooks/flake8.nix ]; }; - fix-byte-order-marker = mkHook { name = "fix-byte-order-marker"; description = "Remove UTF-8 byte order marker."; modules = [ ./hooks/fix-byte-order-marker.nix ]; }; - fix-encoding-pragma = mkHook { name = "fix-encoding-pragma"; description = "Adds # -*- coding: utf-8 -*- to the top of Python files."; modules = [ ./hooks/fix-encoding-pragma.nix ]; }; - flake-checker = mkHook { name = "flake-checker"; description = "Run health checks on your flake-powered Nix projects."; modules = [ ./hooks/flake-checker.nix ]; }; - flynt = mkHook { name = "flynt"; description = "CLI tool to convert a python project's %-formatted strings to f-strings."; modules = [ ./hooks/flynt.nix ]; }; - fourmolu = mkHook { name = "fourmolu"; description = "Haskell code prettifier."; modules = [ ./hooks/fourmolu.nix ]; }; - forbid-new-submodules = mkHook { name = "forbid-new-submodules"; description = "Prevent addition of new Git submodules."; modules = [ ./hooks/forbid-new-submodules.nix ]; }; - fprettify = mkHook { name = "fprettify"; description = "Auto-formatter for modern Fortran code."; modules = [ ./hooks/fprettify.nix ]; }; - gitlint = mkHook { name = "gitlint"; description = "Linting for your git commit messages"; modules = [ ./hooks/gitlint.nix ]; }; - gofmt = mkHook { name = "gofmt"; description = "A tool that automatically formats Go source code"; modules = [ ./hooks/gofmt.nix ]; }; - golangci-lint = mkHook { name = "golangci-lint"; description = "Fast linters runner for Go."; modules = [ ./hooks/golangci-lint.nix ]; }; - golines = mkHook { name = "golines"; description = "A golang formatter that fixes long lines"; modules = [ ./hooks/golines.nix ]; }; - gotest = mkHook { name = "gotest"; description = "Run go tests"; modules = [ ./hooks/gotest.nix ]; }; - govet = mkHook { name = "govet"; description = "Checks correctness of Go programs."; modules = [ ./hooks/govet.nix ]; }; - gptcommit = mkHook { name = "gptcommit"; description = "Generate a commit message using GPT3."; modules = [ ./hooks/gptcommit.nix ]; }; - hadolint = mkHook { name = "hadolint"; description = "Dockerfile linter, validate inline bash."; modules = [ ./hooks/hadolint.nix ]; }; - headache = mkHook { name = "headache"; description = "Lightweight tool for managing headers in source code files."; modules = [ ./hooks/headache.nix ]; }; - hlint = mkHook { name = "hlint"; description = "Haskell linter"; modules = [ ./hooks/hlint.nix ]; }; - hpack = mkHook { name = "hpack"; description = "A modern format for Haskell packages"; modules = [ ./hooks/hpack.nix ]; }; - isort = mkHook { name = "isort"; description = "A Python utility/library to sort imports."; modules = [ ./hooks/isort.nix ]; }; - lacheck = mkHook { name = "lacheck"; description = "LaTeX checker"; modules = [ ./hooks/lacheck.nix ]; }; - latexindent = mkHook { name = "latexindent"; description = "Perl script to add indentation to LaTeX files"; modules = [ ./hooks/latexindent.nix ]; }; - lua-ls = mkHook { name = "lua-ls"; description = "Lua language server"; modules = [ ./hooks/lua-ls.nix ]; }; - lychee = mkHook { name = "lychee"; description = "Fast, async, stream-based link checker"; modules = [ ./hooks/lychee.nix ]; }; - markdownlint = mkHook { name = "markdownlint"; description = "Markdown linter"; modules = [ ./hooks/markdownlint.nix ]; }; - mdl = mkHook { name = "mdl"; description = "Markdown linter"; modules = [ ./hooks/mdl.nix ]; }; - mkdocs-linkcheck = mkHook { name = "mkdocs-linkcheck"; description = "MkDocs link checker"; modules = [ ./hooks/mkdocs-linkcheck.nix ]; }; - mypy = mkHook { name = "mypy"; description = "Optional static type checker for Python"; modules = [ ./hooks/mypy.nix ]; }; - nixfmt = mkHook { - name = "nixfmt"; - description = "Deprecated nixfmt hook. Use nixfmt-classic or nixfmt-rfc-style instead."; - modules = [ ./hooks/nixfmt.nix ]; - visible = false; - }; - nixfmt-classic = mkHook { name = "nixfmt-classic"; description = "nixfmt (classic)"; modules = [ ./hooks/nixfmt-classic.nix ]; }; - nixfmt-rfc-style = mkHook { name = "nixfmt-rfc-style"; description = "nixfmt (RFC 166 style)"; modules = [ ./hooks/nixfmt-rfc-style.nix ]; }; - nixpkgs-fmt = mkHook { name = "nixpkgs-fmt"; description = "Nix code formatter for nixpkgs."; modules = [ ./hooks/nixpkgs-fmt.nix ]; }; - no-commit-to-branch = mkHook { name = "no-commit-to-branch"; description = "Protect specific branches from direct checkins"; modules = [ ./hooks/no-commit-to-branch.nix ]; }; - ormolu = mkHook { name = "ormolu"; description = "Haskell source code formatter"; modules = [ ./hooks/ormolu.nix ]; }; - php-cs-fixer = mkHook { name = "php-cs-fixer"; description = "PHP coding standards fixer"; modules = [ ./hooks/php-cs-fixer.nix ]; }; - phpcbf = mkHook { name = "phpcbf"; description = "PHP code beautifier and fixer"; modules = [ ./hooks/phpcbf.nix ]; }; - phpcs = mkHook { name = "phpcs"; description = "PHP code sniffer"; modules = [ ./hooks/phpcs.nix ]; }; - phpstan = mkHook { name = "phpstan"; description = "PHP static analysis tool"; modules = [ ./hooks/phpstan.nix ]; }; + actionlint = mkHook ./hooks/actionlint.nix "Static checker for GitHub Actions workflow files"; + alejandra = mkHook ./hooks/alejandra.nix "The Uncompromising Nix Code Formatter"; + annex = mkHook ./hooks/annex.nix "Runs the git-annex hook for large file support"; + ansible-lint = mkHook ./hooks/ansible-lint.nix "Ansible linter"; + autoflake = mkHook ./hooks/autoflake.nix "Remove unused imports and variables from Python code"; + bats = mkHook ./hooks/bats.nix "Run bash unit tests"; + beautysh = mkHook ./hooks/beautysh.nix "Format shell files"; + biome = mkHook ./hooks/biome.nix "A toolchain for web projects, aimed to provide functionalities to maintain them"; + black = mkHook ./hooks/black.nix "The uncompromising Python code formatter"; + cabal-fmt = mkHook ./hooks/cabal-fmt.nix "Format Cabal files"; + cabal-gild = mkHook ./hooks/cabal-gild.nix "Format Cabal files"; + cabal2nix = mkHook ./hooks/cabal2nix.nix "Run `cabal2nix` on all `*.cabal` files to generate corresponding `.nix` files"; + cargo-check = mkHook ./hooks/cargo-check.nix "Check the cargo package for errors"; + check-added-large-files = mkHook ./hooks/check-added-large-files.nix "Prevent very large files to be committed (e.g. binaries)."; + check-builtin-literals = mkHook ./hooks/check-builtin-literals.nix "Require literal syntax when initializing empty or zero builtin types in Python."; + check-case-conflicts = mkHook ./hooks/check-case-conflicts.nix "Check for files that would conflict in case-insensitive filesystems."; + check-docstring-first = mkHook ./hooks/check-docstring-first.nix "Check that all docstrings appear above the code."; + check-executables-have-shebangs = mkHook ./hooks/check-executables-have-shebangs.nix "Ensure that all non-binary executables have shebangs."; + check-json = mkHook ./hooks/check-json.nix "Check syntax of JSON files."; + check-merge-conflicts = mkHook ./hooks/check-merge-conflicts.nix "Check for files that contain merge conflict strings."; + check-python = mkHook ./hooks/check-python.nix "Check syntax of Python file by parsing Python abstract syntax tree."; + check-shebang-scripts-are-executable = mkHook ./hooks/check-shebang-scripts-are-executable.nix "Ensure that all (non-binary) files with a shebang are executable."; + check-symlinks = mkHook ./hooks/check-symlinks.nix "Find broken symlinks."; + check-toml = mkHook ./hooks/check-toml.nix "Check syntax of TOML files."; + check-vcs-permalinks = mkHook ./hooks/check-vcs-permalinks.nix "Ensure that links to VCS websites are permalinks."; + check-xml = mkHook ./hooks/check-xml.nix "Check syntax of XML files."; + check-yaml = mkHook ./hooks/check-yaml.nix "Check syntax of YAML files."; + checkmake = mkHook ./hooks/checkmake.nix "Experimental linter/analyzer for Makefiles"; + chktex = mkHook ./hooks/chktex.nix "LaTeX semantic checker"; + cljfmt = mkHook ./hooks/cljfmt.nix "A tool for formatting Clojure code."; + circleci = mkHook ./hooks/circleci.nix "Validate CircleCI config files."; + clang-format = mkHook ./hooks/clang-format.nix "Format your code using `clang-format`."; + clang-tidy = mkHook ./hooks/clang-tidy.nix "Static analyzer for C++ code."; + clippy = mkHook ./hooks/clippy.nix "Lint Rust code."; + cmake-format = mkHook ./hooks/cmake-format.nix "A tool for formatting CMake-files."; + commitizen = mkHook ./hooks/commitizen.nix "Check whether the current commit message follows committing rules."; + conform = mkHook ./hooks/conform.nix "Policy enforcement for commits."; + convco = mkHook ./hooks/convco.nix "A tool for checking and creating conventional commits"; + credo = mkHook ./hooks/credo.nix "Runs a static code analysis using Credo"; + crystal = mkHook ./hooks/crystal.nix "A tool that automatically formats Crystal source code"; + cspell = mkHook ./hooks/cspell.nix "A Spell Checker for Code"; + dart-analyze = mkHook ./hooks/dart-analyze.nix "Dart analyzer"; + dart-format = mkHook ./hooks/dart-format.nix "Dart formatter"; + deadnix = mkHook ./hooks/deadnix.nix "Scan Nix files for dead code (unused variable bindings)."; + detect-aws-credentials = mkHook ./hooks/detect-aws-credentials.nix "Detect AWS credentials from the AWS cli credentials file."; + detect-private-keys = mkHook ./hooks/detect-private-keys.nix "Detect the presence of private keys."; + dhall-format = mkHook ./hooks/dhall-format.nix "Dhall code formatter."; + dialyzer = mkHook ./hooks/dialyzer.nix "Runs a static code analysis using Dialyzer"; + denofmt = mkHook ./hooks/denofmt.nix "Auto-format JavaScript, TypeScript, Markdown, and JSON files."; + denolint = mkHook ./hooks/denolint.nix "Lint JavaScript/TypeScript source code."; + dune-fmt = mkHook ./hooks/dune-fmt.nix "Runs dune-build-opam-files to ensure OCaml and Dune are in sync"; + dune-opam-sync = mkHook ./hooks/dune-opam-sync.nix "Check that Dune-generated OPAM files are in sync."; + eclint = mkHook ./hooks/eclint.nix "EditorConfig linter written in Go."; + editorconfig-checker = mkHook ./hooks/editorconfig-checker.nix "Verify that the files are in harmony with the `.editorconfig`."; + elm-format = mkHook ./hooks/elm-format.nix "Format Elm files."; + elm-review = mkHook ./hooks/elm-review.nix "Analyzes Elm projects, to help find mistakes before your users find them."; + elm-test = mkHook ./hooks/elm-test.nix "Run unit tests and fuzz tests for Elm code."; + end-of-file-fixer = mkHook ./hooks/end-of-file-fixer.nix "Ensures that a file is either empty, or ends with a single newline."; + eslint = mkHook ./hooks/eslint.nix "Find and fix problems in your JavaScript code."; + flake8 = mkHook ./hooks/flake8.nix "Check the style and quality of Python files."; + fix-byte-order-marker = mkHook ./hooks/fix-byte-order-marker.nix "Remove UTF-8 byte order marker."; + fix-encoding-pragma = mkHook ./hooks/fix-encoding-pragma.nix "Adds # -*- coding: utf-8 -*- to the top of Python files."; + flake-checker = mkHook ./hooks/flake-checker.nix "Run health checks on your flake-powered Nix projects."; + flynt = mkHook ./hooks/flynt.nix "CLI tool to convert a python project's %-formatted strings to f-strings."; + fourmolu = mkHook ./hooks/fourmolu.nix "Haskell code prettifier."; + forbid-new-submodules = mkHook ./hooks/forbid-new-submodules.nix "Prevent addition of new Git submodules."; + fprettify = mkHook ./hooks/fprettify.nix "Auto-formatter for modern Fortran code."; + gitlint = mkHook ./hooks/gitlint.nix "Linting for your git commit messages"; + gofmt = mkHook ./hooks/gofmt.nix "A tool that automatically formats Go source code"; + golangci-lint = mkHook ./hooks/golangci-lint.nix "Fast linters runner for Go."; + golines = mkHook ./hooks/golines.nix "A golang formatter that fixes long lines"; + gotest = mkHook ./hooks/gotest.nix "Run go tests"; + govet = mkHook ./hooks/govet.nix "Checks correctness of Go programs."; + gptcommit = mkHook ./hooks/gptcommit.nix "Generate a commit message using GPT3."; + hadolint = mkHook ./hooks/hadolint.nix "Dockerfile linter, validate inline bash."; + headache = mkHook ./hooks/headache.nix "Lightweight tool for managing headers in source code files."; + hlint = mkHook ./hooks/hlint.nix "Haskell linter"; + hpack = mkHook ./hooks/hpack.nix "A modern format for Haskell packages"; + isort = mkHook ./hooks/isort.nix "A Python utility/library to sort imports."; + lacheck = mkHook ./hooks/lacheck.nix "LaTeX checker"; + latexindent = mkHook ./hooks/latexindent.nix "Perl script to add indentation to LaTeX files"; + lua-ls = mkHook ./hooks/lua-ls.nix "Lua language server"; + lychee = mkHook ./hooks/lychee.nix "Fast, async, stream-based link checker"; + markdownlint = mkHook ./hooks/markdownlint.nix "Markdown linter"; + mdl = mkHook ./hooks/mdl.nix "Markdown linter"; + mkdocs-linkcheck = mkHook ./hooks/mkdocs-linkcheck.nix "MkDocs link checker"; + mypy = mkHook ./hooks/mypy.nix "Optional static type checker for Python"; + nixfmt = (mkHook ./hooks/nixfmt.nix "Deprecated nixfmt hook. Use nixfmt-classic or nixfmt-rfc-style instead.") // { visible = false; }; + nixfmt-classic = mkHook ./hooks/nixfmt-classic.nix "nixfmt (classic)"; + nixfmt-rfc-style = mkHook ./hooks/nixfmt-rfc-style.nix "nixfmt (RFC 166 style)"; + nixpkgs-fmt = mkHook ./hooks/nixpkgs-fmt.nix "Nix code formatter for nixpkgs."; + no-commit-to-branch = mkHook ./hooks/no-commit-to-branch.nix "Protect specific branches from direct checkins"; + ormolu = mkHook ./hooks/ormolu.nix "Haskell source code formatter"; + php-cs-fixer = mkHook ./hooks/php-cs-fixer.nix "PHP coding standards fixer"; + phpcbf = mkHook ./hooks/phpcbf.nix "PHP code beautifier and fixer"; + phpcs = mkHook ./hooks/phpcs.nix "PHP code sniffer"; + phpstan = mkHook ./hooks/phpstan.nix "PHP static analysis tool"; # See all CLI flags for prettier [here](https://prettier.io/docs/en/cli.html). # See all options for prettier [here](https://prettier.io/docs/en/options.html). - prettier = mkHook { name = "prettier"; description = "Prettier code formatter"; modules = [ ./hooks/prettier.nix ]; }; - pretty-format-json = mkHook { name = "pretty-format-json"; description = "Pretty format JSON"; modules = [ ./hooks/pretty-format-json.nix ]; }; - proselint = mkHook { name = "proselint"; description = "A linter for prose"; modules = [ ./hooks/proselint.nix ]; }; - psalm = mkHook { name = "psalm"; description = "PHP static analysis tool"; modules = [ ./hooks/psalm.nix ]; }; - pylint = mkHook { name = "pylint"; description = "Python static code analysis tool"; modules = [ ./hooks/pylint.nix ]; }; - pyright = mkHook { name = "pyright"; description = "Static type checker for Python"; modules = [ ./hooks/pyright.nix ]; }; - pyupgrade = mkHook { name = "pyupgrade"; description = "Upgrade syntax for newer versions of Python"; modules = [ ./hooks/pyupgrade.nix ]; }; - reuse = mkHook { name = "reuse"; description = "REUSE is a tool for compliance with the REUSE recommendations"; modules = [ ./hooks/reuse.nix ]; }; - revive = mkHook { name = "revive"; description = "Fast, configurable, extensible, flexible, and beautiful linter for Go"; modules = [ ./hooks/revive.nix ]; }; - ripsecrets = mkHook { name = "ripsecrets"; description = "Prevent committing secret keys into your source code"; modules = [ ./hooks/ripsecrets.nix ]; }; - rome = mkHook { - name = "rome"; - description = "Deprecated rome hook. Use biome instead."; - modules = [ ./hooks/rome.nix ]; - visible = false; - }; - rustfmt = mkHook { - name = "rustfmt"; - description = '' - Rust code formatter + prettier = mkHook ./hooks/prettier.nix "Prettier code formatter"; + pretty-format-json = mkHook ./hooks/pretty-format-json.nix "Pretty format JSON"; + proselint = mkHook ./hooks/proselint.nix "A linter for prose"; + psalm = mkHook ./hooks/psalm.nix "PHP static analysis tool"; + pylint = mkHook ./hooks/pylint.nix "Python static code analysis tool"; + pyright = mkHook ./hooks/pyright.nix "Static type checker for Python"; + pyupgrade = mkHook ./hooks/pyupgrade.nix "Upgrade syntax for newer versions of Python"; + reuse = mkHook ./hooks/reuse.nix "REUSE is a tool for compliance with the REUSE recommendations"; + revive = mkHook ./hooks/revive.nix "Fast, configurable, extensible, flexible, and beautiful linter for Go"; + ripsecrets = mkHook ./hooks/ripsecrets.nix "Prevent committing secret keys into your source code"; + rome = (mkHook ./hooks/rome.nix "Deprecated rome hook. Use biome instead.") // { visible = false; }; + rustfmt = mkHook ./hooks/rustfmt.nix '' + Rust code formatter - Override the `rustfmt` and `cargo` packages by setting `hooks.rustfmt.packageOverrides`. + Override the `rustfmt` and `cargo` packages by setting `hooks.rustfmt.packageOverrides`. - ``` - hooks.rustfmt.packageOverrides.cargo = pkgs.cargo; - hooks.rustfmt.packageOverrides.rustfmt = pkgs.rustfmt; - ``` - ''; - modules = [ ./hooks/rustfmt.nix ]; - specialArgs = { rustSettings = config.settings.rust; }; - }; - shfmt = mkHook { name = "shfmt"; description = "A shell parser, formatter, and interpreter"; modules = [ ./hooks/shfmt.nix ]; }; - sort-file-contents = mkHook { name = "sort-file-contents"; description = "Sort file contents"; modules = [ ./hooks/sort-file-contents.nix ]; }; - statix = mkHook { name = "statix"; description = "Lints and suggestions for the Nix programming language"; modules = [ ./hooks/statix.nix ]; }; - treefmt = mkHook { - name = "treefmt"; - description = '' - One CLI to format the code tree + ``` + hooks.rustfmt.packageOverrides.cargo = pkgs.cargo; + hooks.rustfmt.packageOverrides.rustfmt = pkgs.rustfmt; + ``` + ''; + shfmt = mkHook ./hooks/shfmt.nix "A shell parser, formatter, and interpreter"; + sort-file-contents = mkHook ./hooks/sort-file-contents.nix "Sort file contents"; + statix = mkHook ./hooks/statix.nix "Lints and suggestions for the Nix programming language"; + treefmt = mkHook ./hooks/treefmt.nix '' + One CLI to format the code tree - Include any additional formatters configured by treefmt as `hooks.treefmt.settings.formatters`. + Include any additional formatters configured by treefmt as `hooks.treefmt.settings.formatters`. - ``` - hooks.treefmt.settings.formatters = [ - pkgs.nixpkgs-fmt - pkgs.black - ]; - ``` + ``` + hooks.treefmt.settings.formatters = [ + pkgs.nixpkgs-fmt + pkgs.black + ]; + ``` - Override `treefmt` itself by setting `hooks.treefmt.packageOverrides.treefmt`. + Override `treefmt` itself by setting `hooks.treefmt.packageOverrides.treefmt`. - ``` - hooks.treefmt.packageOverrides.treefmt = pkgs.treefmt; - ``` - ''; - modules = [ ./hooks/treefmt.nix ]; - }; - typos = mkHook { name = "typos"; description = "Source code spell checker"; modules = [ ./hooks/typos.nix ]; }; - vale = mkHook { name = "vale"; description = "A command-line tool that brings code-like linting to prose"; modules = [ ./hooks/vale.nix ]; }; - yamlfmt = mkHook { name = "yamlfmt"; description = "YAML formatter"; modules = [ ./hooks/yamlfmt.nix ]; }; - yamllint = mkHook { name = "yamllint"; description = "YAML linter"; modules = [ ./hooks/yamllint.nix ]; }; + ``` + hooks.treefmt.packageOverrides.treefmt = pkgs.treefmt; + ``` + ''; + typos = mkHook ./hooks/typos.nix "Source code spell checker"; + vale = mkHook ./hooks/vale.nix "A command-line tool that brings code-like linting to prose"; + yamlfmt = mkHook ./hooks/yamlfmt.nix "YAML formatter"; + yamllint = mkHook ./hooks/yamllint.nix "YAML linter"; }; config.warnings = diff --git a/modules/hooks/cargo-check.nix b/modules/hooks/cargo-check.nix index a47ac618..319cd39b 100644 --- a/modules/hooks/cargo-check.nix +++ b/modules/hooks/cargo-check.nix @@ -1,6 +1,6 @@ -{ tools, lib, rustSettings, ... }: +{ tools, lib, settings, ... }: let - inherit (rustSettings) cargoManifestPath; + inherit (settings.rust) cargoManifestPath; cargoManifestPathArg = lib.optionalString (cargoManifestPath != null) @@ -15,4 +15,4 @@ in files = "\\.rs$"; pass_filenames = false; }; -} \ No newline at end of file +} diff --git a/modules/hooks/clippy.nix b/modules/hooks/clippy.nix index bdd1e773..888b9cc0 100644 --- a/modules/hooks/clippy.nix +++ b/modules/hooks/clippy.nix @@ -1,8 +1,8 @@ -{ config, lib, pkgs, rustSettings, ... }: +{ config, lib, pkgs, settings, ... }: let inherit (lib) mkOption types; - inherit (rustSettings) cargoManifestPath; - + inherit (settings.rust) cargoManifestPath; + cargoManifestPathArg = lib.optionalString (cargoManifestPath != null) diff --git a/modules/hooks/rustfmt.nix b/modules/hooks/rustfmt.nix index afac2af3..52d12cdc 100644 --- a/modules/hooks/rustfmt.nix +++ b/modules/hooks/rustfmt.nix @@ -1,4 +1,4 @@ -{ lib, config, rustSettings, ... }: +{ lib, config, settings, ... }: let inherit (lib) mkOption types; nameType = types.strMatching "[][*?!0-9A-Za-z_-]+"; @@ -62,7 +62,7 @@ in manifest-path = mkOption { type = types.nullOr types.str; description = "Path to Cargo.toml"; - default = rustSettings.cargoManifestPath; + default = settings.rust.cargoManifestPath; }; message-format = mkOption { type = types.nullOr (types.enum [ "human" "short" ]); From 80be0852dc40b0bdb94df233a26df2148281e756 Mon Sep 17 00:00:00 2001 From: Sander Date: Mon, 26 May 2025 02:34:10 +0200 Subject: [PATCH 10/13] hooks: fix rustfmt --- modules/hooks/rustfmt.nix | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/modules/hooks/rustfmt.nix b/modules/hooks/rustfmt.nix index 52d12cdc..a67661e4 100644 --- a/modules/hooks/rustfmt.nix +++ b/modules/hooks/rustfmt.nix @@ -82,8 +82,32 @@ in }; }; - config.extraPackages = [ - config.packageOverrides.cargo - config.packageOverrides.rustfmt - ]; + config = { + name = "rustfmt"; + description = "Format Rust code."; + package = config.packageOverrides.rustfmt; + entry = + let + cmdArgs = + lib.mkCmdArgs (with config.settings; [ + [ (all) "--all" ] + [ (check) "--check" ] + [ (color != "auto") "--color ${color}" ] + [ (config != { }) config ] + [ (config-path != null) "--config-path ${lib.escapeShellArg config-path}" ] + [ (emit != "files") "--emit ${emit}" ] + [ (files-with-diff) "--files-with-diff" ] + [ (manifest-path != null) "--manifest-path ${lib.escapeShellArg manifest-path}" ] + [ (message-format != null) "--message-format ${message-format}" ] + [ (package != [ ]) "--package ${lib.strings.concatStringsSep " --package " package}" ] + [ verbose "-v" ] + ]); + in + "${config.packageOverrides.rustfmt}/bin/rustfmt ${cmdArgs}"; + files = "\\.rs$"; + extraPackages = [ + config.packageOverrides.cargo + config.packageOverrides.rustfmt + ]; + }; } From bdf843b52d9b92fa4ca6a4da669251875b6616f0 Mon Sep 17 00:00:00 2001 From: Sander Date: Mon, 26 May 2025 02:56:41 +0200 Subject: [PATCH 11/13] hooks: fix hooks --- modules/hooks.nix | 102 ++++++++++++------ modules/hooks/actionlint.nix | 6 +- modules/hooks/alejandra.nix | 2 +- modules/hooks/annex.nix | 6 +- modules/hooks/ansible-lint.nix | 2 +- modules/hooks/autoflake.nix | 2 +- modules/hooks/bats.nix | 6 +- modules/hooks/beautysh.nix | 6 +- modules/hooks/biome.nix | 2 +- modules/hooks/black.nix | 2 +- modules/hooks/cabal-fmt.nix | 6 +- modules/hooks/cabal-gild.nix | 4 +- modules/hooks/cabal2nix.nix | 2 +- modules/hooks/cargo-check.nix | 4 +- modules/hooks/check-added-large-files.nix | 6 +- modules/hooks/check-builtin-literals.nix | 6 +- modules/hooks/check-case-conflicts.nix | 6 +- modules/hooks/check-docstring-first.nix | 6 +- .../hooks/check-executables-have-shebangs.nix | 6 +- modules/hooks/check-json.nix | 6 +- modules/hooks/check-merge-conflicts.nix | 6 +- modules/hooks/check-python.nix | 6 +- .../check-shebang-scripts-are-executable.nix | 6 +- modules/hooks/check-symlinks.nix | 6 +- modules/hooks/check-toml.nix | 6 +- modules/hooks/check-vcs-permalinks.nix | 6 +- modules/hooks/check-xml.nix | 6 +- modules/hooks/check-yaml.nix | 6 +- modules/hooks/checkmake.nix | 4 +- modules/hooks/chktex.nix | 6 +- modules/hooks/circleci.nix | 6 +- modules/hooks/clang-format.nix | 6 +- modules/hooks/clang-tidy.nix | 6 +- modules/hooks/clippy.nix | 7 +- modules/hooks/cljfmt.nix | 6 +- modules/hooks/cmake-format.nix | 2 +- modules/hooks/commitizen.nix | 6 +- modules/hooks/conform.nix | 6 +- modules/hooks/convco.nix | 6 +- modules/hooks/credo.nix | 2 +- modules/hooks/crystal.nix | 6 +- modules/hooks/cspell.nix | 6 +- modules/hooks/dart-analyze.nix | 6 +- modules/hooks/dart-format.nix | 6 +- modules/hooks/deadnix.nix | 2 +- modules/hooks/denofmt.nix | 2 +- modules/hooks/denolint.nix | 2 +- modules/hooks/detect-aws-credentials.nix | 6 +- modules/hooks/detect-private-keys.nix | 6 +- modules/hooks/dhall-format.nix | 6 +- modules/hooks/dialyzer.nix | 6 +- modules/hooks/dune-fmt.nix | 20 +++- modules/hooks/dune-opam-sync.nix | 6 +- modules/hooks/eclint.nix | 2 +- modules/hooks/editorconfig-checker.nix | 6 +- modules/hooks/elm-format.nix | 6 +- modules/hooks/elm-review.nix | 6 +- modules/hooks/elm-test.nix | 6 +- modules/hooks/end-of-file-fixer.nix | 6 +- modules/hooks/eslint.nix | 2 +- modules/hooks/fix-byte-order-marker.nix | 6 +- modules/hooks/fix-encoding-pragma.nix | 6 +- modules/hooks/flake-checker.nix | 6 +- modules/hooks/flake8.nix | 2 +- modules/hooks/forbid-new-submodules.nix | 6 +- modules/hooks/fourmolu.nix | 2 +- modules/hooks/fprettify.nix | 6 +- modules/hooks/gitlint.nix | 6 +- modules/hooks/gofmt.nix | 6 +- modules/hooks/golangci-lint.nix | 6 +- modules/hooks/golines.nix | 2 +- modules/hooks/gotest.nix | 6 +- modules/hooks/govet.nix | 6 +- modules/hooks/gptcommit.nix | 8 +- modules/hooks/hadolint.nix | 6 +- modules/hooks/headache.nix | 4 +- modules/hooks/hindent.nix | 6 +- modules/hooks/hlint.nix | 9 +- modules/hooks/hpack.nix | 19 +++- modules/hooks/html-tidy.nix | 8 +- modules/hooks/hunspell.nix | 6 +- modules/hooks/isort.nix | 18 +++- modules/hooks/juliaformatter.nix | 25 +++-- modules/hooks/lacheck.nix | 18 +++- modules/hooks/latexindent.nix | 10 +- modules/hooks/lua-ls.nix | 46 +++++++- modules/hooks/luacheck.nix | 6 +- modules/hooks/lychee.nix | 18 +++- modules/hooks/markdownlint.nix | 10 +- modules/hooks/mdformat.nix | 6 +- modules/hooks/mdl.nix | 29 ++++- modules/hooks/mdsh.nix | 14 ++- modules/hooks/mix-format.nix | 6 +- modules/hooks/mix-test.nix | 6 +- modules/hooks/mixed-line-endings.nix | 10 +- modules/hooks/mkdocs-linkcheck.nix | 26 ++++- modules/hooks/mypy.nix | 4 +- modules/hooks/name-tests-test.nix | 10 +- modules/hooks/nil.nix | 6 +- modules/hooks/nixpkgs-fmt.nix | 6 +- modules/hooks/ocp-indent.nix | 8 +- modules/hooks/opam-lint.nix | 8 +- modules/hooks/openapi-spec-validator.nix | 6 +- modules/hooks/ormolu.nix | 17 ++- modules/hooks/php-cs-fixer.nix | 16 ++- modules/hooks/phpcbf.nix | 4 +- modules/hooks/phpcs.nix | 12 ++- modules/hooks/phpstan.nix | 16 ++- modules/hooks/poetry-check.nix | 10 +- modules/hooks/poetry-lock.nix | 12 +-- modules/hooks/pre-commit-hook-ensure-sops.nix | 8 +- modules/hooks/prettier.nix | 59 +++++++++- modules/hooks/pretty-format-json.nix | 21 +++- modules/hooks/proselint.nix | 20 +++- modules/hooks/psalm.nix | 12 ++- modules/hooks/purs-tidy.nix | 8 +- modules/hooks/purty.nix | 10 ++ modules/hooks/pylint.nix | 22 +++- modules/hooks/pyright.nix | 12 ++- modules/hooks/python-debug-statements.nix | 6 +- modules/hooks/pyupgrade.nix | 12 ++- modules/hooks/reuse.nix | 11 +- modules/hooks/revive.nix | 31 +++++- modules/hooks/ripsecrets.nix | 22 +++- modules/hooks/rome.nix | 2 +- modules/hooks/ruff-format.nix | 9 +- modules/hooks/ruff.nix | 6 +- modules/hooks/rustfmt.nix | 66 +++++++----- modules/hooks/selene.nix | 8 +- modules/hooks/shellcheck.nix | 8 +- modules/hooks/shfmt.nix | 14 ++- modules/hooks/single-quoted-strings.nix | 6 +- modules/hooks/sort-file-contents.nix | 20 +++- modules/hooks/sort-requirements-txt.nix | 10 +- modules/hooks/sort-simple-yaml.nix | 10 +- modules/hooks/staticcheck.nix | 27 ++++- modules/hooks/statix.nix | 26 ++++- modules/hooks/stylish-haskell.nix | 8 +- modules/hooks/stylua.nix | 8 +- modules/hooks/tagref.nix | 6 +- modules/hooks/taplo.nix | 6 +- modules/hooks/terraform-format.nix | 12 +-- modules/hooks/terraform-validate.nix | 12 ++- modules/hooks/tflint.nix | 10 +- modules/hooks/topiary.nix | 21 +++- modules/hooks/treefmt.nix | 38 ++++++- modules/hooks/trim-trailing-whitespace.nix | 9 +- modules/hooks/trufflehog.nix | 14 +-- modules/hooks/typos.nix | 35 +++++- modules/hooks/typstfmt.nix | 8 +- modules/hooks/typstyle.nix | 14 ++- modules/hooks/vale.nix | 21 +++- modules/hooks/yamlfmt.nix | 23 +++- modules/hooks/yamllint.nix | 25 ++++- modules/hooks/zprint.nix | 8 +- 155 files changed, 1205 insertions(+), 467 deletions(-) create mode 100644 modules/hooks/purty.nix diff --git a/modules/hooks.nix b/modules/hooks.nix index ce59aac0..9f07fd36 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -57,6 +57,7 @@ in config.hookModule = { imports = [ ./hook.nix ]; config._module.args = { + inherit pkgs; inherit (cfg) default_stages settings tools; mkCmdArgs = predActionList: lib.concatStringsSep @@ -125,11 +126,11 @@ in check-yaml = mkHook ./hooks/check-yaml.nix "Check syntax of YAML files."; checkmake = mkHook ./hooks/checkmake.nix "Experimental linter/analyzer for Makefiles"; chktex = mkHook ./hooks/chktex.nix "LaTeX semantic checker"; - cljfmt = mkHook ./hooks/cljfmt.nix "A tool for formatting Clojure code."; circleci = mkHook ./hooks/circleci.nix "Validate CircleCI config files."; clang-format = mkHook ./hooks/clang-format.nix "Format your code using `clang-format`."; clang-tidy = mkHook ./hooks/clang-tidy.nix "Static analyzer for C++ code."; clippy = mkHook ./hooks/clippy.nix "Lint Rust code."; + cljfmt = mkHook ./hooks/cljfmt.nix "A tool for formatting Clojure code."; cmake-format = mkHook ./hooks/cmake-format.nix "A tool for formatting CMake-files."; commitizen = mkHook ./hooks/commitizen.nix "Check whether the current commit message follows committing rules."; conform = mkHook ./hooks/conform.nix "Policy enforcement for commits."; @@ -140,12 +141,12 @@ in dart-analyze = mkHook ./hooks/dart-analyze.nix "Dart analyzer"; dart-format = mkHook ./hooks/dart-format.nix "Dart formatter"; deadnix = mkHook ./hooks/deadnix.nix "Scan Nix files for dead code (unused variable bindings)."; + denofmt = mkHook ./hooks/denofmt.nix "Auto-format JavaScript, TypeScript, Markdown, and JSON files."; + denolint = mkHook ./hooks/denolint.nix "Lint JavaScript/TypeScript source code."; detect-aws-credentials = mkHook ./hooks/detect-aws-credentials.nix "Detect AWS credentials from the AWS cli credentials file."; detect-private-keys = mkHook ./hooks/detect-private-keys.nix "Detect the presence of private keys."; dhall-format = mkHook ./hooks/dhall-format.nix "Dhall code formatter."; dialyzer = mkHook ./hooks/dialyzer.nix "Runs a static code analysis using Dialyzer"; - denofmt = mkHook ./hooks/denofmt.nix "Auto-format JavaScript, TypeScript, Markdown, and JSON files."; - denolint = mkHook ./hooks/denolint.nix "Lint JavaScript/TypeScript source code."; dune-fmt = mkHook ./hooks/dune-fmt.nix "Runs dune-build-opam-files to ensure OCaml and Dune are in sync"; dune-opam-sync = mkHook ./hooks/dune-opam-sync.nix "Check that Dune-generated OPAM files are in sync."; eclint = mkHook ./hooks/eclint.nix "EditorConfig linter written in Go."; @@ -155,13 +156,13 @@ in elm-test = mkHook ./hooks/elm-test.nix "Run unit tests and fuzz tests for Elm code."; end-of-file-fixer = mkHook ./hooks/end-of-file-fixer.nix "Ensures that a file is either empty, or ends with a single newline."; eslint = mkHook ./hooks/eslint.nix "Find and fix problems in your JavaScript code."; - flake8 = mkHook ./hooks/flake8.nix "Check the style and quality of Python files."; fix-byte-order-marker = mkHook ./hooks/fix-byte-order-marker.nix "Remove UTF-8 byte order marker."; fix-encoding-pragma = mkHook ./hooks/fix-encoding-pragma.nix "Adds # -*- coding: utf-8 -*- to the top of Python files."; + flake8 = mkHook ./hooks/flake8.nix "Check the style and quality of Python files."; flake-checker = mkHook ./hooks/flake-checker.nix "Run health checks on your flake-powered Nix projects."; flynt = mkHook ./hooks/flynt.nix "CLI tool to convert a python project's %-formatted strings to f-strings."; - fourmolu = mkHook ./hooks/fourmolu.nix "Haskell code prettifier."; forbid-new-submodules = mkHook ./hooks/forbid-new-submodules.nix "Prevent addition of new Git submodules."; + fourmolu = mkHook ./hooks/fourmolu.nix "Haskell code prettifier."; fprettify = mkHook ./hooks/fprettify.nix "Auto-formatter for modern Fortran code."; gitlint = mkHook ./hooks/gitlint.nix "Linting for your git commit messages"; gofmt = mkHook ./hooks/gofmt.nix "A tool that automatically formats Go source code"; @@ -174,38 +175,58 @@ in headache = mkHook ./hooks/headache.nix "Lightweight tool for managing headers in source code files."; hlint = mkHook ./hooks/hlint.nix "Haskell linter"; hpack = mkHook ./hooks/hpack.nix "A modern format for Haskell packages"; + html-tidy = mkHook ./hooks/html-tidy.nix "HTML linter."; + hunspell = mkHook ./hooks/hunspell.nix "Spell checker and morphological analyzer."; isort = mkHook ./hooks/isort.nix "A Python utility/library to sort imports."; + juliaformatter = mkHook ./hooks/juliaformatter.nix "Run JuliaFormatter.jl against Julia source files"; lacheck = mkHook ./hooks/lacheck.nix "LaTeX checker"; latexindent = mkHook ./hooks/latexindent.nix "Perl script to add indentation to LaTeX files"; lua-ls = mkHook ./hooks/lua-ls.nix "Lua language server"; - lychee = mkHook ./hooks/lychee.nix "Fast, async, stream-based link checker"; - markdownlint = mkHook ./hooks/markdownlint.nix "Markdown linter"; - mdl = mkHook ./hooks/mdl.nix "Markdown linter"; - mkdocs-linkcheck = mkHook ./hooks/mkdocs-linkcheck.nix "MkDocs link checker"; - mypy = mkHook ./hooks/mypy.nix "Optional static type checker for Python"; - nixfmt = (mkHook ./hooks/nixfmt.nix "Deprecated nixfmt hook. Use nixfmt-classic or nixfmt-rfc-style instead.") // { visible = false; }; - nixfmt-classic = mkHook ./hooks/nixfmt-classic.nix "nixfmt (classic)"; - nixfmt-rfc-style = mkHook ./hooks/nixfmt-rfc-style.nix "nixfmt (RFC 166 style)"; - nixpkgs-fmt = mkHook ./hooks/nixpkgs-fmt.nix "Nix code formatter for nixpkgs."; - no-commit-to-branch = mkHook ./hooks/no-commit-to-branch.nix "Protect specific branches from direct checkins"; + luacheck = mkHook ./hooks/luacheck.nix "A tool for linting and static analysis of Lua code."; + lychee = mkHook ./hooks/lychee.nix "A fast, async, stream-based link checker that finds broken hyperlinks and mail addresses inside Markdown, HTML, reStructuredText, or any other text file or website."; + markdownlint = mkHook ./hooks/markdownlint.nix "Style checker and linter for markdown files."; + mdformat = mkHook ./hooks/mdformat.nix "CommonMark compliant Markdown formatter"; + mdl = mkHook ./hooks/mdl.nix "A tool to check markdown files and flag style issues."; + mdsh = mkHook ./hooks/mdsh.nix "Markdown shell pre-processor."; + mix-format = mkHook ./hooks/mix-format.nix "Runs the built-in Elixir syntax formatter"; + mix-test = mkHook ./hooks/mix-test.nix "Runs the built-in Elixir test framework"; + mixed-line-endings = mkHook ./hooks/mixed-line-endings.nix "Resolve mixed line endings."; + mkdocs-linkcheck = mkHook ./hooks/mkdocs-linkcheck.nix "Validate links associated with markdown-based, statically generated websites"; + mypy = mkHook ./hooks/mypy.nix "Static type checker for Python"; + name-tests-test = mkHook ./hooks/name-tests-test.nix "Verify that Python test files are named correctly."; + nil = mkHook ./hooks/nil.nix "Incremental analysis assistant for writing in Nix."; + nixfmt = (mkHook ./hooks/nixfmt.nix "Deprecated Nix code prettifier. Use nixfmt-classic or nixfmt-rfc-style instead.") // { visible = false; }; + nixfmt-classic = mkHook ./hooks/nixfmt-classic.nix "Nix code prettifier (classic)"; + nixfmt-rfc-style = mkHook ./hooks/nixfmt-rfc-style.nix "Nix code prettifier (RFC 166 style)."; + nixpkgs-fmt = mkHook ./hooks/nixpkgs-fmt.nix "Nix code prettifier."; + no-commit-to-branch = mkHook ./hooks/no-commit-to-branch.nix "Disallow committing to certain branch/branches."; + ocp-indent = mkHook ./hooks/ocp-indent.nix "A tool to indent OCaml code."; + opam-lint = mkHook ./hooks/opam-lint.nix "OCaml package manager configuration checker"; + openapi-spec-validator = mkHook ./hooks/openapi-spec-validator.nix "Validate OpenAPI specifications."; ormolu = mkHook ./hooks/ormolu.nix "Haskell source code formatter"; - php-cs-fixer = mkHook ./hooks/php-cs-fixer.nix "PHP coding standards fixer"; - phpcbf = mkHook ./hooks/phpcbf.nix "PHP code beautifier and fixer"; - phpcs = mkHook ./hooks/phpcs.nix "PHP code sniffer"; - phpstan = mkHook ./hooks/phpstan.nix "PHP static analysis tool"; - # See all CLI flags for prettier [here](https://prettier.io/docs/en/cli.html). - # See all options for prettier [here](https://prettier.io/docs/en/options.html). - prettier = mkHook ./hooks/prettier.nix "Prettier code formatter"; + php-cs-fixer = mkHook ./hooks/php-cs-fixer.nix "Lint PHP files."; + phpcbf = mkHook ./hooks/phpcbf.nix "Lint PHP files."; + phpcs = mkHook ./hooks/phpcs.nix "Lint PHP files."; + phpstan = mkHook ./hooks/phpstan.nix "Static analysis of PHP files."; + poetry-check = mkHook ./hooks/poetry-check.nix "Check the validity of the pyproject.toml file."; + poetry-lock = mkHook ./hooks/poetry-lock.nix "Update the poetry.lock file."; + pre-commit-hook-ensure-sops = mkHook ./hooks/pre-commit-hook-ensure-sops.nix "Ensure that sops files are encrypted."; + prettier = mkHook ./hooks/prettier.nix "Opinionated multi-language code formatter."; pretty-format-json = mkHook ./hooks/pretty-format-json.nix "Pretty format JSON"; proselint = mkHook ./hooks/proselint.nix "A linter for prose"; psalm = mkHook ./hooks/psalm.nix "PHP static analysis tool"; - pylint = mkHook ./hooks/pylint.nix "Python static code analysis tool"; + purs-tidy = mkHook ./hooks/purs-tidy.nix "Format purescript files."; + purty = mkHook ./hooks/purty.nix "Format purescript files"; + pylint = mkHook ./hooks/pylint.nix "Lint Python files."; pyright = mkHook ./hooks/pyright.nix "Static type checker for Python"; - pyupgrade = mkHook ./hooks/pyupgrade.nix "Upgrade syntax for newer versions of Python"; - reuse = mkHook ./hooks/reuse.nix "REUSE is a tool for compliance with the REUSE recommendations"; - revive = mkHook ./hooks/revive.nix "Fast, configurable, extensible, flexible, and beautiful linter for Go"; + python-debug-statements = mkHook ./hooks/python-debug-statements.nix "Check for debugger imports and py37+ `breakpoint()` calls in python source."; + pyupgrade = mkHook ./hooks/pyupgrade.nix "Upgrade syntax for newer versions of Python."; + reuse = mkHook ./hooks/reuse.nix "reuse is a tool for compliance with the REUSE recommendations."; + revive = mkHook ./hooks/revive.nix "A linter for Go source code."; ripsecrets = mkHook ./hooks/ripsecrets.nix "Prevent committing secret keys into your source code"; rome = (mkHook ./hooks/rome.nix "Deprecated rome hook. Use biome instead.") // { visible = false; }; + ruff = mkHook ./hooks/ruff.nix "An extremely fast Python linter, written in Rust."; + ruff-format = mkHook ./hooks/ruff-format.nix "An extremely fast Python code formatter, written in Rust."; rustfmt = mkHook ./hooks/rustfmt.nix '' Rust code formatter @@ -216,9 +237,23 @@ in hooks.rustfmt.packageOverrides.rustfmt = pkgs.rustfmt; ``` ''; - shfmt = mkHook ./hooks/shfmt.nix "A shell parser, formatter, and interpreter"; - sort-file-contents = mkHook ./hooks/sort-file-contents.nix "Sort file contents"; + selene = mkHook ./hooks/selene.nix "A blazing-fast modern Lua linter written in Rust."; + shellcheck = mkHook ./hooks/shellcheck.nix "Format shell files."; + shfmt = mkHook ./hooks/shfmt.nix "Format shell files."; + single-quoted-strings = mkHook ./hooks/single-quoted-strings.nix "Replace double quoted strings with single quoted strings."; + sort-file-contents = mkHook ./hooks/sort-file-contents.nix "Sort the lines in specified files (defaults to alphabetical)."; + sort-requirements-txt = mkHook ./hooks/sort-requirements-txt.nix "Sort requirements in requirements.txt and constraints.txt files."; + sort-simple-yaml = mkHook ./hooks/sort-simple-yaml.nix "Sort simple YAML files which consist only of top-level keys, preserving comments and blocks."; + staticcheck = mkHook ./hooks/staticcheck.nix "State of the art linter for the Go programming language."; statix = mkHook ./hooks/statix.nix "Lints and suggestions for the Nix programming language"; + stylish-haskell = mkHook ./hooks/stylish-haskell.nix "A simple Haskell code prettifier."; + stylua = mkHook ./hooks/stylua.nix "An opinionated code formatter for Lua."; + tagref = mkHook ./hooks/tagref.nix "Have tagref check all references and tags."; + taplo = mkHook ./hooks/taplo.nix "Format TOML files with taplo fmt"; + terraform-format = mkHook ./hooks/terraform-format.nix "Format Terraform (`.tf`) files."; + terraform-validate = mkHook ./hooks/terraform-validate.nix "Validates terraform configuration files (`.tf`)."; + tflint = mkHook ./hooks/tflint.nix "A pluggable Terraform linter."; + topiary = mkHook ./hooks/topiary.nix "A universal formatter engine within the Tree-sitter ecosystem, with support for many languages."; treefmt = mkHook ./hooks/treefmt.nix '' One CLI to format the code tree @@ -237,10 +272,15 @@ in hooks.treefmt.packageOverrides.treefmt = pkgs.treefmt; ``` ''; + trim-trailing-whitespace = mkHook ./hooks/trim-trailing-whitespace.nix "Trim trailing whitespace."; + trufflehog = mkHook ./hooks/trufflehog.nix "Secrets scanner."; typos = mkHook ./hooks/typos.nix "Source code spell checker"; - vale = mkHook ./hooks/vale.nix "A command-line tool that brings code-like linting to prose"; - yamlfmt = mkHook ./hooks/yamlfmt.nix "YAML formatter"; - yamllint = mkHook ./hooks/yamllint.nix "YAML linter"; + typstfmt = mkHook ./hooks/typstfmt.nix "Format Typst files."; + typstyle = mkHook ./hooks/typstyle.nix "Beautiful and reliable typst code formatter."; + vale = mkHook ./hooks/vale.nix "A markup-aware linter for prose built with speed and extensibility in mind."; + yamlfmt = mkHook ./hooks/yamlfmt.nix "Formatter for YAML files."; + yamllint = mkHook ./hooks/yamllint.nix "Linter for YAML files."; + zprint = mkHook ./hooks/zprint.nix "Beautifully format Clojure and Clojurescript source code and s-expressions."; }; config.warnings = diff --git a/modules/hooks/actionlint.nix b/modules/hooks/actionlint.nix index 6f82e69d..46bb5dd7 100644 --- a/modules/hooks/actionlint.nix +++ b/modules/hooks/actionlint.nix @@ -1,4 +1,4 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "actionlint"; @@ -6,6 +6,6 @@ files = "^.github/workflows/"; types = [ "yaml" ]; package = tools.actionlint; - entry = "${tools.actionlint}/bin/actionlint"; + entry = "${config.package}/bin/actionlint"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/alejandra.nix b/modules/hooks/alejandra.nix index 6a314061..68b4fc7e 100644 --- a/modules/hooks/alejandra.nix +++ b/modules/hooks/alejandra.nix @@ -49,7 +49,7 @@ in [ (threads != null) "--threads ${toString threads}" ] ]); in - "${tools.alejandra}/bin/alejandra ${cmdArgs}"; + "${config.package}/bin/alejandra ${cmdArgs}"; files = "\\.nix$"; }; } diff --git a/modules/hooks/annex.nix b/modules/hooks/annex.nix index ef40734b..8f1e169a 100644 --- a/modules/hooks/annex.nix +++ b/modules/hooks/annex.nix @@ -1,9 +1,9 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "annex"; description = "Runs the git-annex hook for large file support"; package = tools.git-annex; - entry = "${tools.git-annex}/bin/git-annex pre-commit"; + entry = "${config.package}/bin/git-annex pre-commit"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/ansible-lint.nix b/modules/hooks/ansible-lint.nix index b5971a15..f403b963 100644 --- a/modules/hooks/ansible-lint.nix +++ b/modules/hooks/ansible-lint.nix @@ -29,7 +29,7 @@ in [ (config.settings.configPath != "") "-c ${config.settings.configPath}" ] ]; in - "${tools.ansible-lint}/bin/ansible-lint ${cmdArgs}"; + "${config.package}/bin/ansible-lint ${cmdArgs}"; files = if config.settings.subdir != "" then "${config.settings.subdir}/" else ""; }; } diff --git a/modules/hooks/autoflake.nix b/modules/hooks/autoflake.nix index 06efd292..1470b66a 100644 --- a/modules/hooks/autoflake.nix +++ b/modules/hooks/autoflake.nix @@ -10,7 +10,7 @@ in description = "Path to autoflake binary."; default = null; defaultText = lib.literalExpression '' - "''${tools.autoflake}/bin/autoflake" + "''${config.package}/bin/autoflake" ''; }; diff --git a/modules/hooks/bats.nix b/modules/hooks/bats.nix index 1867e687..04080805 100644 --- a/modules/hooks/bats.nix +++ b/modules/hooks/bats.nix @@ -1,4 +1,4 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "bats"; @@ -6,6 +6,6 @@ types = [ "shell" ]; types_or = [ "bats" "bash" ]; package = tools.bats; - entry = "${tools.bats}/bin/bats -p"; + entry = "${config.package}/bin/bats -p"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/beautysh.nix b/modules/hooks/beautysh.nix index 8568947c..10a3fca8 100644 --- a/modules/hooks/beautysh.nix +++ b/modules/hooks/beautysh.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "beautysh"; description = "Format shell files"; types = [ "shell" ]; package = tools.beautysh; - entry = "${tools.beautysh}/bin/beautysh"; + entry = "${config.package}/bin/beautysh"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/biome.nix b/modules/hooks/biome.nix index 1f0d894f..fbfd3b1e 100644 --- a/modules/hooks/biome.nix +++ b/modules/hooks/biome.nix @@ -14,7 +14,7 @@ in ''; default = null; defaultText = lib.literalExpression '' - "''${tools.biome}/bin/biome" + "''${config.package}/bin/biome" ''; example = lib.literalExpression '' "./node_modules/.bin/biome" diff --git a/modules/hooks/black.nix b/modules/hooks/black.nix index f29d2541..e1fb9829 100644 --- a/modules/hooks/black.nix +++ b/modules/hooks/black.nix @@ -16,7 +16,7 @@ in name = "black"; description = "The uncompromising Python code formatter"; package = tools.black; - entry = "${tools.black}/bin/black ${config.settings.flags}"; + entry = "${config.package}/bin/black ${config.settings.flags}"; types = [ "file" "python" ]; }; } diff --git a/modules/hooks/cabal-fmt.nix b/modules/hooks/cabal-fmt.nix index d4328628..51b0fb7c 100644 --- a/modules/hooks/cabal-fmt.nix +++ b/modules/hooks/cabal-fmt.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "cabal-fmt"; description = "Format Cabal files"; package = tools.cabal-fmt; - entry = "${tools.cabal-fmt}/bin/cabal-fmt --inplace"; + entry = "${config.package}/bin/cabal-fmt --inplace"; files = "\\.cabal$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/cabal-gild.nix b/modules/hooks/cabal-gild.nix index fd83ce08..fbcd49fb 100644 --- a/modules/hooks/cabal-gild.nix +++ b/modules/hooks/cabal-gild.nix @@ -8,11 +8,11 @@ let script = pkgs.writeShellScript "precommit-cabal-gild" '' for file in "$@"; do - ${tools.cabal-gild}/bin/cabal-gild --io="$file" + ${config.package}/bin/cabal-gild --io="$file" done ''; in builtins.toString script; files = "\\.cabal$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/cabal2nix.nix b/modules/hooks/cabal2nix.nix index 186912b6..c46eb5b4 100644 --- a/modules/hooks/cabal2nix.nix +++ b/modules/hooks/cabal2nix.nix @@ -16,7 +16,7 @@ in name = "cabal2nix"; description = "Run `cabal2nix` on all `*.cabal` files to generate corresponding `.nix` files"; package = tools.cabal2nix-dir; - entry = "${tools.cabal2nix-dir}/bin/cabal2nix-dir --outputFileName=${config.settings.outputFilename}"; + entry = "${config.package}/bin/cabal2nix-dir --outputFileName=${config.settings.outputFilename}"; files = "\\.cabal$"; after = [ "hpack" ]; }; diff --git a/modules/hooks/cargo-check.nix b/modules/hooks/cargo-check.nix index 319cd39b..760df510 100644 --- a/modules/hooks/cargo-check.nix +++ b/modules/hooks/cargo-check.nix @@ -1,4 +1,4 @@ -{ tools, lib, settings, ... }: +{ tools, lib, settings, config, ... }: let inherit (settings.rust) cargoManifestPath; cargoManifestPathArg = @@ -11,7 +11,7 @@ in name = "cargo-check"; description = "Check the cargo package for errors"; package = tools.cargo; - entry = "${tools.cargo}/bin/cargo check ${cargoManifestPathArg}"; + entry = "${config.package}/bin/cargo check ${cargoManifestPathArg}"; files = "\\.rs$"; pass_filenames = false; }; diff --git a/modules/hooks/check-added-large-files.nix b/modules/hooks/check-added-large-files.nix index b840e6ed..552294a9 100644 --- a/modules/hooks/check-added-large-files.nix +++ b/modules/hooks/check-added-large-files.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "check-added-large-files"; description = "Prevent very large files to be committed (e.g. binaries)."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/check-added-large-files"; + entry = "${config.package}/bin/check-added-large-files"; stages = [ "pre-commit" "pre-push" "manual" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/check-builtin-literals.nix b/modules/hooks/check-builtin-literals.nix index 67485c86..4f822dd3 100644 --- a/modules/hooks/check-builtin-literals.nix +++ b/modules/hooks/check-builtin-literals.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "check-builtin-literals"; description = "Require literal syntax when initializing empty or zero builtin types in Python."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/check-builtin-literals"; + entry = "${config.package}/bin/check-builtin-literals"; types = [ "python" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/check-case-conflicts.nix b/modules/hooks/check-case-conflicts.nix index 9bd87209..ad4816af 100644 --- a/modules/hooks/check-case-conflicts.nix +++ b/modules/hooks/check-case-conflicts.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "check-case-conflicts"; description = "Check for files that would conflict in case-insensitive filesystems."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/check-case-conflict"; + entry = "${config.package}/bin/check-case-conflict"; types = [ "file" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/check-docstring-first.nix b/modules/hooks/check-docstring-first.nix index a6c1610f..f9a3c236 100644 --- a/modules/hooks/check-docstring-first.nix +++ b/modules/hooks/check-docstring-first.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "check-docstring-above"; description = "Check that all docstrings appear above the code."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/check-docstring-first"; + entry = "${config.package}/bin/check-docstring-first"; types = [ "python" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/check-executables-have-shebangs.nix b/modules/hooks/check-executables-have-shebangs.nix index 0c422c76..ecf00c4b 100644 --- a/modules/hooks/check-executables-have-shebangs.nix +++ b/modules/hooks/check-executables-have-shebangs.nix @@ -1,11 +1,11 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "check-executables-have-shebangs"; description = "Ensure that all non-binary executables have shebangs."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/check-executables-have-shebangs"; + entry = "${config.package}/bin/check-executables-have-shebangs"; types = [ "text" "executable" ]; stages = [ "pre-commit" "pre-push" "manual" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/check-json.nix b/modules/hooks/check-json.nix index 1e64c37a..e15e9af3 100644 --- a/modules/hooks/check-json.nix +++ b/modules/hooks/check-json.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "check-json"; description = "Check syntax of JSON files."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/check-json"; + entry = "${config.package}/bin/check-json"; types = [ "json" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/check-merge-conflicts.nix b/modules/hooks/check-merge-conflicts.nix index ed7a10bb..32ad4327 100644 --- a/modules/hooks/check-merge-conflicts.nix +++ b/modules/hooks/check-merge-conflicts.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "check-merge-conflicts"; description = "Check for files that contain merge conflict strings."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/check-merge-conflict"; + entry = "${config.package}/bin/check-merge-conflict"; types = [ "text" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/check-python.nix b/modules/hooks/check-python.nix index 3cafc186..6a876b12 100644 --- a/modules/hooks/check-python.nix +++ b/modules/hooks/check-python.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "check-python"; description = "Check syntax of Python file by parsing Python abstract syntax tree."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/check-ast"; + entry = "${config.package}/bin/check-ast"; types = [ "python" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/check-shebang-scripts-are-executable.nix b/modules/hooks/check-shebang-scripts-are-executable.nix index 2322e8ee..d6eeaff2 100644 --- a/modules/hooks/check-shebang-scripts-are-executable.nix +++ b/modules/hooks/check-shebang-scripts-are-executable.nix @@ -1,11 +1,11 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "check-shebang-scripts-are-executable"; description = "Ensure that all (non-binary) files with a shebang are executable."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/check-shebang-scripts-are-executable"; + entry = "${config.package}/bin/check-shebang-scripts-are-executable"; types = [ "text" ]; stages = [ "pre-commit" "pre-push" "manual" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/check-symlinks.nix b/modules/hooks/check-symlinks.nix index 45eac7fa..6efe935f 100644 --- a/modules/hooks/check-symlinks.nix +++ b/modules/hooks/check-symlinks.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "check-symlinks"; description = "Find broken symlinks."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/check-symlinks"; + entry = "${config.package}/bin/check-symlinks"; types = [ "symlink" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/check-toml.nix b/modules/hooks/check-toml.nix index e70b767a..ed3609c9 100644 --- a/modules/hooks/check-toml.nix +++ b/modules/hooks/check-toml.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "check-toml"; description = "Check syntax of TOML files."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/check-toml"; + entry = "${config.package}/bin/check-toml"; types = [ "toml" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/check-vcs-permalinks.nix b/modules/hooks/check-vcs-permalinks.nix index e77a3552..37e4ea94 100644 --- a/modules/hooks/check-vcs-permalinks.nix +++ b/modules/hooks/check-vcs-permalinks.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "check-vcs-permalinks"; description = "Ensure that links to VCS websites are permalinks."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/check-vcs-permalinks"; + entry = "${config.package}/bin/check-vcs-permalinks"; types = [ "text" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/check-xml.nix b/modules/hooks/check-xml.nix index 57d2aa97..43b321f9 100644 --- a/modules/hooks/check-xml.nix +++ b/modules/hooks/check-xml.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "check-xml"; description = "Check syntax of XML files."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/check-xml"; + entry = "${config.package}/bin/check-xml"; types = [ "xml" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/check-yaml.nix b/modules/hooks/check-yaml.nix index 8146c6d2..da3850ea 100644 --- a/modules/hooks/check-yaml.nix +++ b/modules/hooks/check-yaml.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "check-yaml"; description = "Check syntax of YAML files."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/check-yaml --multi"; + entry = "${config.package}/bin/check-yaml --multi"; types = [ "yaml" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/checkmake.nix b/modules/hooks/checkmake.nix index 0fcedc81..8b5db3b4 100644 --- a/modules/hooks/checkmake.nix +++ b/modules/hooks/checkmake.nix @@ -11,6 +11,6 @@ lib.throwIf (config.package == null) "The version of nixpkgs used by git-hooks.nix must have `checkmake` in version at least 0.2.2 for it to work on non-Linux systems." - "${tools.checkmake}/bin/checkmake"; + "${config.package}/bin/checkmake"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/chktex.nix b/modules/hooks/chktex.nix index 213b0eb1..00f2be30 100644 --- a/modules/hooks/chktex.nix +++ b/modules/hooks/chktex.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "chktex"; description = "LaTeX semantic checker"; types = [ "file" "tex" ]; package = tools.chktex; - entry = "${tools.chktex}/bin/chktex"; + entry = "${config.package}/bin/chktex"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/circleci.nix b/modules/hooks/circleci.nix index b4dca521..cf478d90 100644 --- a/modules/hooks/circleci.nix +++ b/modules/hooks/circleci.nix @@ -1,4 +1,4 @@ -{ tools, lib, pkgs, ... }: +{ config, tools, lib, pkgs, ... }: { config = { name = "circleci"; @@ -8,7 +8,7 @@ set -e failed=false for file in "$@"; do - if ! ${tools.circleci-cli}/bin/circleci config validate "$file" 2>&1 + if ! ${config.package}/bin/circleci config validate "$file" 2>&1 then echo "Config file at $file is invalid, check the errors above." failed=true @@ -21,4 +21,4 @@ files = "^.circleci/"; types = [ "yaml" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/clang-format.nix b/modules/hooks/clang-format.nix index 910cabb5..70f282be 100644 --- a/modules/hooks/clang-format.nix +++ b/modules/hooks/clang-format.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "clang-format"; description = "Format your code using `clang-format`."; package = tools.clang-tools; - entry = "${tools.clang-tools}/bin/clang-format -style=file -i"; + entry = "${config.package}/bin/clang-format -style=file -i"; # Source: # https://github.com/pre-commit/mirrors-clang-format/blob/46516e8f532c8f2d55e801c34a740ebb8036365c/.pre-commit-hooks.yaml types_or = [ @@ -19,4 +19,4 @@ "proto" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/clang-tidy.nix b/modules/hooks/clang-tidy.nix index 9a63083f..59debc10 100644 --- a/modules/hooks/clang-tidy.nix +++ b/modules/hooks/clang-tidy.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "clang-tidy"; description = "Static analyzer for C++ code."; package = tools.clang-tools; - entry = "${tools.clang-tools}/bin/clang-tidy --fix"; + entry = "${config.package}/bin/clang-tidy --fix"; types_or = [ "c" "c++" "c#" "objective-c" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/clippy.nix b/modules/hooks/clippy.nix index 888b9cc0..2bf7e97f 100644 --- a/modules/hooks/clippy.nix +++ b/modules/hooks/clippy.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, settings, ... }: +{ config, tools, lib, pkgs, settings, ... }: let inherit (lib) mkOption types; inherit (settings.rust) cargoManifestPath; @@ -47,10 +47,14 @@ in cargo = mkOption { type = types.package; description = "The cargo package to use"; + default = tools.cargo; + defaultText = "tools.cargo"; }; clippy = mkOption { type = types.package; description = "The clippy package to use"; + default = tools.clippy; + defaultText = "tools.clippy"; }; }; }; @@ -59,7 +63,6 @@ in name = "clippy"; description = "Lint Rust code."; package = wrapper; - packageOverrides = { cargo = config.packageOverrides.cargo; clippy = config.packageOverrides.clippy; }; entry = "${wrapper}/bin/cargo-clippy clippy ${cargoManifestPathArg} ${lib.optionalString config.settings.offline "--offline"} ${lib.optionalString config.settings.allFeatures "--all-features"} ${config.settings.extraArgs} -- ${lib.optionalString config.settings.denyWarnings "-D warnings"}"; files = "\\.rs$"; pass_filenames = false; diff --git a/modules/hooks/cljfmt.nix b/modules/hooks/cljfmt.nix index 8adde7b8..6007af5a 100644 --- a/modules/hooks/cljfmt.nix +++ b/modules/hooks/cljfmt.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "cljfmt"; description = "A tool for formatting Clojure code."; package = tools.cljfmt; - entry = "${tools.cljfmt}/bin/cljfmt fix"; + entry = "${config.package}/bin/cljfmt fix"; types_or = [ "clojure" "clojurescript" "edn" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/cmake-format.nix b/modules/hooks/cmake-format.nix index 050fc8f2..a671821c 100644 --- a/modules/hooks/cmake-format.nix +++ b/modules/hooks/cmake-format.nix @@ -24,7 +24,7 @@ in then "" else "-C ${config.settings.configPath}"; in - "${tools.cmake-format}/bin/cmake-format --check ${maybeConfigPath}"; + "${config.package}/bin/cmake-format --check ${maybeConfigPath}"; files = "\\.cmake$|CMakeLists.txt"; }; } diff --git a/modules/hooks/commitizen.nix b/modules/hooks/commitizen.nix index 8d2cf049..11cdc34d 100644 --- a/modules/hooks/commitizen.nix +++ b/modules/hooks/commitizen.nix @@ -1,4 +1,4 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "commitizen check"; @@ -6,7 +6,7 @@ Check whether the current commit message follows committing rules. ''; package = tools.commitizen; - entry = "${tools.commitizen}/bin/cz check --allow-abort --commit-msg-file"; + entry = "${config.package}/bin/cz check --allow-abort --commit-msg-file"; stages = [ "commit-msg" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/conform.nix b/modules/hooks/conform.nix index dd06f1ac..19cd6f52 100644 --- a/modules/hooks/conform.nix +++ b/modules/hooks/conform.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "conform enforce"; description = "Policy enforcement for commits."; package = tools.conform; - entry = "${tools.conform}/bin/conform enforce --commit-msg-file"; + entry = "${config.package}/bin/conform enforce --commit-msg-file"; stages = [ "commit-msg" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/convco.nix b/modules/hooks/convco.nix index d478b15f..4231e58c 100644 --- a/modules/hooks/convco.nix +++ b/modules/hooks/convco.nix @@ -1,11 +1,11 @@ -{ tools, lib, pkgs, ... }: +{ config, tools, lib, pkgs, ... }: { config = { name = "convco"; package = tools.convco; entry = let - convco = tools.convco; + convco = config.package; script = pkgs.writeShellScript "precommit-convco" '' cat $1 | ${convco}/bin/convco check --from-stdin ''; @@ -17,4 +17,4 @@ script; stages = [ "commit-msg" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/credo.nix b/modules/hooks/credo.nix index 283241ef..7037acd9 100644 --- a/modules/hooks/credo.nix +++ b/modules/hooks/credo.nix @@ -18,7 +18,7 @@ in package = tools.elixir; entry = let strict = if config.settings.strict then "--strict" else ""; - in "${tools.elixir}/bin/mix credo ${strict}"; + in "${config.package}/bin/mix credo ${strict}"; files = "\\.exs?$"; }; } diff --git a/modules/hooks/crystal.nix b/modules/hooks/crystal.nix index 7872940f..5910cba6 100644 --- a/modules/hooks/crystal.nix +++ b/modules/hooks/crystal.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "crystal"; description = "A tool that automatically formats Crystal source code"; package = tools.crystal; - entry = "${tools.crystal}/bin/crystal tool format"; + entry = "${config.package}/bin/crystal tool format"; files = "\.cr$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/cspell.nix b/modules/hooks/cspell.nix index 12c0dd41..62f50e69 100644 --- a/modules/hooks/cspell.nix +++ b/modules/hooks/cspell.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "cspell"; description = "A Spell Checker for Code"; package = tools.cspell; - entry = "${tools.cspell}/bin/cspell --no-summary"; + entry = "${config.package}/bin/cspell --no-summary"; types = [ "text" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/dart-analyze.nix b/modules/hooks/dart-analyze.nix index c34ccd9a..ed4e7160 100644 --- a/modules/hooks/dart-analyze.nix +++ b/modules/hooks/dart-analyze.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "dart analyze"; description = "Dart analyzer"; package = tools.dart; - entry = "${tools.dart}/bin/dart analyze"; + entry = "${config.package}/bin/dart analyze"; types = [ "dart" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/dart-format.nix b/modules/hooks/dart-format.nix index 512959ec..1a888114 100644 --- a/modules/hooks/dart-format.nix +++ b/modules/hooks/dart-format.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "dart format"; description = "Dart formatter"; package = tools.dart; - entry = "${tools.dart}/bin/dart format"; + entry = "${config.package}/bin/dart format"; types = [ "dart" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/deadnix.nix b/modules/hooks/deadnix.nix index 7113616b..a3a27514 100644 --- a/modules/hooks/deadnix.nix +++ b/modules/hooks/deadnix.nix @@ -71,7 +71,7 @@ in [ (exclude != [ ]) "--exclude ${lib.escapeShellArgs exclude}" ] ]); in - "${tools.deadnix}/bin/deadnix ${cmdArgs} --fail"; + "${config.package}/bin/deadnix ${cmdArgs} --fail"; files = "\\.nix$"; }; } diff --git a/modules/hooks/denofmt.nix b/modules/hooks/denofmt.nix index 3a868fc9..48d972fa 100644 --- a/modules/hooks/denofmt.nix +++ b/modules/hooks/denofmt.nix @@ -33,6 +33,6 @@ in [ (config.settings.configPath != "") "-c ${config.settings.configPath}" ] ]; in - "${tools.deno}/bin/deno fmt ${cmdArgs}"; + "${config.package}/bin/deno fmt ${cmdArgs}"; }; } diff --git a/modules/hooks/denolint.nix b/modules/hooks/denolint.nix index c7f33df5..dac5e0a5 100644 --- a/modules/hooks/denolint.nix +++ b/modules/hooks/denolint.nix @@ -35,6 +35,6 @@ in [ (config.settings.configPath != "") "-c ${config.settings.configPath}" ] ]; in - "${tools.deno}/bin/deno lint ${cmdArgs}"; + "${config.package}/bin/deno lint ${cmdArgs}"; }; } diff --git a/modules/hooks/detect-aws-credentials.nix b/modules/hooks/detect-aws-credentials.nix index 352dcf25..4ffa1aaf 100644 --- a/modules/hooks/detect-aws-credentials.nix +++ b/modules/hooks/detect-aws-credentials.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "detect-aws-credentials"; description = "Detect AWS credentials from the AWS cli credentials file."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/detect-aws-credentials --allow-missing-credentials"; + entry = "${config.package}/bin/detect-aws-credentials --allow-missing-credentials"; types = [ "text" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/detect-private-keys.nix b/modules/hooks/detect-private-keys.nix index daa8e735..ef750a8c 100644 --- a/modules/hooks/detect-private-keys.nix +++ b/modules/hooks/detect-private-keys.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "detect-private-keys"; description = "Detect the presence of private keys."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/detect-private-key"; + entry = "${config.package}/bin/detect-private-key"; types = [ "text" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/dhall-format.nix b/modules/hooks/dhall-format.nix index 4909e142..4ead110f 100644 --- a/modules/hooks/dhall-format.nix +++ b/modules/hooks/dhall-format.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "dhall-format"; description = "Dhall code formatter."; package = tools.dhall; - entry = "${tools.dhall}/bin/dhall format"; + entry = "${config.package}/bin/dhall format"; files = "\.dhall$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/dialyzer.nix b/modules/hooks/dialyzer.nix index 73ef07c1..86cd4038 100644 --- a/modules/hooks/dialyzer.nix +++ b/modules/hooks/dialyzer.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "dialyzer"; description = "Runs a static code analysis using Dialyzer"; package = tools.elixir; - entry = "${tools.elixir}/bin/mix dialyzer"; + entry = "${config.package}/bin/mix dialyzer"; files = "\.exs?$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/dune-fmt.nix b/modules/hooks/dune-fmt.nix index 4c210d0d..430ee6b8 100644 --- a/modules/hooks/dune-fmt.nix +++ b/modules/hooks/dune-fmt.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, lib, pkgs, tools, ... }: let inherit (lib) mkOption types; in @@ -17,5 +17,21 @@ in }; }; - config.extraPackages = config.settings.extraRuntimeInputs; + config = { + name = "dune-fmt"; + description = "Runs Dune's formatters on the code tree."; + package = tools.dune-fmt; + entry = + let + auto-promote = if config.settings.auto-promote then "--auto-promote" else ""; + run-dune-fmt = pkgs.writeShellApplication { + name = "run-dune-fmt"; + runtimeInputs = config.settings.extraRuntimeInputs; + text = "${config.package}/bin/dune-fmt ${auto-promote}"; + }; + in + "${run-dune-fmt}/bin/run-dune-fmt"; + pass_filenames = false; + extraPackages = config.settings.extraRuntimeInputs; + }; } diff --git a/modules/hooks/dune-opam-sync.nix b/modules/hooks/dune-opam-sync.nix index a5c66cff..be325054 100644 --- a/modules/hooks/dune-opam-sync.nix +++ b/modules/hooks/dune-opam-sync.nix @@ -1,14 +1,14 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "dune/opam sync"; description = "Check that Dune-generated OPAM files are in sync."; package = tools.dune-build-opam-files; - entry = "${tools.dune-build-opam-files}/bin/dune-build-opam-files"; + entry = "${config.package}/bin/dune-build-opam-files"; files = "(\.opam$)|(\.opam.template$)|((^|/)dune-project$)"; ## We don't pass filenames because they can only be misleading. Indeed, ## we need to re-run `dune build` for every `*.opam` file, but also when ## the `dune-project` file has changed. pass_filenames = false; }; -} \ No newline at end of file +} diff --git a/modules/hooks/eclint.nix b/modules/hooks/eclint.nix index 44bd4531..b38e4cd0 100644 --- a/modules/hooks/eclint.nix +++ b/modules/hooks/eclint.nix @@ -53,6 +53,6 @@ in [ (verbosity != 0) "-verbosity ${toString verbosity}" ] ]); in - "${tools.eclint}/bin/eclint ${cmdArgs}"; + "${config.package}/bin/eclint ${cmdArgs}"; }; } diff --git a/modules/hooks/editorconfig-checker.nix b/modules/hooks/editorconfig-checker.nix index cdb7adb5..9f4d7711 100644 --- a/modules/hooks/editorconfig-checker.nix +++ b/modules/hooks/editorconfig-checker.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "editorconfig-checker"; description = "Verify that the files are in harmony with the `.editorconfig`."; package = tools.editorconfig-checker; - entry = "${tools.editorconfig-checker}/bin/editorconfig-checker"; + entry = "${config.package}/bin/editorconfig-checker"; types = [ "file" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/elm-format.nix b/modules/hooks/elm-format.nix index cbe60e91..d8e6ecd9 100644 --- a/modules/hooks/elm-format.nix +++ b/modules/hooks/elm-format.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "elm-format"; description = "Format Elm files."; package = tools.elm-format; - entry = "${tools.elm-format}/bin/elm-format --yes --elm-version=0.19"; + entry = "${config.package}/bin/elm-format --yes --elm-version=0.19"; files = "\.elm$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/elm-review.nix b/modules/hooks/elm-review.nix index c429b366..57f032ac 100644 --- a/modules/hooks/elm-review.nix +++ b/modules/hooks/elm-review.nix @@ -1,11 +1,11 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "elm-review"; description = "Analyzes Elm projects, to help find mistakes before your users find them."; package = tools.elm-review; - entry = "${tools.elm-review}/bin/elm-review"; + entry = "${config.package}/bin/elm-review"; files = "\.elm$"; pass_filenames = false; }; -} \ No newline at end of file +} diff --git a/modules/hooks/elm-test.nix b/modules/hooks/elm-test.nix index fc3d2509..93a198dc 100644 --- a/modules/hooks/elm-test.nix +++ b/modules/hooks/elm-test.nix @@ -1,11 +1,11 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "elm-test"; description = "Run unit tests and fuzz tests for Elm code."; package = tools.elm-test; - entry = "${tools.elm-test}/bin/elm-test"; + entry = "${config.package}/bin/elm-test"; files = "\.elm$"; pass_filenames = false; }; -} \ No newline at end of file +} diff --git a/modules/hooks/end-of-file-fixer.nix b/modules/hooks/end-of-file-fixer.nix index ef6e2f33..b3077c0f 100644 --- a/modules/hooks/end-of-file-fixer.nix +++ b/modules/hooks/end-of-file-fixer.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "end-of-file-fixer"; description = "Ensures that a file is either empty, or ends with a single newline."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/end-of-file-fixer"; + entry = "${config.package}/bin/end-of-file-fixer"; types = [ "text" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/eslint.nix b/modules/hooks/eslint.nix index 31ea1bec..e1901086 100644 --- a/modules/hooks/eslint.nix +++ b/modules/hooks/eslint.nix @@ -14,7 +14,7 @@ in ''; default = null; defaultText = lib.literalExpression '' - "''${tools.eslint}/bin/eslint" + "''${config.package}/bin/eslint" ''; example = lib.literalExpression '' "./node_modules/.bin/eslint" diff --git a/modules/hooks/fix-byte-order-marker.nix b/modules/hooks/fix-byte-order-marker.nix index d9d85cf2..5dd2f914 100644 --- a/modules/hooks/fix-byte-order-marker.nix +++ b/modules/hooks/fix-byte-order-marker.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "fix-byte-order-marker"; description = "Remove UTF-8 byte order marker."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/fix-byte-order-marker"; + entry = "${config.package}/bin/fix-byte-order-marker"; types = [ "text" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/fix-encoding-pragma.nix b/modules/hooks/fix-encoding-pragma.nix index a686d315..35c747ec 100644 --- a/modules/hooks/fix-encoding-pragma.nix +++ b/modules/hooks/fix-encoding-pragma.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "fix-encoding-pragma"; description = "Adds # -*- coding: utf-8 -*- to the top of Python files.'"; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/fix-encoding-pragma"; + entry = "${config.package}/bin/fix-encoding-pragma"; types = [ "python" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/flake-checker.nix b/modules/hooks/flake-checker.nix index 067d3ed8..b3b605ff 100644 --- a/modules/hooks/flake-checker.nix +++ b/modules/hooks/flake-checker.nix @@ -1,11 +1,11 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "flake-checker"; description = "Run health checks on your flake-powered Nix projects."; package = tools.flake-checker; - entry = "${tools.flake-checker}/bin/flake-checker -f"; + entry = "${config.package}/bin/flake-checker -f"; files = "(^flake\.nix$|^flake\.lock$)"; pass_filenames = false; }; -} \ No newline at end of file +} diff --git a/modules/hooks/flake8.nix b/modules/hooks/flake8.nix index 274b761b..86fb87dd 100644 --- a/modules/hooks/flake8.nix +++ b/modules/hooks/flake8.nix @@ -15,7 +15,7 @@ in description = "flake8 binary path. Should be used to specify flake8 binary from your Python environment."; default = null; defaultText = lib.literalExpression '' - "''${tools.flake8}/bin/flake8" + "''${config.package}/bin/flake8" ''; }; extendIgnore = diff --git a/modules/hooks/forbid-new-submodules.nix b/modules/hooks/forbid-new-submodules.nix index 30aa1f15..71d0cc8b 100644 --- a/modules/hooks/forbid-new-submodules.nix +++ b/modules/hooks/forbid-new-submodules.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "forbid-new-submodules"; description = "Prevent addition of new Git submodules."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/forbid-new-submodules"; + entry = "${config.package}/bin/forbid-new-submodules"; types = [ "directory" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/fourmolu.nix b/modules/hooks/fourmolu.nix index b9c9042c..bbae6125 100644 --- a/modules/hooks/fourmolu.nix +++ b/modules/hooks/fourmolu.nix @@ -16,7 +16,7 @@ in description = "Haskell code prettifier."; package = tools.fourmolu; entry = - "${tools.fourmolu}/bin/fourmolu --mode inplace ${ + "${config.package}/bin/fourmolu --mode inplace ${ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) config.settings.defaultExtensions) }"; files = "\\.l?hs(-boot)?$"; diff --git a/modules/hooks/fprettify.nix b/modules/hooks/fprettify.nix index c5f8c698..b227fbf6 100644 --- a/modules/hooks/fprettify.nix +++ b/modules/hooks/fprettify.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "fprettify"; description = "Auto-formatter for modern Fortran code."; types = [ "fortran " ]; package = tools.fprettify; - entry = "${tools.fprettify}/bin/fprettify"; + entry = "${config.package}/bin/fprettify"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/gitlint.nix b/modules/hooks/gitlint.nix index 6d254ce0..da4a5bc1 100644 --- a/modules/hooks/gitlint.nix +++ b/modules/hooks/gitlint.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "gitlint"; description = "Linting for your git commit messages"; package = tools.gitlint; - entry = "${tools.gitlint}/bin/gitlint --staged --msg-filename"; + entry = "${config.package}/bin/gitlint --staged --msg-filename"; stages = [ "commit-msg" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/gofmt.nix b/modules/hooks/gofmt.nix index 1092b9cf..d2901628 100644 --- a/modules/hooks/gofmt.nix +++ b/modules/hooks/gofmt.nix @@ -1,4 +1,4 @@ -{ tools, lib, pkgs, ... }: +{ config, tools, lib, pkgs, ... }: { config = { name = "gofmt"; @@ -11,7 +11,7 @@ failed=false for file in "$@"; do # redirect stderr so that violations and summaries are properly interleaved. - if ! ${tools.go}/bin/gofmt -l -w "$file" 2>&1 + if ! ${config.package}/bin/gofmt -l -w "$file" 2>&1 then failed=true fi @@ -24,4 +24,4 @@ builtins.toString script; files = "\\.go$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/golangci-lint.nix b/modules/hooks/golangci-lint.nix index 9cc59f8a..9a99d578 100644 --- a/modules/hooks/golangci-lint.nix +++ b/modules/hooks/golangci-lint.nix @@ -1,4 +1,4 @@ -{ tools, lib, pkgs, ... }: +{ config, tools, lib, pkgs, ... }: { config = { name = "golangci-lint"; @@ -9,7 +9,7 @@ script = pkgs.writeShellScript "precommit-golangci-lint" '' set -e for dir in $(echo "$@" | xargs -n1 dirname | sort -u); do - ${tools.golangci-lint}/bin/golangci-lint run ./"$dir" + ${config.package}/bin/golangci-lint run ./"$dir" done ''; in @@ -19,4 +19,4 @@ # all file names in a single run. require_serial = true; }; -} \ No newline at end of file +} diff --git a/modules/hooks/golines.nix b/modules/hooks/golines.nix index 228a0875..0c698082 100644 --- a/modules/hooks/golines.nix +++ b/modules/hooks/golines.nix @@ -23,7 +23,7 @@ in failed=false for file in "$@"; do # redirect stderr so that violations and summaries are properly interleaved. - if ! ${tools.golines}/bin/golines ${config.settings.flags} -w "$file" 2>&1 + if ! ${config.package}/bin/golines ${config.settings.flags} -w "$file" 2>&1 then failed=true fi diff --git a/modules/hooks/gotest.nix b/modules/hooks/gotest.nix index 7baa138d..5327de25 100644 --- a/modules/hooks/gotest.nix +++ b/modules/hooks/gotest.nix @@ -1,4 +1,4 @@ -{ tools, lib, pkgs, ... }: +{ config, tools, lib, pkgs, ... }: { config = { name = "gotest"; @@ -31,7 +31,7 @@ # test each directory one by one for dir in "''${sorted_dirs[@]}"; do - ${tools.go}/bin/go test "./$dir" + ${config.package}/bin/go test "./$dir" done ''; in @@ -41,4 +41,4 @@ # all file names in a single run. require_serial = true; }; -} \ No newline at end of file +} diff --git a/modules/hooks/govet.nix b/modules/hooks/govet.nix index 0d7a4dd2..be84443b 100644 --- a/modules/hooks/govet.nix +++ b/modules/hooks/govet.nix @@ -1,4 +1,4 @@ -{ tools, lib, pkgs, ... }: +{ config, tools, lib, pkgs, ... }: { config = { name = "govet"; @@ -10,7 +10,7 @@ script = pkgs.writeShellScript "precommit-govet" '' set -e for dir in $(echo "$@" | xargs -n1 dirname | sort -u); do - ${tools.go}/bin/go vet -C ./"$dir" + ${config.package}/bin/go vet -C ./"$dir" done ''; in @@ -20,4 +20,4 @@ require_serial = true; files = "\.go$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/gptcommit.nix b/modules/hooks/gptcommit.nix index 9f34e991..1fb6bd84 100644 --- a/modules/hooks/gptcommit.nix +++ b/modules/hooks/gptcommit.nix @@ -1,4 +1,4 @@ -{ tools, lib, pkgs, ... }: +{ config, tools, lib, pkgs, ... }: { config = { name = "gptcommit"; @@ -7,13 +7,13 @@ entry = let script = pkgs.writeShellScript "precommit-gptcomit" '' - ${tools.gptcommit}/bin/gptcommit prepare-commit-msg --commit-source \ + ${config.package}/bin/gptcommit prepare-commit-msg --commit-source \ "$PRE_COMMIT_COMMIT_MSG_SOURCE" --commit-msg-file "$1" ''; in - lib.throwIf (tools.gptcommit == null) "The version of Nixpkgs used by git-hooks.nix does not have the `gptcommit` package. Please use a more recent version of Nixpkgs." + lib.throwIf (config.package == null) "The version of Nixpkgs used by git-hooks.nix does not have the `gptcommit` package. Please use a more recent version of Nixpkgs." toString script; stages = [ "prepare-commit-msg" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/hadolint.nix b/modules/hooks/hadolint.nix index 68339323..8819f91c 100644 --- a/modules/hooks/hadolint.nix +++ b/modules/hooks/hadolint.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "hadolint"; description = "Dockerfile linter, validate inline bash."; package = tools.hadolint; - entry = "${tools.hadolint}/bin/hadolint"; + entry = "${config.package}/bin/hadolint"; files = "Dockerfile$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/headache.nix b/modules/hooks/headache.nix index 2c5dac10..8a11b2cc 100644 --- a/modules/hooks/headache.nix +++ b/modules/hooks/headache.nix @@ -22,8 +22,8 @@ in ## NOTE: `headache` made into in nixpkgs on 12 April 2023. At the ## next NixOS release, the following code will become irrelevant. lib.throwIf - (tools.headache == null) + (config.package == null) "The version of nixpkgs used by git-hooks.nix does not have `ocamlPackages.headache`. Please use a more recent version of nixpkgs." - "${tools.headache}/bin/headache -h ${config.settings.header-file}"; + "${config.package}/bin/headache -h ${config.settings.header-file}"; }; } diff --git a/modules/hooks/hindent.nix b/modules/hooks/hindent.nix index 13885f21..d892f8e8 100644 --- a/modules/hooks/hindent.nix +++ b/modules/hooks/hindent.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "hindent"; description = "Haskell code prettifier."; package = tools.hindent; - entry = "${tools.hindent}/bin/hindent"; + entry = "${config.package}/bin/hindent"; files = "\.l?hs$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/hlint.nix b/modules/hooks/hlint.nix index 362e0327..46e79943 100644 --- a/modules/hooks/hlint.nix +++ b/modules/hooks/hlint.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ config, lib, tools, ... }: let inherit (lib) mkOption types; in @@ -11,4 +11,11 @@ in default = null; }; }; + config = { + name = "hlint"; + description = "HLint gives suggestions on how to improve your source code."; + package = tools.hlint; + entry = "${config.package}/bin/hlint${if config.settings.hintFile == null then "" else " --hint=${config.settings.hintFile}"}"; + files = "\\.l?hs(-boot)?$"; + }; } diff --git a/modules/hooks/hpack.nix b/modules/hooks/hpack.nix index 9eb6b828..29c9f911 100644 --- a/modules/hooks/hpack.nix +++ b/modules/hooks/hpack.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ config, lib, tools, ... }: let inherit (lib) mkOption types; in @@ -11,4 +11,21 @@ in default = false; }; }; + + config = { + name = "hpack"; + description = "`hpack` converts package definitions in the hpack format (`package.yaml`) to Cabal files."; + package = tools.hpack-dir; + entry = "${config.package}/bin/hpack-dir --${if config.settings.silent then "silent" else "verbose"}"; + files = "(\\.l?hs(-boot)?$)|(\\.cabal$)|((^|/)package\\.yaml$)"; + # We don't pass filenames because they can only be misleading. + # Indeed, we need to rerun `hpack` in every directory: + # 1. In which there is a *.cabal file, or + # 2. Below which there are haskell files, or + # 3. In which there is a package.yaml that references haskell files + # that have been changed at arbitrary locations specified in that + # file. + # In other words: We have no choice but to always run `hpack` on every `package.yaml` directory. + pass_filenames = false; + }; } diff --git a/modules/hooks/html-tidy.nix b/modules/hooks/html-tidy.nix index 079380b8..03f4361d 100644 --- a/modules/hooks/html-tidy.nix +++ b/modules/hooks/html-tidy.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "html-tidy"; - description = "Tidy HTML files."; + description = "HTML linter"; package = tools.html-tidy; - entry = "${tools.html-tidy}/bin/tidy -modify -indent -quiet"; + entry = "${config.package}/bin/tidy -modify -indent -quiet"; types = [ "html" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/hunspell.nix b/modules/hooks/hunspell.nix index 66f18791..b203b6da 100644 --- a/modules/hooks/hunspell.nix +++ b/modules/hooks/hunspell.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "hunspell"; description = "Spell checker and morphological analyzer."; package = tools.hunspell; - entry = "${tools.hunspell}/bin/hunspell -l"; + entry = "${config.package}/bin/hunspell -l"; types = [ "text" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/isort.nix b/modules/hooks/isort.nix index 64b76e90..f6933266 100644 --- a/modules/hooks/isort.nix +++ b/modules/hooks/isort.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ config, lib, tools, mkCmdArgs, ... }: let inherit (lib) mkOption types; in @@ -17,4 +17,20 @@ in default = ""; }; }; + + config = { + name = "isort"; + description = "A Python utility / library to sort imports."; + types = [ "file" "python" ]; + package = tools.isort; + entry = + let + cmdArgs = + mkCmdArgs + (with config.settings; [ + [ (profile != "") " --profile ${profile}" ] + ]); + in + "${config.package}/bin/isort${cmdArgs} ${config.settings.flags}"; + }; } diff --git a/modules/hooks/juliaformatter.nix b/modules/hooks/juliaformatter.nix index 72a88508..11e4dac1 100644 --- a/modules/hooks/juliaformatter.nix +++ b/modules/hooks/juliaformatter.nix @@ -1,11 +1,24 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "juliaformatter"; - description = "Format Julia files."; + description = "Run JuliaFormatter.jl against Julia source files"; package = tools.julia-bin; - entry = "${tools.julia-bin}/bin/julia -e 'using JuliaFormatter; format(".")'"; - files = "\.jl$"; - pass_filenames = false; + entry = '' + ${config.package}/bin/julia -e ' + using Pkg + Pkg.activate(".") + using JuliaFormatter + format(ARGS) + out = Cmd(`git diff --name-only`) |> read |> String + if out == "" + exit(0) + else + @error "Some files have been formatted !!!" + write(stdout, out) + exit(1) + end' + ''; + files = "\\.jl$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/lacheck.nix b/modules/hooks/lacheck.nix index 1e6ef53e..017de292 100644 --- a/modules/hooks/lacheck.nix +++ b/modules/hooks/lacheck.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ config, lib, pkgs, tools, ... }: let inherit (lib) mkOption types; in @@ -17,4 +17,20 @@ in default = { }; }; }; + + config = + let + script = pkgs.writeShellScript "precommit-mdsh" '' + for file in $(echo "$@"); do + "${config.package}/bin/lacheck" "$file" + done + ''; + in + { + name = "lacheck"; + description = "A consistency checker for LaTeX documents."; + types = [ "file" "tex" ]; + package = tools.lacheck; + entry = "${script}"; + }; } diff --git a/modules/hooks/latexindent.nix b/modules/hooks/latexindent.nix index 3159e5fb..409dca5c 100644 --- a/modules/hooks/latexindent.nix +++ b/modules/hooks/latexindent.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ config, lib, tools, ... }: let inherit (lib) mkOption types; in @@ -11,4 +11,12 @@ in default = "--local --silent --overwriteIfDifferent"; }; }; + + config = { + name = "latexindent"; + description = "Perl script to add indentation to LaTeX files."; + types = [ "file" "tex" ]; + package = tools.latexindent; + entry = "${config.package}/bin/latexindent ${config.settings.flags}"; + }; } diff --git a/modules/hooks/lua-ls.nix b/modules/hooks/lua-ls.nix index 1e6ef53e..a7c9daec 100644 --- a/modules/hooks/lua-ls.nix +++ b/modules/hooks/lua-ls.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ config, lib, pkgs, tools, ... }: let inherit (lib) mkOption types; in @@ -17,4 +17,48 @@ in default = { }; }; }; + + config = + let + # .luarc.json has to be in a directory, + # or lua-language-server will hang forever. + luarc = pkgs.writeText ".luarc.json" (builtins.toJSON config.settings.configuration); + luarc-dir = pkgs.stdenv.mkDerivation { + name = "luarc"; + unpackPhase = "true"; + installPhase = '' + mkdir $out + cp ${luarc} $out/.luarc.json + ''; + }; + script = pkgs.writeShellApplication { + name = "lua-ls-lint"; + runtimeInputs = [ config.package pkgs.jq ]; + checkPhase = ""; # The default checkPhase depends on GHC + text = '' + set -e + export logpath="$(mktemp -d)" + lua-language-server --check $(realpath .) \ + --checklevel="${config.settings.checklevel}" \ + --configpath="${luarc-dir}/.luarc.json" \ + --logpath="$logpath" + if [[ -f $logpath/check.json ]]; then + echo "+++++++++++++++ lua-language-server diagnostics +++++++++++++++" + cat $logpath/check.json + diagnostic_count=$(jq 'length' $logpath/check.json) + if [ "$diagnostic_count" -gt 0 ]; then + exit 1 + fi + fi + ''; + }; + in + { + name = "lua-ls"; + description = "Uses the lua-language-server CLI to statically type-check and lint Lua code."; + package = tools.lua-language-server; + entry = "${script}/bin/lua-ls-lint"; + files = "\\.lua$"; + pass_filenames = false; + }; } diff --git a/modules/hooks/luacheck.nix b/modules/hooks/luacheck.nix index 136dc80e..f3b3da9d 100644 --- a/modules/hooks/luacheck.nix +++ b/modules/hooks/luacheck.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, config, lib, ... }: { config = { name = "luacheck"; description = "A tool for linting and static analysis of Lua code."; package = tools.luacheck; - entry = "${tools.luacheck}/bin/luacheck"; + entry = "${config.package}/bin/luacheck"; types = [ "lua" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/lychee.nix b/modules/hooks/lychee.nix index 405dd6cf..63fc18bf 100644 --- a/modules/hooks/lychee.nix +++ b/modules/hooks/lychee.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ config, lib, tools, mkCmdArgs, ... }: let inherit (lib) mkOption types; in @@ -17,4 +17,20 @@ in default = ""; }; }; + + config = { + name = "lychee"; + description = "A fast, async, stream-based link checker that finds broken hyperlinks and mail addresses inside Markdown, HTML, reStructuredText, or any other text file or website."; + package = tools.lychee; + entry = + let + cmdArgs = + mkCmdArgs + (with config.settings; [ + [ (configPath != "") " --config ${configPath}" ] + ]); + in + "${config.package}/bin/lychee${cmdArgs} ${config.settings.flags}"; + types = [ "text" ]; + }; } diff --git a/modules/hooks/markdownlint.nix b/modules/hooks/markdownlint.nix index 05c35f36..7b311fb8 100644 --- a/modules/hooks/markdownlint.nix +++ b/modules/hooks/markdownlint.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ config, lib, pkgs, tools, ... }: let inherit (lib) mkOption types; in @@ -12,4 +12,12 @@ in default = { }; }; }; + + config = { + name = "markdownlint"; + description = "Style checker and linter for markdown files."; + package = tools.markdownlint-cli; + entry = "${config.package}/bin/markdownlint -c ${pkgs.writeText "markdownlint.json" (builtins.toJSON config.settings.configuration)}"; + files = "\\.md$"; + }; } diff --git a/modules/hooks/mdformat.nix b/modules/hooks/mdformat.nix index 240409ce..be51e9b5 100644 --- a/modules/hooks/mdformat.nix +++ b/modules/hooks/mdformat.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "mdformat"; description = "CommonMark compliant Markdown formatter."; package = tools.mdformat; - entry = "${tools.mdformat}/bin/mdformat"; + entry = "${config.package}/bin/mdformat"; types = [ "markdown" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/mdl.nix b/modules/hooks/mdl.nix index d54e6e48..f191d4d4 100644 --- a/modules/hooks/mdl.nix +++ b/modules/hooks/mdl.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ config, lib, tools, mkCmdArgs, ... }: let inherit (lib) mkOption types; in @@ -77,4 +77,31 @@ in default = false; }; }; + + config = { + name = "mdl"; + description = "A tool to check markdown files and flag style issues."; + package = tools.mdl; + entry = + let + cmdArgs = + mkCmdArgs + (with config.settings; [ + [ (configPath != "") "--config ${configPath}" ] + [ git-recurse "--git-recurse" ] + [ ignore-front-matter "--ignore-front-matter" ] + [ json "--json" ] + [ (rules != [ ]) "--rules ${lib.strings.concatStringsSep "," rules}" ] + [ (rulesets != [ ]) "--rulesets ${lib.strings.concatStringsSep "," rulesets}" ] + [ show-aliases "--show-aliases" ] + [ warnings "--warnings" ] + [ skip-default-ruleset "--skip-default-ruleset" ] + [ (style != "") "--style ${style}" ] + [ (tags != [ ]) "--tags ${lib.strings.concatStringsSep "," tags}" ] + [ verbose "--verbose" ] + ]); + in + "${config.package}/bin/mdl ${cmdArgs}"; + files = "\\.md$"; + }; } diff --git a/modules/hooks/mdsh.nix b/modules/hooks/mdsh.nix index 3a2450b7..30444950 100644 --- a/modules/hooks/mdsh.nix +++ b/modules/hooks/mdsh.nix @@ -1,11 +1,19 @@ -{ tools, lib, ... }: +{ config, tools, lib, pkgs, ... }: { config = { name = "mdsh"; description = "Markdown shell pre-processor."; package = tools.mdsh; - entry = "${tools.mdsh}/bin/mdsh"; + entry = + let + script = pkgs.writeShellScript "precommit-mdsh" '' + for file in $(echo "$@"); do + ${config.package}/bin/mdsh -i "$file" + done + ''; + in + toString script; files = "\.md$"; pass_filenames = false; }; -} \ No newline at end of file +} diff --git a/modules/hooks/mix-format.nix b/modules/hooks/mix-format.nix index a7a6f2d3..43052058 100644 --- a/modules/hooks/mix-format.nix +++ b/modules/hooks/mix-format.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ config, tools, lib, ... }: { config = { name = "mix-format"; description = "Format Elixir files with mix format."; package = tools.elixir; - entry = "${tools.elixir}/bin/mix format"; + entry = "${config.package}/bin/mix format"; files = "\.exs?$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/mix-test.nix b/modules/hooks/mix-test.nix index 50bf4667..732b9327 100644 --- a/modules/hooks/mix-test.nix +++ b/modules/hooks/mix-test.nix @@ -1,11 +1,11 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "mix-test"; description = "Run Elixir tests with mix test."; package = tools.elixir; - entry = "${tools.elixir}/bin/mix test"; + entry = "${config.package}/bin/mix test"; files = "\.exs?$"; pass_filenames = false; }; -} \ No newline at end of file +} diff --git a/modules/hooks/mixed-line-endings.nix b/modules/hooks/mixed-line-endings.nix index 14a96d6d..4322d30d 100644 --- a/modules/hooks/mixed-line-endings.nix +++ b/modules/hooks/mixed-line-endings.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { - name = "mixed-line-ending"; - description = "Check for mixed line endings."; + name = "mixed-line-endings"; + description = "Resolve mixed line endings."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/mixed-line-ending"; + entry = "${config.package}/bin/mixed-line-ending"; types = [ "text" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/mkdocs-linkcheck.nix b/modules/hooks/mkdocs-linkcheck.nix index 6dc7ac66..9f473fb6 100644 --- a/modules/hooks/mkdocs-linkcheck.nix +++ b/modules/hooks/mkdocs-linkcheck.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, tools, migrateBinPathToPackage, mkCmdArgs, ... }: let inherit (lib) mkOption types; in @@ -10,7 +10,7 @@ in description = "mkdocs-linkcheck binary path. Should be used to specify the mkdocs-linkcheck binary from your Python environment."; default = null; defaultText = lib.literalExpression '' - "''${tools.mkdocs-linkcheck}/bin/mkdocs-linkcheck" + "''${config.package}/bin/mkdocs-linkcheck" ''; }; @@ -49,4 +49,26 @@ in default = "get"; }; }; + + config = { + name = "mkdocs-linkcheck"; + description = "Validate links associated with markdown-based, statically generated websites."; + package = tools.mkdocs-linkcheck; + entry = + let + binPath = migrateBinPathToPackage config "/bin/mkdocs-linkcheck"; + cmdArgs = + mkCmdArgs + (with config.settings; [ + [ local-only " --local" ] + [ recurse " --recurse" ] + [ (extension != "") " --ext ${extension}" ] + [ (method != "") " --method ${method}" ] + [ (path != "") " ${path}" ] + ]); + in + "${binPath}${cmdArgs}"; + types = [ "text" "markdown" ]; + }; + } diff --git a/modules/hooks/mypy.nix b/modules/hooks/mypy.nix index 189022b8..d3732469 100644 --- a/modules/hooks/mypy.nix +++ b/modules/hooks/mypy.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, ... }: let inherit (lib) mkOption types; in @@ -10,7 +10,7 @@ in description = "Mypy binary path. Should be used to specify the mypy executable in an environment containing your typing stubs."; default = null; defaultText = lib.literalExpression '' - "''${tools.mypy}/bin/mypy" + "''${config.package}/bin/mypy" ''; }; }; diff --git a/modules/hooks/name-tests-test.nix b/modules/hooks/name-tests-test.nix index 2c9f0f9c..1c38e7e8 100644 --- a/modules/hooks/name-tests-test.nix +++ b/modules/hooks/name-tests-test.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "name-tests-test"; - description = "Verify Python test files are named correctly."; + description = "Verify that Python test files are named correctly."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/name-tests-test"; - files = "(^|/)tests/.+\.py$"; + entry = "${config.package}/bin/tests_should_end_in_test.py"; + files = "(^|/)tests/\.+\\.py$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/nil.nix b/modules/hooks/nil.nix index cb91912f..79937430 100644 --- a/modules/hooks/nil.nix +++ b/modules/hooks/nil.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "nil"; description = "Incremental analysis assistant for writing in Nix."; package = tools.nil; - entry = "${tools.nil}/bin/nil"; + entry = "${config.package}/bin/nil"; files = "\.nix$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/nixpkgs-fmt.nix b/modules/hooks/nixpkgs-fmt.nix index 73266c15..5fa0be23 100644 --- a/modules/hooks/nixpkgs-fmt.nix +++ b/modules/hooks/nixpkgs-fmt.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "nixpkgs-fmt"; description = "Nix code formatter for nixpkgs."; package = tools.nixpkgs-fmt; - entry = "${tools.nixpkgs-fmt}/bin/nixpkgs-fmt"; + entry = "${config.package}/bin/nixpkgs-fmt"; files = "\.nix$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/ocp-indent.nix b/modules/hooks/ocp-indent.nix index ef6aef3a..8d644af4 100644 --- a/modules/hooks/ocp-indent.nix +++ b/modules/hooks/ocp-indent.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "ocp-indent"; - description = "A simple tool and library to indent OCaml code."; + description = "A tool to indent OCaml code."; package = tools.ocp-indent; - entry = "${tools.ocp-indent}/bin/ocp-indent --inplace"; + entry = "${config.package}/bin/ocp-indent --inplace"; files = "\.mli?$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/opam-lint.nix b/modules/hooks/opam-lint.nix index 244f366c..67982e9c 100644 --- a/modules/hooks/opam-lint.nix +++ b/modules/hooks/opam-lint.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "opam lint"; - description = "Lint opam package definition files."; + description = "OCaml package manager configuration checker"; package = tools.opam; - entry = "${tools.opam}/bin/opam lint"; + entry = "${config.package}/bin/opam lint"; files = "opam$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/openapi-spec-validator.nix b/modules/hooks/openapi-spec-validator.nix index 6115da55..3f97d5b6 100644 --- a/modules/hooks/openapi-spec-validator.nix +++ b/modules/hooks/openapi-spec-validator.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "openapi-spec-validator"; description = "Validate OpenAPI specifications."; package = tools.openapi-spec-validator; - entry = "${tools.openapi-spec-validator}/bin/openapi-spec-validator"; + entry = "${config.package}/bin/openapi-spec-validator"; files = "\.ya?ml$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/ormolu.nix b/modules/hooks/ormolu.nix index 45d2d716..2554ffed 100644 --- a/modules/hooks/ormolu.nix +++ b/modules/hooks/ormolu.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, tools, ... }: let inherit (lib) mkOption types; in @@ -17,4 +17,19 @@ in default = false; }; }; + + config = { + name = "ormolu"; + description = "Haskell code prettifier."; + package = tools.ormolu; + entry = + let + extensions = + lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) config.settings.defaultExtensions); + cabalExtensions = + if config.settings.cabalDefaultExtensions then "--cabal-default-extensions" else ""; + in + "${config.package}/bin/ormolu --mode inplace ${extensions} ${cabalExtensions}"; + files = "\\.l?hs(-boot)?$"; + }; } diff --git a/modules/hooks/php-cs-fixer.nix b/modules/hooks/php-cs-fixer.nix index bf639a12..60f4c42a 100644 --- a/modules/hooks/php-cs-fixer.nix +++ b/modules/hooks/php-cs-fixer.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, tools, migrateBinPathToPackage, ... }: let inherit (lib) mkOption types; in @@ -10,8 +10,20 @@ in description = "PHP-CS-Fixer binary path."; default = null; defaultText = lib.literalExpression '' - "''${tools.php-cs-fixer}/bin/php-cs-fixer" + "''${config.package}/bin/php-cs-fixer" ''; }; }; + + config = { + name = "php-cs-fixer"; + description = "Lint PHP files."; + package = tools.php-cs-fixer; + entry = + let + binPath = migrateBinPathToPackage config "/bin/php-cs-fixer"; + in + "${binPath} fix"; + types = [ "php" ]; + }; } diff --git a/modules/hooks/phpcbf.nix b/modules/hooks/phpcbf.nix index a24475da..25b96a64 100644 --- a/modules/hooks/phpcbf.nix +++ b/modules/hooks/phpcbf.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, ... }: let inherit (lib) mkOption types; in @@ -10,7 +10,7 @@ in description = "PHP_CodeSniffer binary path."; default = null; defaultText = lib.literalExpression '' - "''${tools.phpcbf}/bin/phpcbf" + "''${config.package}/bin/phpcbf" ''; }; }; diff --git a/modules/hooks/phpcs.nix b/modules/hooks/phpcs.nix index 528c40fe..0c7cd766 100644 --- a/modules/hooks/phpcs.nix +++ b/modules/hooks/phpcs.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, tools, migrateBinPathToPackage, ... }: let inherit (lib) mkOption types; in @@ -10,8 +10,16 @@ in description = "PHP_CodeSniffer binary path."; default = null; defaultText = lib.literalExpression '' - "''${tools.phpcs}/bin/phpcs" + "''${config.package}/bin/phpcs" ''; }; }; + + config = { + name = "phpcs"; + description = "Lint PHP files."; + package = tools.phpcs; + entry = migrateBinPathToPackage config "/bin/phpcs"; + types = [ "php" ]; + }; } diff --git a/modules/hooks/phpstan.nix b/modules/hooks/phpstan.nix index 69fb8302..8d785c9b 100644 --- a/modules/hooks/phpstan.nix +++ b/modules/hooks/phpstan.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, tools, migrateBinPathToPackage, ... }: let inherit (lib) mkOption types; in @@ -10,8 +10,20 @@ in description = "PHPStan binary path."; default = null; defaultText = lib.literalExpression '' - "''${tools.phpstan}/bin/phpstan" + "''${config.package}/bin/phpstan" ''; }; }; + + config = { + name = "phpstan"; + description = "Static Analysis of PHP files."; + package = tools.phpstan; + entry = + let + binPath = migrateBinPathToPackage config "/bin/phpstan"; + in + "${binPath} analyse"; + types = [ "php" ]; + }; } diff --git a/modules/hooks/poetry-check.nix b/modules/hooks/poetry-check.nix index 153bd9a7..6274bb97 100644 --- a/modules/hooks/poetry-check.nix +++ b/modules/hooks/poetry-check.nix @@ -1,11 +1,11 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { - name = "poetry-check"; + name = "poetry check"; description = "Check the validity of the pyproject.toml file."; package = tools.poetry; - entry = "${tools.poetry}/bin/poetry check"; - files = "pyproject\.toml$"; + entry = "${config.package}/bin/poetry check"; + files = "^(poetry\\.lock$|pyproject\\.toml)$"; pass_filenames = false; }; -} \ No newline at end of file +} diff --git a/modules/hooks/poetry-lock.nix b/modules/hooks/poetry-lock.nix index 8718b45f..3b84a0b1 100644 --- a/modules/hooks/poetry-lock.nix +++ b/modules/hooks/poetry-lock.nix @@ -1,11 +1,11 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { - name = "poetry-lock"; - description = "Update the poetry.lock file."; + name = "poetry lock"; + description = "Update the poetry.lock file"; package = tools.poetry; - entry = "${tools.poetry}/bin/poetry lock"; - files = "pyproject\.toml$"; + entry = "${config.package}/bin/poetry lock"; + files = "^(poetry\\.lock$|pyproject\\.toml)$"; pass_filenames = false; }; -} \ No newline at end of file +} diff --git a/modules/hooks/pre-commit-hook-ensure-sops.nix b/modules/hooks/pre-commit-hook-ensure-sops.nix index 894ef33c..99cdc6e3 100644 --- a/modules/hooks/pre-commit-hook-ensure-sops.nix +++ b/modules/hooks/pre-commit-hook-ensure-sops.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "pre-commit-hook-ensure-sops"; description = "Ensure that sops files are encrypted."; package = tools.pre-commit-hook-ensure-sops; - entry = "${tools.pre-commit-hook-ensure-sops}/bin/pre-commit-hook-ensure-sops"; - files = "\.sops\.(ya?ml|json)$"; + entry = "${config.package}/bin/pre-commit-hook-ensure-sops"; + files = "^secrets"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/prettier.nix b/modules/hooks/prettier.nix index eb7cf893..916d78f7 100644 --- a/modules/hooks/prettier.nix +++ b/modules/hooks/prettier.nix @@ -1,8 +1,10 @@ -{ lib, ... }: +{ lib, config, tools, migrateBinPathToPackage, mkCmdArgs, ... }: let inherit (lib) mkOption types; in { + # See all CLI flags for prettier [here](https://prettier.io/docs/en/cli.html). + # See all options for prettier [here](https://prettier.io/docs/en/options.html). options.settings = { binPath = mkOption { @@ -14,7 +16,7 @@ in type = types.nullOr (types.oneOf [ types.str types.path ]); default = null; defaultText = lib.literalExpression '' - "''${tools.prettier}/bin/prettier" + "''${config.package}/bin/prettier" ''; example = lib.literalExpression '' "./node_modules/.bin/prettier" @@ -246,4 +248,57 @@ in default = true; }; }; + + config = { + name = "prettier"; + description = "Opinionated multi-language code formatter."; + types = [ "text" ]; + package = tools.prettier; + entry = + let + binPath = migrateBinPathToPackage config "/bin/prettier"; + cmdArgs = + mkCmdArgs + (with config.settings; [ + [ (allow-parens != "always") "--allow-parens ${allow-parens}" ] + [ bracket-same-line "--bracket-same-line" ] + [ cache "--cache" ] + [ (cache-location != "./node_modules/.cache/prettier/.prettier-cache") "--cache-location ${cache-location}" ] + [ (cache-strategy != null) "--cache-strategy ${cache-strategy}" ] + [ check "--check" ] + [ (!color) "--no-color" ] + [ (configPath != "") "--config ${configPath}" ] + [ (config-precedence != "cli-override") "--config-precedence ${config-precedence}" ] + [ (embedded-language-formatting != "auto") "--embedded-language-formatting ${embedded-language-formatting}" ] + [ (end-of-line != "lf") "--end-of-line ${end-of-line}" ] + [ (html-whitespace-sensitivity != "css") "--html-whitespace-sensitivity ${html-whitespace-sensitivity}" ] + [ (ignore-path != [ ]) "--ignore-path ${lib.escapeShellArgs ignore-path}" ] + [ ignore-unknown "--ignore-unknown" ] + [ insert-pragma "--insert-pragma" ] + [ jsx-single-quote "--jsx-single-quote" ] + [ list-different "--list-different" ] + [ (log-level != "log") "--log-level ${log-level}" ] + [ no-bracket-spacing "--no-bracket-spacing" ] + [ no-config "--no-config" ] + [ no-editorconfig "--no-editorconfig" ] + [ no-error-on-unmatched-pattern "--no-error-on-unmatched-pattern" ] + [ no-semi "--no-semi" ] + [ (parser != "") "--parser ${parser}" ] + [ (print-width != 80) "--print-width ${toString print-width}" ] + [ (prose-wrap != "preserve") "--prose-wrap ${prose-wrap}" ] + [ (plugins != [ ]) "--plugin ${lib.strings.concatStringsSep " --plugin " plugins}" ] + [ (quote-props != "as-needed") "--quote-props ${quote-props}" ] + [ require-pragma "--require-pragma" ] + [ single-attribute-per-line "--single-attribute-per-line" ] + [ single-quote "--single-quote" ] + [ (tab-width != 2) "--tab-width ${toString tab-width}" ] + [ (trailing-comma != "all") "--trailing-comma ${trailing-comma}" ] + [ use-tabs "--use-tabs" ] + [ vue-indent-script-and-style "--vue-indent-script-and-style" ] + [ with-node-modules "--with-node-modules" ] + [ write "--write" ] + ]); + in + "${binPath} ${cmdArgs}"; + }; } diff --git a/modules/hooks/pretty-format-json.nix b/modules/hooks/pretty-format-json.nix index 21450200..8d9db0a5 100644 --- a/modules/hooks/pretty-format-json.nix +++ b/modules/hooks/pretty-format-json.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, tools, mkCmdArgs, ... }: let inherit (lib) mkOption types; in @@ -35,4 +35,23 @@ in default = [ ]; }; }; + + config = { + name = "pretty-format-json"; + description = "Pretty format JSON."; + package = tools.pre-commit-hooks; + entry = + let + binPath = "${config.package}/bin/pretty-format-json"; + cmdArgs = mkCmdArgs (with config.settings; [ + [ autofix "--autofix" ] + [ (indent != null) "--indent ${toString indent}" ] + [ no-ensure-ascii "--no-ensure-ascii" ] + [ no-sort-keys "--no-sort-keys" ] + [ (top-keys != [ ]) "--top-keys ${lib.strings.concatStringsSep "," top-keys}" ] + ]); + in + "${binPath} ${cmdArgs}"; + types = [ "json" ]; + }; } diff --git a/modules/hooks/proselint.nix b/modules/hooks/proselint.nix index ebf13bde..5d1c86bc 100644 --- a/modules/hooks/proselint.nix +++ b/modules/hooks/proselint.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, tools, mkCmdArgs, ... }: let inherit (lib) mkOption types; in @@ -30,4 +30,22 @@ in default = ""; }; }; + + config = { + name = "proselint"; + description = "A linter for prose."; + types = [ "text" ]; + package = tools.proselint; + entry = + let + configFile = builtins.toFile "proselint-config.json" "${config.settings.config}"; + cmdArgs = + mkCmdArgs + (with config.settings; [ + [ (configPath != "") " --config ${configPath}" ] + [ (config != "" && configPath == "") " --config ${configFile}" ] + ]); + in + "${config.package}/bin/proselint${cmdArgs} ${config.settings.flags}"; + }; } diff --git a/modules/hooks/psalm.nix b/modules/hooks/psalm.nix index 5ff49bd0..50e94436 100644 --- a/modules/hooks/psalm.nix +++ b/modules/hooks/psalm.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, tools, migrateBinPathToPackage, ... }: let inherit (lib) mkOption types; in @@ -10,8 +10,16 @@ in description = "Psalm binary path."; default = null; defaultText = lib.literalExpression '' - "''${tools.psalm}/bin/psalm" + "''${config.package}/bin/psalm" ''; }; }; + + config = { + name = "psalm"; + description = "Static Analysis of PHP files."; + package = tools.psalm; + entry = migrateBinPathToPackage config "/bin/psalm"; + types = [ "php" ]; + }; } diff --git a/modules/hooks/purs-tidy.nix b/modules/hooks/purs-tidy.nix index 0a685382..ea0dc00e 100644 --- a/modules/hooks/purs-tidy.nix +++ b/modules/hooks/purs-tidy.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "purs-tidy"; - description = "Format PureScript files with purs-tidy."; + description = "Format purescript files."; package = tools.purs-tidy; - entry = "${tools.purs-tidy}/bin/purs-tidy format-in-place"; + entry = "${config.package}/bin/purs-tidy format-in-place"; files = "\.purs$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/purty.nix b/modules/hooks/purty.nix new file mode 100644 index 00000000..468861e7 --- /dev/null +++ b/modules/hooks/purty.nix @@ -0,0 +1,10 @@ +{ tools, config, lib, ... }: +{ + config = { + name = "purty"; + description = "Format purescript files."; + package = tools.purty; + entry = "${config.package}/bin/purty"; + files = "\\.purs$"; + }; +} diff --git a/modules/hooks/pylint.nix b/modules/hooks/pylint.nix index 3328cd10..407db15b 100644 --- a/modules/hooks/pylint.nix +++ b/modules/hooks/pylint.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, tools, migrateBinPathToPackage, mkCmdArgs, ... }: let inherit (lib) mkOption types; in @@ -10,7 +10,7 @@ in description = "Pylint binary path. Should be used to specify Pylint binary from your Python environment."; default = null; defaultText = lib.literalExpression '' - "''${tools.pylint}/bin/pylint" + "''${config.package}/bin/pylint" ''; }; reports = @@ -26,4 +26,22 @@ in default = true; }; }; + + config = { + name = "pylint"; + description = "Lint Python files."; + package = tools.pylint; + entry = + let + binPath = migrateBinPathToPackage config "/bin/pylint"; + cmdArgs = + mkCmdArgs + (with config.settings; [ + [ reports "-ry" ] + [ (! score) "-sn" ] + ]); + in + "${binPath} ${cmdArgs}"; + types = [ "python" ]; + }; } diff --git a/modules/hooks/pyright.nix b/modules/hooks/pyright.nix index 2cf3cdd3..e235c16c 100644 --- a/modules/hooks/pyright.nix +++ b/modules/hooks/pyright.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, tools, migrateBinPathToPackage, ... }: let inherit (lib) mkOption types; in @@ -10,8 +10,16 @@ in description = "Pyright binary path. Should be used to specify the pyright executable in an environment containing your typing stubs."; default = null; defaultText = lib.literalExpression '' - "''${tools.pyright}/bin/pyright" + "''${config.package}/bin/pyright" ''; }; }; + + config = { + name = "pyright"; + description = "Static type checker for Python"; + package = tools.pyright; + entry = migrateBinPathToPackage config "/bin/pyright"; + files = "\\.py$"; + }; } diff --git a/modules/hooks/python-debug-statements.nix b/modules/hooks/python-debug-statements.nix index 188ea3cf..26155ea3 100644 --- a/modules/hooks/python-debug-statements.nix +++ b/modules/hooks/python-debug-statements.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "debug-statements"; description = "Check for debugger imports and py37+ `breakpoint()` calls in python source."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/debug-statement-hook"; + entry = "${config.package}/bin/debug-statement-hook"; types = [ "python" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/pyupgrade.nix b/modules/hooks/pyupgrade.nix index 699635f2..f76d1fa0 100644 --- a/modules/hooks/pyupgrade.nix +++ b/modules/hooks/pyupgrade.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, tools, migrateBinPathToPackage, ... }: let inherit (lib) mkOption types; in @@ -10,8 +10,16 @@ in description = "pyupgrade binary path. Should be used to specify the pyupgrade binary from your Python environment."; default = null; defaultText = lib.literalExpression '' - "''${tools.pyupgrade}/bin/pyupgrade" + "''${config.package}/bin/pyupgrade" ''; }; }; + + config = { + name = "pyupgrade"; + description = "Upgrade syntax for newer versions of Python."; + package = tools.pyupgrade; + entry = migrateBinPathToPackage config "/bin/pyupgrade"; + types = [ "python" ]; + }; } diff --git a/modules/hooks/reuse.nix b/modules/hooks/reuse.nix index 6e3e007b..8c292594 100644 --- a/modules/hooks/reuse.nix +++ b/modules/hooks/reuse.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, tools, ... }: let inherit (lib) mkOption types; in @@ -11,4 +11,13 @@ in example = "--json"; }; }; + + config = { + name = "reuse"; + description = "reuse is a tool for compliance with the REUSE recommendations."; + package = tools.reuse; + entry = "${config.package}/bin/reuse lint ${config.settings.flags}"; + types = [ "file" ]; + pass_filenames = false; + }; } diff --git a/modules/hooks/revive.nix b/modules/hooks/revive.nix index 812c9097..ef51998c 100644 --- a/modules/hooks/revive.nix +++ b/modules/hooks/revive.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, pkgs, tools, mkCmdArgs, ... }: let inherit (lib) mkOption types; in @@ -13,4 +13,33 @@ in default = ""; }; }; + + config = { + name = "revive"; + description = "A linter for Go source code."; + package = tools.revive; + entry = + let + cmdArgs = + mkCmdArgs [ + [ true "-set_exit_status" ] + [ (config.settings.configPath != "") "-config ${config.settings.configPath}" ] + ]; + # revive works with both files and directories; however some lints + # may fail (e.g. package-comment) if they run on an individual file + # rather than a package/directory scope; given this let's get the + # directories from each individual file. + script = pkgs.writeShellScript "precommit-revive" '' + set -e + for dir in $(echo "$@" | xargs -n1 dirname | sort -u); do + ${config.package}/bin/revive ${cmdArgs} ./"$dir" + done + ''; + in + builtins.toString script; + files = "\\.go$"; + # to avoid multiple invocations of the same directory input, provide + # all file names in a single run. + require_serial = true; + }; } diff --git a/modules/hooks/ripsecrets.nix b/modules/hooks/ripsecrets.nix index 19a8712a..8d57179c 100644 --- a/modules/hooks/ripsecrets.nix +++ b/modules/hooks/ripsecrets.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, tools, mkCmdArgs, ... }: let inherit (lib) mkOption types; in @@ -11,4 +11,24 @@ in default = [ ]; }; }; + + config = { + name = "ripsecrets"; + description = "Prevent committing secret keys into your source code"; + package = tools.ripsecrets; + entry = + let + cmdArgs = mkCmdArgs ( + with config.settings; [ + [ true "--strict-ignore" ] + [ + (additionalPatterns != [ ]) + "--additional-pattern ${lib.strings.concatStringsSep " --additional-pattern " additionalPatterns}" + ] + ] + ); + in + "${config.package}/bin/ripsecrets ${cmdArgs}"; + types = [ "text" ]; + }; } diff --git a/modules/hooks/rome.nix b/modules/hooks/rome.nix index f752a1be..ce2994d1 100644 --- a/modules/hooks/rome.nix +++ b/modules/hooks/rome.nix @@ -14,7 +14,7 @@ in ''; default = null; defaultText = lib.literalExpression '' - "''${tools.rome}/bin/rome" + "''${config.package}/bin/rome" ''; example = lib.literalExpression '' "./node_modules/.bin/rome" diff --git a/modules/hooks/ruff-format.nix b/modules/hooks/ruff-format.nix index b3907bcf..e5ddc593 100644 --- a/modules/hooks/ruff-format.nix +++ b/modules/hooks/ruff-format.nix @@ -1,11 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "ruff-format"; - description = "An extremely fast Python formatter, written in Rust."; + description = "An extremely fast Python code formatter, written in Rust."; package = tools.ruff; - entry = "${tools.ruff}/bin/ruff format"; + entry = "${config.package}/bin/ruff format"; types = [ "python" ]; - require_serial = true; }; -} \ No newline at end of file +} diff --git a/modules/hooks/ruff.nix b/modules/hooks/ruff.nix index ef0c0476..9f3d34ba 100644 --- a/modules/hooks/ruff.nix +++ b/modules/hooks/ruff.nix @@ -1,11 +1,11 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "ruff"; description = "An extremely fast Python linter, written in Rust."; package = tools.ruff; - entry = "${tools.ruff}/bin/ruff check --fix"; + entry = "${config.package}/bin/ruff check --fix"; types = [ "python" ]; require_serial = true; }; -} \ No newline at end of file +} diff --git a/modules/hooks/rustfmt.nix b/modules/hooks/rustfmt.nix index a67661e4..4f4c36bf 100644 --- a/modules/hooks/rustfmt.nix +++ b/modules/hooks/rustfmt.nix @@ -1,4 +1,4 @@ -{ lib, config, settings, ... }: +{ lib, config, settings, pkgs, tools, ... }: let inherit (lib) mkOption types; nameType = types.strMatching "[][*?!0-9A-Za-z_-]+"; @@ -82,32 +82,40 @@ in }; }; - config = { - name = "rustfmt"; - description = "Format Rust code."; - package = config.packageOverrides.rustfmt; - entry = - let - cmdArgs = - lib.mkCmdArgs (with config.settings; [ - [ (all) "--all" ] - [ (check) "--check" ] - [ (color != "auto") "--color ${color}" ] - [ (config != { }) config ] - [ (config-path != null) "--config-path ${lib.escapeShellArg config-path}" ] - [ (emit != "files") "--emit ${emit}" ] - [ (files-with-diff) "--files-with-diff" ] - [ (manifest-path != null) "--manifest-path ${lib.escapeShellArg manifest-path}" ] - [ (message-format != null) "--message-format ${message-format}" ] - [ (package != [ ]) "--package ${lib.strings.concatStringsSep " --package " package}" ] - [ verbose "-v" ] - ]); - in - "${config.packageOverrides.rustfmt}/bin/rustfmt ${cmdArgs}"; - files = "\\.rs$"; - extraPackages = [ - config.packageOverrides.cargo - config.packageOverrides.rustfmt - ]; - }; + config = + let + mkAdditionalArgs = args: lib.optionalString (args != "") " -- ${args}"; + + wrapper = pkgs.symlinkJoin { + name = "rustfmt-wrapped"; + paths = [ config.packageOverrides.rustfmt ]; + nativeBuildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/cargo-fmt \ + --prefix PATH : ${lib.makeBinPath (builtins.attrValues config.packageOverrides)} + ''; + }; + in + { + name = "rustfmt"; + description = "Format Rust code."; + package = wrapper; + packageOverrides = { inherit (tools) cargo rustfmt; }; + entry = + let + cargoArgs = lib.cli.toGNUCommandLineShell { } { + inherit (config.settings) all package verbose manifest-path; + }; + rustfmtArgs = lib.cli.toGNUCommandLineShell { } { + inherit (config.settings) check emit config-path color files-with-diff config verbose; + }; + in + "${config.package}/bin/cargo-fmt fmt ${cargoArgs}${mkAdditionalArgs rustfmtArgs}"; + files = "\\.rs$"; + pass_filenames = false; + extraPackages = [ + config.packageOverrides.cargo + config.packageOverrides.rustfmt + ]; + }; } diff --git a/modules/hooks/selene.nix b/modules/hooks/selene.nix index 2103633e..5776bd68 100644 --- a/modules/hooks/selene.nix +++ b/modules/hooks/selene.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "selene"; - description = "A blazing-fast modern Lua linter."; + description = "A blazing-fast modern Lua linter written in Rust."; package = tools.selene; - entry = "${tools.selene}/bin/selene"; + entry = "${config.package}/bin/selene"; types = [ "lua" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/shellcheck.nix b/modules/hooks/shellcheck.nix index 7951e8f4..1ca69824 100644 --- a/modules/hooks/shellcheck.nix +++ b/modules/hooks/shellcheck.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "shellcheck"; - description = "ShellCheck is a static analysis tool for shell scripts."; + description = "Format shell files"; package = tools.shellcheck; - entry = "${tools.shellcheck}/bin/shellcheck"; + entry = "${config.package}/bin/shellcheck"; types = [ "shell" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/shfmt.nix b/modules/hooks/shfmt.nix index 709eaa1e..b0f11368 100644 --- a/modules/hooks/shfmt.nix +++ b/modules/hooks/shfmt.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, tools, ... }: let inherit (lib) mkOption types; in @@ -10,4 +10,16 @@ in default = true; }; }; + + config = { + name = "shfmt"; + description = "Format shell files."; + types = [ "shell" ]; + package = tools.shfmt; + entry = + let + simplify = if config.settings.simplify then "-s" else ""; + in + "${config.package}/bin/shfmt -w -l ${simplify}"; + }; } diff --git a/modules/hooks/single-quoted-strings.nix b/modules/hooks/single-quoted-strings.nix index e838e7b1..06a33a70 100644 --- a/modules/hooks/single-quoted-strings.nix +++ b/modules/hooks/single-quoted-strings.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "single-quoted-strings"; description = "Replace double quoted strings with single quoted strings."; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/single-quoted-strings"; + entry = "${config.package}/bin/double-quote-string-fixer"; types = [ "python" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/sort-file-contents.nix b/modules/hooks/sort-file-contents.nix index 03350464..1158e4ba 100644 --- a/modules/hooks/sort-file-contents.nix +++ b/modules/hooks/sort-file-contents.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, tools, mkCmdArgs, ... }: let inherit (lib) mkOption types; in @@ -17,4 +17,22 @@ in default = false; }; }; + + config = { + name = "sort-file-contents"; + description = "Sort the lines in specified files (defaults to alphabetical)."; + types = [ "text" ]; + package = tools.pre-commit-hooks; + entry = + let + cmdArgs = + mkCmdArgs + (with config.settings; + [ + [ ignore-case "--ignore-case" ] + [ unique "--unique" ] + ]); + in + "${config.package}/bin/file-contents-sorter ${cmdArgs}"; + }; } diff --git a/modules/hooks/sort-requirements-txt.nix b/modules/hooks/sort-requirements-txt.nix index 0c26d6c7..7878900f 100644 --- a/modules/hooks/sort-requirements-txt.nix +++ b/modules/hooks/sort-requirements-txt.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "sort-requirements-txt"; - description = "Sort the lines in specified files (defaults to alphabetical)."; + description = "Sort requirements in requirements.txt and constraints.txt files"; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/requirements-txt-fixer"; - files = "requirements.*\.txt$"; + entry = "${config.package}/bin/requirements-txt-fixer"; + files = "\\.*(requirements|constraints)\\.*\\.txt$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/sort-simple-yaml.nix b/modules/hooks/sort-simple-yaml.nix index ce73e0d6..78f64d29 100644 --- a/modules/hooks/sort-simple-yaml.nix +++ b/modules/hooks/sort-simple-yaml.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "sort-simple-yaml"; - description = "Sort simple YAML files."; + description = "Sort simple YAML files which consist only of top-level keys, preserving comments and blocks"; package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/sort-simple-yaml"; - files = "\.ya?ml$"; + entry = "${config.package}/bin/sort-simple-yaml"; + files = "(\\.yaml$)|(\\.yml$)"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/staticcheck.nix b/modules/hooks/staticcheck.nix index 758f0bc2..7e1ce6b0 100644 --- a/modules/hooks/staticcheck.nix +++ b/modules/hooks/staticcheck.nix @@ -1,11 +1,28 @@ -{ tools, lib, ... }: +{ tools, lib, config, pkgs, ... }: { config = { name = "staticcheck"; - description = "A state of the art linter for the Go programming language."; + description = "State of the art linter for the Go programming language"; package = tools.go-tools; - entry = "${tools.go-tools}/bin/staticcheck"; - types = [ "go" ]; + # staticheck works with directories. + entry = + let + script = pkgs.writeShellScript "precommit-staticcheck" '' + err=0 + for dir in $(echo "$@" | xargs -n1 dirname | sort -u); do + ${config.package}/bin/staticcheck ./"$dir" + code="$?" + if [[ "$err" -eq 0 ]]; then + err="$code" + fi + done + exit $err + ''; + in + builtins.toString script; + files = "\\.go$"; + # to avoid multiple invocations of the same directory input, provide + # all file names in a single run. require_serial = true; }; -} \ No newline at end of file +} diff --git a/modules/hooks/statix.nix b/modules/hooks/statix.nix index 172d4752..f7b4030e 100644 --- a/modules/hooks/statix.nix +++ b/modules/hooks/statix.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, tools, config, ... }: let inherit (lib) mkOption types; in @@ -34,4 +34,28 @@ in example = true; }; }; + + config = { + name = "statix"; + description = "Lints and suggestions for the Nix programming language."; + package = tools.statix; + entry = + let + inherit (config) package settings; + mkOptionName = k: + if builtins.stringLength k == 1 + then "-${k}" + else "--${k}"; + options = lib.cli.toGNUCommandLineShell + { + # instead of repeating the option name for each element, + # create a single option with a space-separated list of unique values. + mkList = k: v: if v == [ ] then [ ] else [ (mkOptionName k) ] ++ lib.unique v; + } + settings; + in + "${package}/bin/statix check ${options}"; + files = "\\.nix$"; + pass_filenames = false; + }; } diff --git a/modules/hooks/stylish-haskell.nix b/modules/hooks/stylish-haskell.nix index 2cb7c69d..e6b0e978 100644 --- a/modules/hooks/stylish-haskell.nix +++ b/modules/hooks/stylish-haskell.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "stylish-haskell"; description = "A simple Haskell code prettifier."; package = tools.stylish-haskell; - entry = "${tools.stylish-haskell}/bin/stylish-haskell --inplace"; - files = "\.l?hs$"; + entry = "${config.package}/bin/stylish-haskell --inplace"; + files = "\\.l?hs(-boot)?$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/stylua.nix b/modules/hooks/stylua.nix index 6c9be792..0871d43a 100644 --- a/modules/hooks/stylua.nix +++ b/modules/hooks/stylua.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "stylua"; description = "An opinionated code formatter for Lua."; package = tools.stylua; - entry = "${tools.stylua}/bin/stylua"; - types = [ "lua" ]; + entry = "${config.package}/bin/stylua --respect-ignores"; + types = [ "file" "lua" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/tagref.nix b/modules/hooks/tagref.nix index 03f736e4..625f75fd 100644 --- a/modules/hooks/tagref.nix +++ b/modules/hooks/tagref.nix @@ -1,11 +1,11 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "tagref"; description = "Have tagref check all references and tags."; package = tools.tagref; - entry = "${tools.tagref}/bin/tagref"; + entry = "${config.package}/bin/tagref"; types = [ "text" ]; pass_filenames = false; }; -} \ No newline at end of file +} diff --git a/modules/hooks/taplo.nix b/modules/hooks/taplo.nix index a9084f3b..be579a37 100644 --- a/modules/hooks/taplo.nix +++ b/modules/hooks/taplo.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "taplo"; description = "Format TOML files with taplo fmt."; package = tools.taplo; - entry = "${tools.taplo}/bin/taplo format"; + entry = "${config.package}/bin/taplo fmt"; types = [ "toml" ]; }; -} \ No newline at end of file +} diff --git a/modules/hooks/terraform-format.nix b/modules/hooks/terraform-format.nix index 46364e77..53bc7238 100644 --- a/modules/hooks/terraform-format.nix +++ b/modules/hooks/terraform-format.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "terraform-format"; - description = "Format terraform files."; - package = tools.terraform; - entry = "${tools.terraform}/bin/terraform fmt"; - files = "\.tf$"; + description = "Format Terraform (`.tf`) files."; + package = tools.opentofu; + entry = "${lib.getExe config.package} fmt -check -diff"; + files = "\\.tf$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/terraform-validate.nix b/modules/hooks/terraform-validate.nix index 3058d4ec..08709d57 100644 --- a/modules/hooks/terraform-validate.nix +++ b/modules/hooks/terraform-validate.nix @@ -1,10 +1,12 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "terraform-validate"; - description = "Validate terraform files."; + description = "Validates terraform configuration files (`.tf`)."; package = tools.terraform-validate; - entry = "${tools.terraform-validate}/bin/terraform-validate"; - files = "\.tf$"; + entry = "${config.package}/bin/terraform-validate"; + files = "\\.(tf(vars)?|terraform\\.lock\\.hcl)$"; + excludes = [ "\\.terraform/.*$" ]; + require_serial = true; }; -} \ No newline at end of file +} diff --git a/modules/hooks/tflint.nix b/modules/hooks/tflint.nix index 9beada60..d27c203f 100644 --- a/modules/hooks/tflint.nix +++ b/modules/hooks/tflint.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "tflint"; - description = "A Pluggable Terraform Linter."; + description = "A pluggable Terraform linter."; package = tools.tflint; - entry = "${tools.tflint}/bin/tflint"; - files = "\.tf$"; + entry = "${config.package}/bin/tflint"; + files = "\\.tf$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/topiary.nix b/modules/hooks/topiary.nix index 0d7df05b..cedc3800 100644 --- a/modules/hooks/topiary.nix +++ b/modules/hooks/topiary.nix @@ -1,10 +1,21 @@ -{ tools, lib, ... }: +{ tools, lib, config, pkgs, ... }: { config = { name = "topiary"; - description = "A universal formatter engine."; + description = "A universal formatter engine within the Tree-sitter ecosystem, with support for many languages."; package = tools.topiary; - entry = "${tools.topiary}/bin/topiary format"; - pass_filenames = false; + entry = + let + topiary-inplace = pkgs.writeShellApplication { + name = "topiary-inplace"; + text = '' + for file; do + ${config.package}/bin/topiary --in-place --input-file "$file" + done + ''; + }; + in + "${topiary-inplace}/bin/topiary-inplace"; + files = "(\\.json$)|(\\.toml$)|(\\.mli?$)"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/treefmt.nix b/modules/hooks/treefmt.nix index 9de595ee..f52af423 100644 --- a/modules/hooks/treefmt.nix +++ b/modules/hooks/treefmt.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, lib, pkgs, tools, mkCmdArgs, ... }: let inherit (lib) mkOption types; in @@ -30,5 +30,39 @@ in }; }; - config.extraPackages = config.settings.formatters; + config = + let + inherit (config) packageOverrides settings; + wrapper = + pkgs.writeShellApplication { + name = "treefmt"; + runtimeInputs = [ + packageOverrides.treefmt + ] ++ settings.formatters; + + text = + '' + exec treefmt "$@" + ''; + }; + in + { + name = "treefmt"; + description = "One CLI to format the code tree."; + types = [ "file" ]; + pass_filenames = true; + package = wrapper; + packageOverrides = { inherit (tools) treefmt; }; + entry = + let + cmdArgs = + mkCmdArgs + (with config.settings; [ + [ fail-on-change "--fail-on-change" ] + [ no-cache "--no-cache" ] + ]); + in + "${config.package}/bin/treefmt ${cmdArgs}"; + extraPackages = config.settings.formatters; + }; } diff --git a/modules/hooks/trim-trailing-whitespace.nix b/modules/hooks/trim-trailing-whitespace.nix index 590b705d..d0302815 100644 --- a/modules/hooks/trim-trailing-whitespace.nix +++ b/modules/hooks/trim-trailing-whitespace.nix @@ -1,10 +1,11 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "trailing-whitespace"; description = "Trim trailing whitespace."; - package = tools.pre-commit-hooks; - entry = "${tools.pre-commit-hooks}/bin/trailing-whitespace-fixer"; types = [ "text" ]; + stages = [ "pre-commit" "pre-push" "manual" ]; + package = tools.pre-commit-hooks; + entry = "${config.package}/bin/trailing-whitespace-fixer"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/trufflehog.nix b/modules/hooks/trufflehog.nix index b0f662ae..88afa5d0 100644 --- a/modules/hooks/trufflehog.nix +++ b/modules/hooks/trufflehog.nix @@ -1,16 +1,18 @@ -{ tools, lib, pkgs, ... }: +{ tools, lib, pkgs, config, ... }: { config = { name = "trufflehog"; - description = "Detect secrets in your data."; + description = "Secrets scanner."; package = tools.trufflehog; entry = let script = pkgs.writeShellScript "precommit-trufflehog" '' - trufflehog git file://$(git rev-parse --show-toplevel) --since-commit HEAD --only-verified --fail + set -e + ${config.package}/bin/trufflehog --no-update git "file://$(git rev-parse --show-toplevel)" --since-commit HEAD --only-verified --fail ''; in - "${tools.trufflehog}/bin/trufflehog git file://$(git rev-parse --show-toplevel) --since-commit HEAD --only-verified --fail"; - types = [ "text" ]; + builtins.toString script; + # trufflehog expects to run across the whole repo, not particular files + pass_filenames = false; }; -} \ No newline at end of file +} diff --git a/modules/hooks/typos.nix b/modules/hooks/typos.nix index 9d73f5ab..1915321c 100644 --- a/modules/hooks/typos.nix +++ b/modules/hooks/typos.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, tools, config, mkCmdArgs, ... }: let inherit (lib) mkOption types; in @@ -130,4 +130,37 @@ in default = false; }; }; + + config = { + name = "typos"; + description = "Source code spell checker"; + package = tools.typos; + entry = + let + # Concatenate config in config file with section for ignoring words generated from list of words to ignore + configuration = "${config.settings.configuration}" + lib.strings.optionalString (config.settings.ignored-words != [ ]) "\n\[default.extend-words\]" + lib.strings.concatMapStrings (x: "\n${x} = \"${x}\"") config.settings.ignored-words; + configFile = builtins.toFile "typos-config.toml" configuration; + cmdArgs = + mkCmdArgs + (with config.settings; [ + [ binary "--binary" ] + [ (color != "auto") "--color ${color}" ] + [ (configuration != "") "--config ${configFile}" ] + [ (configPath != "" && configuration == "") "--config ${configPath}" ] + [ diff "--diff" ] + [ (exclude != "") "--exclude ${exclude} --force-exclude" ] + [ (format != "long") "--format ${format}" ] + [ hidden "--hidden" ] + [ (locale != "en") "--locale ${locale}" ] + [ no-check-filenames "--no-check-filenames" ] + [ no-check-files "--no-check-files" ] + [ no-unicode "--no-unicode" ] + [ quiet "--quiet" ] + [ verbose "--verbose" ] + [ (write && !diff) "--write-changes" ] + ]); + in + "${config.package}/bin/typos ${cmdArgs}"; + types = [ "text" ]; + }; } diff --git a/modules/hooks/typstfmt.nix b/modules/hooks/typstfmt.nix index ef8e3798..f46441d1 100644 --- a/modules/hooks/typstfmt.nix +++ b/modules/hooks/typstfmt.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "typstfmt"; description = "Format Typst files."; package = tools.typstfmt; - entry = "${tools.typstfmt}/bin/typstfmt"; - files = "\.typ$"; + entry = "${config.package}/bin/typstfmt"; + files = "\\.typ$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/typstyle.nix b/modules/hooks/typstyle.nix index dcd14919..28016654 100644 --- a/modules/hooks/typstyle.nix +++ b/modules/hooks/typstyle.nix @@ -1,10 +1,14 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "typstyle"; - description = "Format Typst files with typstyle."; + description = "Beautiful and reliable typst code formatter."; package = tools.typstyle; - entry = "${tools.typstyle}/bin/typstyle"; - files = "\.typ$"; + entry = + lib.throwIf + (config.package == null) + "The version of nixpkgs used by git-hooks.nix must contain typstyle" + "${config.package}/bin/typstyle -i"; + files = "\\.typ$"; }; -} \ No newline at end of file +} diff --git a/modules/hooks/vale.nix b/modules/hooks/vale.nix index f088fbb3..d0ab6f84 100644 --- a/modules/hooks/vale.nix +++ b/modules/hooks/vale.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, tools, config, mkCmdArgs, ... }: let inherit (lib) mkOption types; in @@ -28,4 +28,23 @@ in default = ""; }; }; + + config = { + name = "vale"; + description = "A markup-aware linter for prose built with speed and extensibility in mind."; + package = tools.vale; + entry = + let + # TODO: was .vale.ini, threw error in Nix + configFile = builtins.toFile "vale.ini" "${config.settings.configuration}"; + cmdArgs = + mkCmdArgs + (with config.settings; [ + [ (configPath != "") " --config ${configPath}" ] + [ (configuration != "" && configPath == "") " --config ${configFile}" ] + ]); + in + "${config.package}/bin/vale${cmdArgs} ${config.settings.flags}"; + types = [ "text" ]; + }; } diff --git a/modules/hooks/yamlfmt.nix b/modules/hooks/yamlfmt.nix index 25389053..d6546380 100644 --- a/modules/hooks/yamlfmt.nix +++ b/modules/hooks/yamlfmt.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, config, tools, mkCmdArgs, ... }: let inherit (lib) mkOption types; in @@ -22,4 +22,25 @@ in default = true; }; }; + + config = { + name = "yamlfmt"; + description = "Formatter for YAML files."; + types = [ "file" "yaml" ]; + package = tools.yamlfmt; + entry = + let + cmdArgs = + mkCmdArgs + (with config.settings; [ + # Exit with non-zero status if the file is not formatted + [ lint-only "-lint" ] + # Do not print the diff + [ lint-only "-quiet" ] + # See https://github.com/google/yamlfmt/blob/main/docs/config-file.md#config-file-discovery + [ (configPath != "") "-conf ${configPath}" ] + ]); + in + "${config.package}/bin/yamlfmt ${cmdArgs}"; + }; } diff --git a/modules/hooks/yamllint.nix b/modules/hooks/yamllint.nix index 50d2b6b7..15866192 100644 --- a/modules/hooks/yamllint.nix +++ b/modules/hooks/yamllint.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, tools, config, mkCmdArgs, ... }: let inherit (lib) mkOption types; in @@ -52,4 +52,27 @@ in default = true; }; }; + + config = { + name = "yamllint"; + description = "Linter for YAML files."; + types = [ "file" "yaml" ]; + package = tools.yamllint; + entry = + let + configFile = builtins.toFile "yamllint.yaml" "${config.settings.configuration}"; + cmdArgs = + mkCmdArgs + (with config.settings; [ + # Priorize multiline configuration over serialized configuration and configuration file + [ (configuration != "") "--config-file ${configFile}" ] + [ (configData != "" && configuration == "") "--config-data \"${configData}\"" ] + [ (configPath != "" && configData == "" && configuration == "" && preset == "default") "--config-file ${configPath}" ] + [ (format != "auto") "--format ${format}" ] + [ (preset != "default" && configuration == "") "--config-data ${preset}" ] + [ strict "--strict" ] + ]); + in + "${config.package}/bin/yamllint ${cmdArgs}"; + }; } diff --git a/modules/hooks/zprint.nix b/modules/hooks/zprint.nix index 190c190b..dc8ec244 100644 --- a/modules/hooks/zprint.nix +++ b/modules/hooks/zprint.nix @@ -1,10 +1,10 @@ -{ tools, lib, ... }: +{ tools, lib, config, ... }: { config = { name = "zprint"; - description = "Clojure/ClojureScript source code formatting."; + description = "Beautifully format Clojure and Clojurescript source code and s-expressions."; package = tools.zprint; - entry = "${tools.zprint}/bin/zprint '{:search-config? true}' -w"; + entry = "${config.package}/bin/zprint '{:search-config? true}' -w"; types_or = [ "clojure" "clojurescript" "edn" ]; }; -} \ No newline at end of file +} From 2898aeef717d892c2d6725063c704e308f410257 Mon Sep 17 00:00:00 2001 From: Sander Date: Mon, 26 May 2025 16:45:36 +0200 Subject: [PATCH 12/13] hooks: duplicate name and description for now --- modules/hooks.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/hooks.nix b/modules/hooks.nix index 9f07fd36..1f7f2ca5 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -11,8 +11,9 @@ let type = types.submoduleWith ({ modules = [ hookModule ] ++ [ module + # TODO # Set name and description - ({ name, ... }: { config = { inherit name description; }; }) + # ({ name, ... }: { config = { inherit name description; }; }) ]; }); default = { }; From 98499b1c0cf4673f3821f93f9f461e9e8e23075a Mon Sep 17 00:00:00 2001 From: Sander Date: Mon, 26 May 2025 20:42:00 +0200 Subject: [PATCH 13/13] hooks: automate name and description --- modules/hooks.nix | 3 +-- modules/hooks/actionlint.nix | 2 -- modules/hooks/alejandra.nix | 2 -- modules/hooks/annex.nix | 2 -- modules/hooks/ansible-lint.nix | 2 -- modules/hooks/autoflake.nix | 2 -- modules/hooks/bats.nix | 2 -- modules/hooks/beautysh.nix | 2 -- modules/hooks/biome.nix | 2 -- modules/hooks/black.nix | 2 -- modules/hooks/cabal-fmt.nix | 2 -- modules/hooks/cabal-gild.nix | 2 -- modules/hooks/cabal2nix.nix | 2 -- modules/hooks/cargo-check.nix | 2 -- modules/hooks/check-added-large-files.nix | 2 -- modules/hooks/check-builtin-literals.nix | 2 -- modules/hooks/check-case-conflicts.nix | 2 -- modules/hooks/check-docstring-first.nix | 2 -- modules/hooks/check-executables-have-shebangs.nix | 2 -- modules/hooks/check-json.nix | 2 -- modules/hooks/check-merge-conflicts.nix | 2 -- modules/hooks/check-python.nix | 2 -- modules/hooks/check-shebang-scripts-are-executable.nix | 2 -- modules/hooks/check-symlinks.nix | 2 -- modules/hooks/check-toml.nix | 2 -- modules/hooks/check-vcs-permalinks.nix | 2 -- modules/hooks/check-xml.nix | 2 -- modules/hooks/check-yaml.nix | 2 -- modules/hooks/checkmake.nix | 2 -- modules/hooks/chktex.nix | 2 -- modules/hooks/circleci.nix | 2 -- modules/hooks/clang-format.nix | 2 -- modules/hooks/clang-tidy.nix | 2 -- modules/hooks/clippy.nix | 2 -- modules/hooks/cljfmt.nix | 2 -- modules/hooks/cmake-format.nix | 2 -- modules/hooks/commitizen.nix | 5 +---- modules/hooks/conform.nix | 2 -- modules/hooks/convco.nix | 1 - modules/hooks/credo.nix | 2 -- modules/hooks/crystal.nix | 2 -- modules/hooks/cspell.nix | 2 -- modules/hooks/dart-analyze.nix | 2 -- modules/hooks/dart-format.nix | 2 -- modules/hooks/deadnix.nix | 2 -- modules/hooks/denofmt.nix | 2 -- modules/hooks/denolint.nix | 2 -- modules/hooks/detect-aws-credentials.nix | 2 -- modules/hooks/detect-private-keys.nix | 2 -- modules/hooks/dhall-format.nix | 2 -- modules/hooks/dialyzer.nix | 2 -- modules/hooks/dune-fmt.nix | 2 -- modules/hooks/dune-opam-sync.nix | 2 -- modules/hooks/eclint.nix | 2 -- modules/hooks/editorconfig-checker.nix | 2 -- modules/hooks/elm-format.nix | 2 -- modules/hooks/elm-review.nix | 2 -- modules/hooks/elm-test.nix | 2 -- modules/hooks/end-of-file-fixer.nix | 2 -- modules/hooks/eslint.nix | 2 -- modules/hooks/fix-byte-order-marker.nix | 2 -- modules/hooks/fix-encoding-pragma.nix | 2 -- modules/hooks/flake-checker.nix | 2 -- modules/hooks/flake8.nix | 2 -- modules/hooks/flynt.nix | 2 -- modules/hooks/forbid-new-submodules.nix | 2 -- modules/hooks/fourmolu.nix | 2 -- modules/hooks/fprettify.nix | 2 -- modules/hooks/gitlint.nix | 2 -- modules/hooks/gofmt.nix | 2 -- modules/hooks/golangci-lint.nix | 2 -- modules/hooks/golines.nix | 2 -- modules/hooks/gotest.nix | 2 -- modules/hooks/govet.nix | 2 -- modules/hooks/gptcommit.nix | 2 -- modules/hooks/hadolint.nix | 2 -- modules/hooks/headache.nix | 2 -- modules/hooks/hindent.nix | 2 -- modules/hooks/hlint.nix | 2 -- modules/hooks/hpack.nix | 2 -- modules/hooks/html-tidy.nix | 2 -- modules/hooks/hunspell.nix | 2 -- modules/hooks/isort.nix | 2 -- modules/hooks/juliaformatter.nix | 2 -- modules/hooks/lacheck.nix | 2 -- modules/hooks/latexindent.nix | 2 -- modules/hooks/lua-ls.nix | 2 -- modules/hooks/luacheck.nix | 2 -- modules/hooks/lychee.nix | 2 -- modules/hooks/markdownlint.nix | 2 -- modules/hooks/mdformat.nix | 2 -- modules/hooks/mdl.nix | 2 -- modules/hooks/mdsh.nix | 2 -- modules/hooks/mix-format.nix | 2 -- modules/hooks/mix-test.nix | 2 -- modules/hooks/mixed-line-endings.nix | 2 -- modules/hooks/mkdocs-linkcheck.nix | 2 -- modules/hooks/name-tests-test.nix | 2 -- modules/hooks/nil.nix | 2 -- modules/hooks/nixpkgs-fmt.nix | 2 -- modules/hooks/ocp-indent.nix | 2 -- modules/hooks/opam-lint.nix | 2 -- modules/hooks/openapi-spec-validator.nix | 2 -- modules/hooks/ormolu.nix | 2 -- modules/hooks/php-cs-fixer.nix | 2 -- modules/hooks/phpcs.nix | 2 -- modules/hooks/phpstan.nix | 2 -- modules/hooks/poetry-check.nix | 2 -- modules/hooks/poetry-lock.nix | 2 -- modules/hooks/pre-commit-hook-ensure-sops.nix | 2 -- modules/hooks/prettier.nix | 2 -- modules/hooks/pretty-format-json.nix | 2 -- modules/hooks/proselint.nix | 2 -- modules/hooks/psalm.nix | 2 -- modules/hooks/purs-tidy.nix | 2 -- modules/hooks/purty.nix | 2 -- modules/hooks/pylint.nix | 2 -- modules/hooks/pyright.nix | 2 -- modules/hooks/python-debug-statements.nix | 2 -- modules/hooks/pyupgrade.nix | 2 -- modules/hooks/reuse.nix | 2 -- modules/hooks/revive.nix | 2 -- modules/hooks/ripsecrets.nix | 2 -- modules/hooks/rome.nix | 2 -- modules/hooks/ruff-format.nix | 2 -- modules/hooks/ruff.nix | 2 -- modules/hooks/rustfmt.nix | 2 -- modules/hooks/selene.nix | 2 -- modules/hooks/shellcheck.nix | 2 -- modules/hooks/shfmt.nix | 2 -- modules/hooks/single-quoted-strings.nix | 2 -- modules/hooks/sort-file-contents.nix | 2 -- modules/hooks/sort-requirements-txt.nix | 2 -- modules/hooks/sort-simple-yaml.nix | 2 -- modules/hooks/staticcheck.nix | 2 -- modules/hooks/statix.nix | 2 -- modules/hooks/stylish-haskell.nix | 2 -- modules/hooks/stylua.nix | 2 -- modules/hooks/tagref.nix | 2 -- modules/hooks/taplo.nix | 2 -- modules/hooks/terraform-format.nix | 2 -- modules/hooks/terraform-validate.nix | 2 -- modules/hooks/tflint.nix | 2 -- modules/hooks/topiary.nix | 2 -- modules/hooks/treefmt.nix | 2 -- modules/hooks/trim-trailing-whitespace.nix | 2 -- modules/hooks/trufflehog.nix | 2 -- modules/hooks/typos.nix | 2 -- modules/hooks/typstfmt.nix | 2 -- modules/hooks/typstyle.nix | 2 -- modules/hooks/vale.nix | 2 -- modules/hooks/yamlfmt.nix | 2 -- modules/hooks/yamllint.nix | 2 -- modules/hooks/zprint.nix | 2 -- 154 files changed, 2 insertions(+), 309 deletions(-) diff --git a/modules/hooks.nix b/modules/hooks.nix index 1f7f2ca5..9f07fd36 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -11,9 +11,8 @@ let type = types.submoduleWith ({ modules = [ hookModule ] ++ [ module - # TODO # Set name and description - # ({ name, ... }: { config = { inherit name description; }; }) + ({ name, ... }: { config = { inherit name description; }; }) ]; }); default = { }; diff --git a/modules/hooks/actionlint.nix b/modules/hooks/actionlint.nix index 46bb5dd7..d9f63003 100644 --- a/modules/hooks/actionlint.nix +++ b/modules/hooks/actionlint.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "actionlint"; - description = "Static checker for GitHub Actions workflow files"; files = "^.github/workflows/"; types = [ "yaml" ]; package = tools.actionlint; diff --git a/modules/hooks/alejandra.nix b/modules/hooks/alejandra.nix index 68b4fc7e..393f4738 100644 --- a/modules/hooks/alejandra.nix +++ b/modules/hooks/alejandra.nix @@ -35,8 +35,6 @@ in }; config = { - name = "alejandra"; - description = "The Uncompromising Nix Code Formatter"; package = tools.alejandra; entry = let diff --git a/modules/hooks/annex.nix b/modules/hooks/annex.nix index 8f1e169a..ade32055 100644 --- a/modules/hooks/annex.nix +++ b/modules/hooks/annex.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "annex"; - description = "Runs the git-annex hook for large file support"; package = tools.git-annex; entry = "${config.package}/bin/git-annex pre-commit"; }; diff --git a/modules/hooks/ansible-lint.nix b/modules/hooks/ansible-lint.nix index f403b963..d2d8dab4 100644 --- a/modules/hooks/ansible-lint.nix +++ b/modules/hooks/ansible-lint.nix @@ -19,8 +19,6 @@ in }; config = { - name = "ansible-lint"; - description = "Ansible linter"; package = tools.ansible-lint; entry = let diff --git a/modules/hooks/autoflake.nix b/modules/hooks/autoflake.nix index 1470b66a..92f1b7e6 100644 --- a/modules/hooks/autoflake.nix +++ b/modules/hooks/autoflake.nix @@ -23,8 +23,6 @@ in }; config = { - name = "autoflake"; - description = "Remove unused imports and variables from Python code"; package = tools.autoflake; entry = let diff --git a/modules/hooks/bats.nix b/modules/hooks/bats.nix index 04080805..b54e584f 100644 --- a/modules/hooks/bats.nix +++ b/modules/hooks/bats.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "bats"; - description = "Run bash unit tests"; types = [ "shell" ]; types_or = [ "bats" "bash" ]; package = tools.bats; diff --git a/modules/hooks/beautysh.nix b/modules/hooks/beautysh.nix index 10a3fca8..f9a80507 100644 --- a/modules/hooks/beautysh.nix +++ b/modules/hooks/beautysh.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "beautysh"; - description = "Format shell files"; types = [ "shell" ]; package = tools.beautysh; entry = "${config.package}/bin/beautysh"; diff --git a/modules/hooks/biome.nix b/modules/hooks/biome.nix index fbfd3b1e..71dc3244 100644 --- a/modules/hooks/biome.nix +++ b/modules/hooks/biome.nix @@ -38,8 +38,6 @@ in }; config = { - name = "biome"; - description = "A toolchain for web projects, aimed to provide functionalities to maintain them"; types_or = [ "javascript" "jsx" "ts" "tsx" "json" ]; package = tools.biome; entry = diff --git a/modules/hooks/black.nix b/modules/hooks/black.nix index e1fb9829..8080e4df 100644 --- a/modules/hooks/black.nix +++ b/modules/hooks/black.nix @@ -13,8 +13,6 @@ in }; config = { - name = "black"; - description = "The uncompromising Python code formatter"; package = tools.black; entry = "${config.package}/bin/black ${config.settings.flags}"; types = [ "file" "python" ]; diff --git a/modules/hooks/cabal-fmt.nix b/modules/hooks/cabal-fmt.nix index 51b0fb7c..0f4d6e8f 100644 --- a/modules/hooks/cabal-fmt.nix +++ b/modules/hooks/cabal-fmt.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "cabal-fmt"; - description = "Format Cabal files"; package = tools.cabal-fmt; entry = "${config.package}/bin/cabal-fmt --inplace"; files = "\\.cabal$"; diff --git a/modules/hooks/cabal-gild.nix b/modules/hooks/cabal-gild.nix index fbcd49fb..65ca0f7d 100644 --- a/modules/hooks/cabal-gild.nix +++ b/modules/hooks/cabal-gild.nix @@ -1,8 +1,6 @@ { tools, config, lib, pkgs, ... }: { config = { - name = "cabal-gild"; - description = "Format Cabal files"; package = tools.cabal-gild; entry = let diff --git a/modules/hooks/cabal2nix.nix b/modules/hooks/cabal2nix.nix index c46eb5b4..e71ebc59 100644 --- a/modules/hooks/cabal2nix.nix +++ b/modules/hooks/cabal2nix.nix @@ -13,8 +13,6 @@ in }; config = { - name = "cabal2nix"; - description = "Run `cabal2nix` on all `*.cabal` files to generate corresponding `.nix` files"; package = tools.cabal2nix-dir; entry = "${config.package}/bin/cabal2nix-dir --outputFileName=${config.settings.outputFilename}"; files = "\\.cabal$"; diff --git a/modules/hooks/cargo-check.nix b/modules/hooks/cargo-check.nix index 760df510..81958f47 100644 --- a/modules/hooks/cargo-check.nix +++ b/modules/hooks/cargo-check.nix @@ -8,8 +8,6 @@ let in { config = { - name = "cargo-check"; - description = "Check the cargo package for errors"; package = tools.cargo; entry = "${config.package}/bin/cargo check ${cargoManifestPathArg}"; files = "\\.rs$"; diff --git a/modules/hooks/check-added-large-files.nix b/modules/hooks/check-added-large-files.nix index 552294a9..996e11ef 100644 --- a/modules/hooks/check-added-large-files.nix +++ b/modules/hooks/check-added-large-files.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "check-added-large-files"; - description = "Prevent very large files to be committed (e.g. binaries)."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/check-added-large-files"; stages = [ "pre-commit" "pre-push" "manual" ]; diff --git a/modules/hooks/check-builtin-literals.nix b/modules/hooks/check-builtin-literals.nix index 4f822dd3..eb3290e7 100644 --- a/modules/hooks/check-builtin-literals.nix +++ b/modules/hooks/check-builtin-literals.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "check-builtin-literals"; - description = "Require literal syntax when initializing empty or zero builtin types in Python."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/check-builtin-literals"; types = [ "python" ]; diff --git a/modules/hooks/check-case-conflicts.nix b/modules/hooks/check-case-conflicts.nix index ad4816af..0e471c3b 100644 --- a/modules/hooks/check-case-conflicts.nix +++ b/modules/hooks/check-case-conflicts.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "check-case-conflicts"; - description = "Check for files that would conflict in case-insensitive filesystems."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/check-case-conflict"; types = [ "file" ]; diff --git a/modules/hooks/check-docstring-first.nix b/modules/hooks/check-docstring-first.nix index f9a3c236..be4db2b0 100644 --- a/modules/hooks/check-docstring-first.nix +++ b/modules/hooks/check-docstring-first.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "check-docstring-above"; - description = "Check that all docstrings appear above the code."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/check-docstring-first"; types = [ "python" ]; diff --git a/modules/hooks/check-executables-have-shebangs.nix b/modules/hooks/check-executables-have-shebangs.nix index ecf00c4b..e97efea5 100644 --- a/modules/hooks/check-executables-have-shebangs.nix +++ b/modules/hooks/check-executables-have-shebangs.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "check-executables-have-shebangs"; - description = "Ensure that all non-binary executables have shebangs."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/check-executables-have-shebangs"; types = [ "text" "executable" ]; diff --git a/modules/hooks/check-json.nix b/modules/hooks/check-json.nix index e15e9af3..af56868c 100644 --- a/modules/hooks/check-json.nix +++ b/modules/hooks/check-json.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "check-json"; - description = "Check syntax of JSON files."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/check-json"; types = [ "json" ]; diff --git a/modules/hooks/check-merge-conflicts.nix b/modules/hooks/check-merge-conflicts.nix index 32ad4327..e36e31b7 100644 --- a/modules/hooks/check-merge-conflicts.nix +++ b/modules/hooks/check-merge-conflicts.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "check-merge-conflicts"; - description = "Check for files that contain merge conflict strings."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/check-merge-conflict"; types = [ "text" ]; diff --git a/modules/hooks/check-python.nix b/modules/hooks/check-python.nix index 6a876b12..28f901a9 100644 --- a/modules/hooks/check-python.nix +++ b/modules/hooks/check-python.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "check-python"; - description = "Check syntax of Python file by parsing Python abstract syntax tree."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/check-ast"; types = [ "python" ]; diff --git a/modules/hooks/check-shebang-scripts-are-executable.nix b/modules/hooks/check-shebang-scripts-are-executable.nix index d6eeaff2..5ffef257 100644 --- a/modules/hooks/check-shebang-scripts-are-executable.nix +++ b/modules/hooks/check-shebang-scripts-are-executable.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "check-shebang-scripts-are-executable"; - description = "Ensure that all (non-binary) files with a shebang are executable."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/check-shebang-scripts-are-executable"; types = [ "text" ]; diff --git a/modules/hooks/check-symlinks.nix b/modules/hooks/check-symlinks.nix index 6efe935f..810c3e54 100644 --- a/modules/hooks/check-symlinks.nix +++ b/modules/hooks/check-symlinks.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "check-symlinks"; - description = "Find broken symlinks."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/check-symlinks"; types = [ "symlink" ]; diff --git a/modules/hooks/check-toml.nix b/modules/hooks/check-toml.nix index ed3609c9..920db480 100644 --- a/modules/hooks/check-toml.nix +++ b/modules/hooks/check-toml.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "check-toml"; - description = "Check syntax of TOML files."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/check-toml"; types = [ "toml" ]; diff --git a/modules/hooks/check-vcs-permalinks.nix b/modules/hooks/check-vcs-permalinks.nix index 37e4ea94..26052114 100644 --- a/modules/hooks/check-vcs-permalinks.nix +++ b/modules/hooks/check-vcs-permalinks.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "check-vcs-permalinks"; - description = "Ensure that links to VCS websites are permalinks."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/check-vcs-permalinks"; types = [ "text" ]; diff --git a/modules/hooks/check-xml.nix b/modules/hooks/check-xml.nix index 43b321f9..a54d9080 100644 --- a/modules/hooks/check-xml.nix +++ b/modules/hooks/check-xml.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "check-xml"; - description = "Check syntax of XML files."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/check-xml"; types = [ "xml" ]; diff --git a/modules/hooks/check-yaml.nix b/modules/hooks/check-yaml.nix index da3850ea..4972bc16 100644 --- a/modules/hooks/check-yaml.nix +++ b/modules/hooks/check-yaml.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "check-yaml"; - description = "Check syntax of YAML files."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/check-yaml --multi"; types = [ "yaml" ]; diff --git a/modules/hooks/checkmake.nix b/modules/hooks/checkmake.nix index 8b5db3b4..9aa2f45d 100644 --- a/modules/hooks/checkmake.nix +++ b/modules/hooks/checkmake.nix @@ -1,8 +1,6 @@ { tools, config, lib, ... }: { config = { - name = "checkmake"; - description = "Experimental linter/analyzer for Makefiles"; types = [ "makefile" ]; package = tools.checkmake; entry = diff --git a/modules/hooks/chktex.nix b/modules/hooks/chktex.nix index 00f2be30..d17f4716 100644 --- a/modules/hooks/chktex.nix +++ b/modules/hooks/chktex.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "chktex"; - description = "LaTeX semantic checker"; types = [ "file" "tex" ]; package = tools.chktex; entry = "${config.package}/bin/chktex"; diff --git a/modules/hooks/circleci.nix b/modules/hooks/circleci.nix index cf478d90..50c0c6c4 100644 --- a/modules/hooks/circleci.nix +++ b/modules/hooks/circleci.nix @@ -1,8 +1,6 @@ { config, tools, lib, pkgs, ... }: { config = { - name = "circleci"; - description = "Validate CircleCI config files."; package = tools.circleci-cli; entry = builtins.toString (pkgs.writeShellScript "precommit-circleci" '' set -e diff --git a/modules/hooks/clang-format.nix b/modules/hooks/clang-format.nix index 70f282be..50caf492 100644 --- a/modules/hooks/clang-format.nix +++ b/modules/hooks/clang-format.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "clang-format"; - description = "Format your code using `clang-format`."; package = tools.clang-tools; entry = "${config.package}/bin/clang-format -style=file -i"; # Source: diff --git a/modules/hooks/clang-tidy.nix b/modules/hooks/clang-tidy.nix index 59debc10..ac856878 100644 --- a/modules/hooks/clang-tidy.nix +++ b/modules/hooks/clang-tidy.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "clang-tidy"; - description = "Static analyzer for C++ code."; package = tools.clang-tools; entry = "${config.package}/bin/clang-tidy --fix"; types_or = [ "c" "c++" "c#" "objective-c" ]; diff --git a/modules/hooks/clippy.nix b/modules/hooks/clippy.nix index 2bf7e97f..1955600b 100644 --- a/modules/hooks/clippy.nix +++ b/modules/hooks/clippy.nix @@ -60,8 +60,6 @@ in }; config = { - name = "clippy"; - description = "Lint Rust code."; package = wrapper; entry = "${wrapper}/bin/cargo-clippy clippy ${cargoManifestPathArg} ${lib.optionalString config.settings.offline "--offline"} ${lib.optionalString config.settings.allFeatures "--all-features"} ${config.settings.extraArgs} -- ${lib.optionalString config.settings.denyWarnings "-D warnings"}"; files = "\\.rs$"; diff --git a/modules/hooks/cljfmt.nix b/modules/hooks/cljfmt.nix index 6007af5a..aff5b8eb 100644 --- a/modules/hooks/cljfmt.nix +++ b/modules/hooks/cljfmt.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "cljfmt"; - description = "A tool for formatting Clojure code."; package = tools.cljfmt; entry = "${config.package}/bin/cljfmt fix"; types_or = [ "clojure" "clojurescript" "edn" ]; diff --git a/modules/hooks/cmake-format.nix b/modules/hooks/cmake-format.nix index a671821c..b07350f6 100644 --- a/modules/hooks/cmake-format.nix +++ b/modules/hooks/cmake-format.nix @@ -13,8 +13,6 @@ in }; config = { - name = "cmake-format"; - description = "A tool for formatting CMake-files."; package = tools.cmake-format; entry = let diff --git a/modules/hooks/commitizen.nix b/modules/hooks/commitizen.nix index 11cdc34d..7555ce3e 100644 --- a/modules/hooks/commitizen.nix +++ b/modules/hooks/commitizen.nix @@ -1,12 +1,9 @@ { config, tools, lib, ... }: { config = { - name = "commitizen check"; - description = '' - Check whether the current commit message follows committing rules. - ''; package = tools.commitizen; entry = "${config.package}/bin/cz check --allow-abort --commit-msg-file"; stages = [ "commit-msg" ]; }; } + diff --git a/modules/hooks/conform.nix b/modules/hooks/conform.nix index 19cd6f52..677e31d7 100644 --- a/modules/hooks/conform.nix +++ b/modules/hooks/conform.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "conform enforce"; - description = "Policy enforcement for commits."; package = tools.conform; entry = "${config.package}/bin/conform enforce --commit-msg-file"; stages = [ "commit-msg" ]; diff --git a/modules/hooks/convco.nix b/modules/hooks/convco.nix index 4231e58c..444d776a 100644 --- a/modules/hooks/convco.nix +++ b/modules/hooks/convco.nix @@ -1,7 +1,6 @@ { config, tools, lib, pkgs, ... }: { config = { - name = "convco"; package = tools.convco; entry = let diff --git a/modules/hooks/credo.nix b/modules/hooks/credo.nix index 7037acd9..e821007c 100644 --- a/modules/hooks/credo.nix +++ b/modules/hooks/credo.nix @@ -13,8 +13,6 @@ in }; config = { - name = "credo"; - description = "Runs a static code analysis using Credo"; package = tools.elixir; entry = let strict = if config.settings.strict then "--strict" else ""; diff --git a/modules/hooks/crystal.nix b/modules/hooks/crystal.nix index 5910cba6..6a0ef778 100644 --- a/modules/hooks/crystal.nix +++ b/modules/hooks/crystal.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "crystal"; - description = "A tool that automatically formats Crystal source code"; package = tools.crystal; entry = "${config.package}/bin/crystal tool format"; files = "\.cr$"; diff --git a/modules/hooks/cspell.nix b/modules/hooks/cspell.nix index 62f50e69..51e09c5f 100644 --- a/modules/hooks/cspell.nix +++ b/modules/hooks/cspell.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "cspell"; - description = "A Spell Checker for Code"; package = tools.cspell; entry = "${config.package}/bin/cspell --no-summary"; types = [ "text" ]; diff --git a/modules/hooks/dart-analyze.nix b/modules/hooks/dart-analyze.nix index ed4e7160..71a5ee9f 100644 --- a/modules/hooks/dart-analyze.nix +++ b/modules/hooks/dart-analyze.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "dart analyze"; - description = "Dart analyzer"; package = tools.dart; entry = "${config.package}/bin/dart analyze"; types = [ "dart" ]; diff --git a/modules/hooks/dart-format.nix b/modules/hooks/dart-format.nix index 1a888114..cb15b560 100644 --- a/modules/hooks/dart-format.nix +++ b/modules/hooks/dart-format.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "dart format"; - description = "Dart formatter"; package = tools.dart; entry = "${config.package}/bin/dart format"; types = [ "dart" ]; diff --git a/modules/hooks/deadnix.nix b/modules/hooks/deadnix.nix index a3a27514..7f50cf06 100644 --- a/modules/hooks/deadnix.nix +++ b/modules/hooks/deadnix.nix @@ -55,8 +55,6 @@ in }; config = { - name = "deadnix"; - description = "Scan Nix files for dead code (unused variable bindings)."; package = tools.deadnix; entry = let diff --git a/modules/hooks/denofmt.nix b/modules/hooks/denofmt.nix index 48d972fa..48d195a6 100644 --- a/modules/hooks/denofmt.nix +++ b/modules/hooks/denofmt.nix @@ -21,8 +21,6 @@ in }; config = { - name = "denofmt"; - description = "Auto-format JavaScript, TypeScript, Markdown, and JSON files."; types_or = [ "javascript" "jsx" "ts" "tsx" "markdown" "json" ]; package = tools.deno; entry = diff --git a/modules/hooks/denolint.nix b/modules/hooks/denolint.nix index dac5e0a5..a0ad03d1 100644 --- a/modules/hooks/denolint.nix +++ b/modules/hooks/denolint.nix @@ -22,8 +22,6 @@ in }; config = { - name = "denolint"; - description = "Lint JavaScript/TypeScript source code."; types_or = [ "javascript" "jsx" "ts" "tsx" ]; package = tools.deno; entry = diff --git a/modules/hooks/detect-aws-credentials.nix b/modules/hooks/detect-aws-credentials.nix index 4ffa1aaf..982e7a8e 100644 --- a/modules/hooks/detect-aws-credentials.nix +++ b/modules/hooks/detect-aws-credentials.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "detect-aws-credentials"; - description = "Detect AWS credentials from the AWS cli credentials file."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/detect-aws-credentials --allow-missing-credentials"; types = [ "text" ]; diff --git a/modules/hooks/detect-private-keys.nix b/modules/hooks/detect-private-keys.nix index ef750a8c..19130d02 100644 --- a/modules/hooks/detect-private-keys.nix +++ b/modules/hooks/detect-private-keys.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "detect-private-keys"; - description = "Detect the presence of private keys."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/detect-private-key"; types = [ "text" ]; diff --git a/modules/hooks/dhall-format.nix b/modules/hooks/dhall-format.nix index 4ead110f..e5b37d4a 100644 --- a/modules/hooks/dhall-format.nix +++ b/modules/hooks/dhall-format.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "dhall-format"; - description = "Dhall code formatter."; package = tools.dhall; entry = "${config.package}/bin/dhall format"; files = "\.dhall$"; diff --git a/modules/hooks/dialyzer.nix b/modules/hooks/dialyzer.nix index 86cd4038..227728d9 100644 --- a/modules/hooks/dialyzer.nix +++ b/modules/hooks/dialyzer.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "dialyzer"; - description = "Runs a static code analysis using Dialyzer"; package = tools.elixir; entry = "${config.package}/bin/mix dialyzer"; files = "\.exs?$"; diff --git a/modules/hooks/dune-fmt.nix b/modules/hooks/dune-fmt.nix index 430ee6b8..37281f61 100644 --- a/modules/hooks/dune-fmt.nix +++ b/modules/hooks/dune-fmt.nix @@ -18,8 +18,6 @@ in }; config = { - name = "dune-fmt"; - description = "Runs Dune's formatters on the code tree."; package = tools.dune-fmt; entry = let diff --git a/modules/hooks/dune-opam-sync.nix b/modules/hooks/dune-opam-sync.nix index be325054..07835651 100644 --- a/modules/hooks/dune-opam-sync.nix +++ b/modules/hooks/dune-opam-sync.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "dune/opam sync"; - description = "Check that Dune-generated OPAM files are in sync."; package = tools.dune-build-opam-files; entry = "${config.package}/bin/dune-build-opam-files"; files = "(\.opam$)|(\.opam.template$)|((^|/)dune-project$)"; diff --git a/modules/hooks/eclint.nix b/modules/hooks/eclint.nix index b38e4cd0..bc1a9be8 100644 --- a/modules/hooks/eclint.nix +++ b/modules/hooks/eclint.nix @@ -37,8 +37,6 @@ in }; config = { - name = "eclint"; - description = "EditorConfig linter written in Go."; types = [ "file" ]; package = tools.eclint; entry = diff --git a/modules/hooks/editorconfig-checker.nix b/modules/hooks/editorconfig-checker.nix index 9f4d7711..dd149ca9 100644 --- a/modules/hooks/editorconfig-checker.nix +++ b/modules/hooks/editorconfig-checker.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "editorconfig-checker"; - description = "Verify that the files are in harmony with the `.editorconfig`."; package = tools.editorconfig-checker; entry = "${config.package}/bin/editorconfig-checker"; types = [ "file" ]; diff --git a/modules/hooks/elm-format.nix b/modules/hooks/elm-format.nix index d8e6ecd9..c2fb3a17 100644 --- a/modules/hooks/elm-format.nix +++ b/modules/hooks/elm-format.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "elm-format"; - description = "Format Elm files."; package = tools.elm-format; entry = "${config.package}/bin/elm-format --yes --elm-version=0.19"; files = "\.elm$"; diff --git a/modules/hooks/elm-review.nix b/modules/hooks/elm-review.nix index 57f032ac..cb003f7d 100644 --- a/modules/hooks/elm-review.nix +++ b/modules/hooks/elm-review.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "elm-review"; - description = "Analyzes Elm projects, to help find mistakes before your users find them."; package = tools.elm-review; entry = "${config.package}/bin/elm-review"; files = "\.elm$"; diff --git a/modules/hooks/elm-test.nix b/modules/hooks/elm-test.nix index 93a198dc..bed84089 100644 --- a/modules/hooks/elm-test.nix +++ b/modules/hooks/elm-test.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "elm-test"; - description = "Run unit tests and fuzz tests for Elm code."; package = tools.elm-test; entry = "${config.package}/bin/elm-test"; files = "\.elm$"; diff --git a/modules/hooks/end-of-file-fixer.nix b/modules/hooks/end-of-file-fixer.nix index b3077c0f..e15c6f72 100644 --- a/modules/hooks/end-of-file-fixer.nix +++ b/modules/hooks/end-of-file-fixer.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "end-of-file-fixer"; - description = "Ensures that a file is either empty, or ends with a single newline."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/end-of-file-fixer"; types = [ "text" ]; diff --git a/modules/hooks/eslint.nix b/modules/hooks/eslint.nix index e1901086..e931157b 100644 --- a/modules/hooks/eslint.nix +++ b/modules/hooks/eslint.nix @@ -31,8 +31,6 @@ in }; config = { - name = "eslint"; - description = "Find and fix problems in your JavaScript code."; package = tools.eslint; entry = let diff --git a/modules/hooks/fix-byte-order-marker.nix b/modules/hooks/fix-byte-order-marker.nix index 5dd2f914..c86ee537 100644 --- a/modules/hooks/fix-byte-order-marker.nix +++ b/modules/hooks/fix-byte-order-marker.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "fix-byte-order-marker"; - description = "Remove UTF-8 byte order marker."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/fix-byte-order-marker"; types = [ "text" ]; diff --git a/modules/hooks/fix-encoding-pragma.nix b/modules/hooks/fix-encoding-pragma.nix index 35c747ec..47900e15 100644 --- a/modules/hooks/fix-encoding-pragma.nix +++ b/modules/hooks/fix-encoding-pragma.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "fix-encoding-pragma"; - description = "Adds # -*- coding: utf-8 -*- to the top of Python files.'"; package = tools.pre-commit-hooks; entry = "${config.package}/bin/fix-encoding-pragma"; types = [ "python" ]; diff --git a/modules/hooks/flake-checker.nix b/modules/hooks/flake-checker.nix index b3b605ff..e30f7f80 100644 --- a/modules/hooks/flake-checker.nix +++ b/modules/hooks/flake-checker.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "flake-checker"; - description = "Run health checks on your flake-powered Nix projects."; package = tools.flake-checker; entry = "${config.package}/bin/flake-checker -f"; files = "(^flake\.nix$|^flake\.lock$)"; diff --git a/modules/hooks/flake8.nix b/modules/hooks/flake8.nix index 86fb87dd..e4646819 100644 --- a/modules/hooks/flake8.nix +++ b/modules/hooks/flake8.nix @@ -34,8 +34,6 @@ in }; config = { - name = "flake8"; - description = "Check the style and quality of Python files."; package = tools.flake8; entry = let diff --git a/modules/hooks/flynt.nix b/modules/hooks/flynt.nix index a60e2f3c..50055312 100644 --- a/modules/hooks/flynt.nix +++ b/modules/hooks/flynt.nix @@ -73,8 +73,6 @@ in }; config = { - name = "flynt"; - description = "CLI tool to convert a python project's %-formatted strings to f-strings."; package = tools.flynt; entry = let diff --git a/modules/hooks/forbid-new-submodules.nix b/modules/hooks/forbid-new-submodules.nix index 71d0cc8b..b1b9b829 100644 --- a/modules/hooks/forbid-new-submodules.nix +++ b/modules/hooks/forbid-new-submodules.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "forbid-new-submodules"; - description = "Prevent addition of new Git submodules."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/forbid-new-submodules"; types = [ "directory" ]; diff --git a/modules/hooks/fourmolu.nix b/modules/hooks/fourmolu.nix index bbae6125..927df030 100644 --- a/modules/hooks/fourmolu.nix +++ b/modules/hooks/fourmolu.nix @@ -12,8 +12,6 @@ in }; config = { - name = "fourmolu"; - description = "Haskell code prettifier."; package = tools.fourmolu; entry = "${config.package}/bin/fourmolu --mode inplace ${ diff --git a/modules/hooks/fprettify.nix b/modules/hooks/fprettify.nix index b227fbf6..f305c99d 100644 --- a/modules/hooks/fprettify.nix +++ b/modules/hooks/fprettify.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "fprettify"; - description = "Auto-formatter for modern Fortran code."; types = [ "fortran " ]; package = tools.fprettify; entry = "${config.package}/bin/fprettify"; diff --git a/modules/hooks/gitlint.nix b/modules/hooks/gitlint.nix index da4a5bc1..46be3125 100644 --- a/modules/hooks/gitlint.nix +++ b/modules/hooks/gitlint.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "gitlint"; - description = "Linting for your git commit messages"; package = tools.gitlint; entry = "${config.package}/bin/gitlint --staged --msg-filename"; stages = [ "commit-msg" ]; diff --git a/modules/hooks/gofmt.nix b/modules/hooks/gofmt.nix index d2901628..11e26483 100644 --- a/modules/hooks/gofmt.nix +++ b/modules/hooks/gofmt.nix @@ -1,8 +1,6 @@ { config, tools, lib, pkgs, ... }: { config = { - name = "gofmt"; - description = "A tool that automatically formats Go source code"; package = tools.go; entry = let diff --git a/modules/hooks/golangci-lint.nix b/modules/hooks/golangci-lint.nix index 9a99d578..a26f0c17 100644 --- a/modules/hooks/golangci-lint.nix +++ b/modules/hooks/golangci-lint.nix @@ -1,8 +1,6 @@ { config, tools, lib, pkgs, ... }: { config = { - name = "golangci-lint"; - description = "Fast linters runner for Go."; package = tools.golangci-lint; entry = let diff --git a/modules/hooks/golines.nix b/modules/hooks/golines.nix index 0c698082..74c5977b 100644 --- a/modules/hooks/golines.nix +++ b/modules/hooks/golines.nix @@ -13,8 +13,6 @@ in }; config = { - name = "golines"; - description = "A golang formatter that fixes long lines"; package = tools.golines; entry = let diff --git a/modules/hooks/gotest.nix b/modules/hooks/gotest.nix index 5327de25..608271dc 100644 --- a/modules/hooks/gotest.nix +++ b/modules/hooks/gotest.nix @@ -1,8 +1,6 @@ { config, tools, lib, pkgs, ... }: { config = { - name = "gotest"; - description = "Run go tests"; package = tools.go; entry = let diff --git a/modules/hooks/govet.nix b/modules/hooks/govet.nix index be84443b..4a3f73e2 100644 --- a/modules/hooks/govet.nix +++ b/modules/hooks/govet.nix @@ -1,8 +1,6 @@ { config, tools, lib, pkgs, ... }: { config = { - name = "govet"; - description = "Checks correctness of Go programs."; package = tools.go; entry = let diff --git a/modules/hooks/gptcommit.nix b/modules/hooks/gptcommit.nix index 1fb6bd84..52a2f2ed 100644 --- a/modules/hooks/gptcommit.nix +++ b/modules/hooks/gptcommit.nix @@ -1,8 +1,6 @@ { config, tools, lib, pkgs, ... }: { config = { - name = "gptcommit"; - description = "Generate a commit message using GPT3."; package = tools.gptcommit; entry = let diff --git a/modules/hooks/hadolint.nix b/modules/hooks/hadolint.nix index 8819f91c..49fdc68e 100644 --- a/modules/hooks/hadolint.nix +++ b/modules/hooks/hadolint.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "hadolint"; - description = "Dockerfile linter, validate inline bash."; package = tools.hadolint; entry = "${config.package}/bin/hadolint"; files = "Dockerfile$"; diff --git a/modules/hooks/headache.nix b/modules/hooks/headache.nix index 8a11b2cc..789de7aa 100644 --- a/modules/hooks/headache.nix +++ b/modules/hooks/headache.nix @@ -12,8 +12,6 @@ in }; config = { - name = "headache"; - description = "Lightweight tool for managing headers in source code files."; ## NOTE: Supported `files` are taken from ## https://github.com/Frama-C/headache/blob/master/config_builtin.txt files = "(\\.ml[ily]?$)|(\\.fmli?$)|(\\.[chy]$)|(\\.tex$)|(Makefile)|(README)|(LICENSE)"; diff --git a/modules/hooks/hindent.nix b/modules/hooks/hindent.nix index d892f8e8..43eed284 100644 --- a/modules/hooks/hindent.nix +++ b/modules/hooks/hindent.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "hindent"; - description = "Haskell code prettifier."; package = tools.hindent; entry = "${config.package}/bin/hindent"; files = "\.l?hs$"; diff --git a/modules/hooks/hlint.nix b/modules/hooks/hlint.nix index 46e79943..78a5f293 100644 --- a/modules/hooks/hlint.nix +++ b/modules/hooks/hlint.nix @@ -12,8 +12,6 @@ in }; }; config = { - name = "hlint"; - description = "HLint gives suggestions on how to improve your source code."; package = tools.hlint; entry = "${config.package}/bin/hlint${if config.settings.hintFile == null then "" else " --hint=${config.settings.hintFile}"}"; files = "\\.l?hs(-boot)?$"; diff --git a/modules/hooks/hpack.nix b/modules/hooks/hpack.nix index 29c9f911..8854c795 100644 --- a/modules/hooks/hpack.nix +++ b/modules/hooks/hpack.nix @@ -13,8 +13,6 @@ in }; config = { - name = "hpack"; - description = "`hpack` converts package definitions in the hpack format (`package.yaml`) to Cabal files."; package = tools.hpack-dir; entry = "${config.package}/bin/hpack-dir --${if config.settings.silent then "silent" else "verbose"}"; files = "(\\.l?hs(-boot)?$)|(\\.cabal$)|((^|/)package\\.yaml$)"; diff --git a/modules/hooks/html-tidy.nix b/modules/hooks/html-tidy.nix index 03f4361d..4e78cbca 100644 --- a/modules/hooks/html-tidy.nix +++ b/modules/hooks/html-tidy.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "html-tidy"; - description = "HTML linter"; package = tools.html-tidy; entry = "${config.package}/bin/tidy -modify -indent -quiet"; types = [ "html" ]; diff --git a/modules/hooks/hunspell.nix b/modules/hooks/hunspell.nix index b203b6da..5c9f97e9 100644 --- a/modules/hooks/hunspell.nix +++ b/modules/hooks/hunspell.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "hunspell"; - description = "Spell checker and morphological analyzer."; package = tools.hunspell; entry = "${config.package}/bin/hunspell -l"; types = [ "text" ]; diff --git a/modules/hooks/isort.nix b/modules/hooks/isort.nix index f6933266..ab032f37 100644 --- a/modules/hooks/isort.nix +++ b/modules/hooks/isort.nix @@ -19,8 +19,6 @@ in }; config = { - name = "isort"; - description = "A Python utility / library to sort imports."; types = [ "file" "python" ]; package = tools.isort; entry = diff --git a/modules/hooks/juliaformatter.nix b/modules/hooks/juliaformatter.nix index 11e4dac1..67f7e813 100644 --- a/modules/hooks/juliaformatter.nix +++ b/modules/hooks/juliaformatter.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "juliaformatter"; - description = "Run JuliaFormatter.jl against Julia source files"; package = tools.julia-bin; entry = '' ${config.package}/bin/julia -e ' diff --git a/modules/hooks/lacheck.nix b/modules/hooks/lacheck.nix index 017de292..b4b52f8f 100644 --- a/modules/hooks/lacheck.nix +++ b/modules/hooks/lacheck.nix @@ -27,8 +27,6 @@ in ''; in { - name = "lacheck"; - description = "A consistency checker for LaTeX documents."; types = [ "file" "tex" ]; package = tools.lacheck; entry = "${script}"; diff --git a/modules/hooks/latexindent.nix b/modules/hooks/latexindent.nix index 409dca5c..99d95199 100644 --- a/modules/hooks/latexindent.nix +++ b/modules/hooks/latexindent.nix @@ -13,8 +13,6 @@ in }; config = { - name = "latexindent"; - description = "Perl script to add indentation to LaTeX files."; types = [ "file" "tex" ]; package = tools.latexindent; entry = "${config.package}/bin/latexindent ${config.settings.flags}"; diff --git a/modules/hooks/lua-ls.nix b/modules/hooks/lua-ls.nix index a7c9daec..95ae7b89 100644 --- a/modules/hooks/lua-ls.nix +++ b/modules/hooks/lua-ls.nix @@ -54,8 +54,6 @@ in }; in { - name = "lua-ls"; - description = "Uses the lua-language-server CLI to statically type-check and lint Lua code."; package = tools.lua-language-server; entry = "${script}/bin/lua-ls-lint"; files = "\\.lua$"; diff --git a/modules/hooks/luacheck.nix b/modules/hooks/luacheck.nix index f3b3da9d..b4d87acc 100644 --- a/modules/hooks/luacheck.nix +++ b/modules/hooks/luacheck.nix @@ -1,8 +1,6 @@ { tools, config, lib, ... }: { config = { - name = "luacheck"; - description = "A tool for linting and static analysis of Lua code."; package = tools.luacheck; entry = "${config.package}/bin/luacheck"; types = [ "lua" ]; diff --git a/modules/hooks/lychee.nix b/modules/hooks/lychee.nix index 63fc18bf..552c1baa 100644 --- a/modules/hooks/lychee.nix +++ b/modules/hooks/lychee.nix @@ -19,8 +19,6 @@ in }; config = { - name = "lychee"; - description = "A fast, async, stream-based link checker that finds broken hyperlinks and mail addresses inside Markdown, HTML, reStructuredText, or any other text file or website."; package = tools.lychee; entry = let diff --git a/modules/hooks/markdownlint.nix b/modules/hooks/markdownlint.nix index 7b311fb8..7befcf72 100644 --- a/modules/hooks/markdownlint.nix +++ b/modules/hooks/markdownlint.nix @@ -14,8 +14,6 @@ in }; config = { - name = "markdownlint"; - description = "Style checker and linter for markdown files."; package = tools.markdownlint-cli; entry = "${config.package}/bin/markdownlint -c ${pkgs.writeText "markdownlint.json" (builtins.toJSON config.settings.configuration)}"; files = "\\.md$"; diff --git a/modules/hooks/mdformat.nix b/modules/hooks/mdformat.nix index be51e9b5..a99efd9d 100644 --- a/modules/hooks/mdformat.nix +++ b/modules/hooks/mdformat.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "mdformat"; - description = "CommonMark compliant Markdown formatter."; package = tools.mdformat; entry = "${config.package}/bin/mdformat"; types = [ "markdown" ]; diff --git a/modules/hooks/mdl.nix b/modules/hooks/mdl.nix index f191d4d4..7a0aa717 100644 --- a/modules/hooks/mdl.nix +++ b/modules/hooks/mdl.nix @@ -79,8 +79,6 @@ in }; config = { - name = "mdl"; - description = "A tool to check markdown files and flag style issues."; package = tools.mdl; entry = let diff --git a/modules/hooks/mdsh.nix b/modules/hooks/mdsh.nix index 30444950..e1fe791f 100644 --- a/modules/hooks/mdsh.nix +++ b/modules/hooks/mdsh.nix @@ -1,8 +1,6 @@ { config, tools, lib, pkgs, ... }: { config = { - name = "mdsh"; - description = "Markdown shell pre-processor."; package = tools.mdsh; entry = let diff --git a/modules/hooks/mix-format.nix b/modules/hooks/mix-format.nix index 43052058..dc6a70f6 100644 --- a/modules/hooks/mix-format.nix +++ b/modules/hooks/mix-format.nix @@ -1,8 +1,6 @@ { config, tools, lib, ... }: { config = { - name = "mix-format"; - description = "Format Elixir files with mix format."; package = tools.elixir; entry = "${config.package}/bin/mix format"; files = "\.exs?$"; diff --git a/modules/hooks/mix-test.nix b/modules/hooks/mix-test.nix index 732b9327..39230e63 100644 --- a/modules/hooks/mix-test.nix +++ b/modules/hooks/mix-test.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "mix-test"; - description = "Run Elixir tests with mix test."; package = tools.elixir; entry = "${config.package}/bin/mix test"; files = "\.exs?$"; diff --git a/modules/hooks/mixed-line-endings.nix b/modules/hooks/mixed-line-endings.nix index 4322d30d..2eee882a 100644 --- a/modules/hooks/mixed-line-endings.nix +++ b/modules/hooks/mixed-line-endings.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "mixed-line-endings"; - description = "Resolve mixed line endings."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/mixed-line-ending"; types = [ "text" ]; diff --git a/modules/hooks/mkdocs-linkcheck.nix b/modules/hooks/mkdocs-linkcheck.nix index 9f473fb6..552902fb 100644 --- a/modules/hooks/mkdocs-linkcheck.nix +++ b/modules/hooks/mkdocs-linkcheck.nix @@ -51,8 +51,6 @@ in }; config = { - name = "mkdocs-linkcheck"; - description = "Validate links associated with markdown-based, statically generated websites."; package = tools.mkdocs-linkcheck; entry = let diff --git a/modules/hooks/name-tests-test.nix b/modules/hooks/name-tests-test.nix index 1c38e7e8..ae0fd800 100644 --- a/modules/hooks/name-tests-test.nix +++ b/modules/hooks/name-tests-test.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "name-tests-test"; - description = "Verify that Python test files are named correctly."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/tests_should_end_in_test.py"; files = "(^|/)tests/\.+\\.py$"; diff --git a/modules/hooks/nil.nix b/modules/hooks/nil.nix index 79937430..7692a2c0 100644 --- a/modules/hooks/nil.nix +++ b/modules/hooks/nil.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "nil"; - description = "Incremental analysis assistant for writing in Nix."; package = tools.nil; entry = "${config.package}/bin/nil"; files = "\.nix$"; diff --git a/modules/hooks/nixpkgs-fmt.nix b/modules/hooks/nixpkgs-fmt.nix index 5fa0be23..ca457f33 100644 --- a/modules/hooks/nixpkgs-fmt.nix +++ b/modules/hooks/nixpkgs-fmt.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "nixpkgs-fmt"; - description = "Nix code formatter for nixpkgs."; package = tools.nixpkgs-fmt; entry = "${config.package}/bin/nixpkgs-fmt"; files = "\.nix$"; diff --git a/modules/hooks/ocp-indent.nix b/modules/hooks/ocp-indent.nix index 8d644af4..5d597764 100644 --- a/modules/hooks/ocp-indent.nix +++ b/modules/hooks/ocp-indent.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "ocp-indent"; - description = "A tool to indent OCaml code."; package = tools.ocp-indent; entry = "${config.package}/bin/ocp-indent --inplace"; files = "\.mli?$"; diff --git a/modules/hooks/opam-lint.nix b/modules/hooks/opam-lint.nix index 67982e9c..21828cfd 100644 --- a/modules/hooks/opam-lint.nix +++ b/modules/hooks/opam-lint.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "opam lint"; - description = "OCaml package manager configuration checker"; package = tools.opam; entry = "${config.package}/bin/opam lint"; files = "opam$"; diff --git a/modules/hooks/openapi-spec-validator.nix b/modules/hooks/openapi-spec-validator.nix index 3f97d5b6..64951322 100644 --- a/modules/hooks/openapi-spec-validator.nix +++ b/modules/hooks/openapi-spec-validator.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "openapi-spec-validator"; - description = "Validate OpenAPI specifications."; package = tools.openapi-spec-validator; entry = "${config.package}/bin/openapi-spec-validator"; files = "\.ya?ml$"; diff --git a/modules/hooks/ormolu.nix b/modules/hooks/ormolu.nix index 2554ffed..b8c4d303 100644 --- a/modules/hooks/ormolu.nix +++ b/modules/hooks/ormolu.nix @@ -19,8 +19,6 @@ in }; config = { - name = "ormolu"; - description = "Haskell code prettifier."; package = tools.ormolu; entry = let diff --git a/modules/hooks/php-cs-fixer.nix b/modules/hooks/php-cs-fixer.nix index 60f4c42a..9e9330ca 100644 --- a/modules/hooks/php-cs-fixer.nix +++ b/modules/hooks/php-cs-fixer.nix @@ -16,8 +16,6 @@ in }; config = { - name = "php-cs-fixer"; - description = "Lint PHP files."; package = tools.php-cs-fixer; entry = let diff --git a/modules/hooks/phpcs.nix b/modules/hooks/phpcs.nix index 0c7cd766..a4d16bfd 100644 --- a/modules/hooks/phpcs.nix +++ b/modules/hooks/phpcs.nix @@ -16,8 +16,6 @@ in }; config = { - name = "phpcs"; - description = "Lint PHP files."; package = tools.phpcs; entry = migrateBinPathToPackage config "/bin/phpcs"; types = [ "php" ]; diff --git a/modules/hooks/phpstan.nix b/modules/hooks/phpstan.nix index 8d785c9b..57f83714 100644 --- a/modules/hooks/phpstan.nix +++ b/modules/hooks/phpstan.nix @@ -16,8 +16,6 @@ in }; config = { - name = "phpstan"; - description = "Static Analysis of PHP files."; package = tools.phpstan; entry = let diff --git a/modules/hooks/poetry-check.nix b/modules/hooks/poetry-check.nix index 6274bb97..5c3c9b58 100644 --- a/modules/hooks/poetry-check.nix +++ b/modules/hooks/poetry-check.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "poetry check"; - description = "Check the validity of the pyproject.toml file."; package = tools.poetry; entry = "${config.package}/bin/poetry check"; files = "^(poetry\\.lock$|pyproject\\.toml)$"; diff --git a/modules/hooks/poetry-lock.nix b/modules/hooks/poetry-lock.nix index 3b84a0b1..cfcda27f 100644 --- a/modules/hooks/poetry-lock.nix +++ b/modules/hooks/poetry-lock.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "poetry lock"; - description = "Update the poetry.lock file"; package = tools.poetry; entry = "${config.package}/bin/poetry lock"; files = "^(poetry\\.lock$|pyproject\\.toml)$"; diff --git a/modules/hooks/pre-commit-hook-ensure-sops.nix b/modules/hooks/pre-commit-hook-ensure-sops.nix index 99cdc6e3..73eb623b 100644 --- a/modules/hooks/pre-commit-hook-ensure-sops.nix +++ b/modules/hooks/pre-commit-hook-ensure-sops.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "pre-commit-hook-ensure-sops"; - description = "Ensure that sops files are encrypted."; package = tools.pre-commit-hook-ensure-sops; entry = "${config.package}/bin/pre-commit-hook-ensure-sops"; files = "^secrets"; diff --git a/modules/hooks/prettier.nix b/modules/hooks/prettier.nix index 916d78f7..1b0f3166 100644 --- a/modules/hooks/prettier.nix +++ b/modules/hooks/prettier.nix @@ -250,8 +250,6 @@ in }; config = { - name = "prettier"; - description = "Opinionated multi-language code formatter."; types = [ "text" ]; package = tools.prettier; entry = diff --git a/modules/hooks/pretty-format-json.nix b/modules/hooks/pretty-format-json.nix index 8d9db0a5..5e1bafb6 100644 --- a/modules/hooks/pretty-format-json.nix +++ b/modules/hooks/pretty-format-json.nix @@ -37,8 +37,6 @@ in }; config = { - name = "pretty-format-json"; - description = "Pretty format JSON."; package = tools.pre-commit-hooks; entry = let diff --git a/modules/hooks/proselint.nix b/modules/hooks/proselint.nix index 5d1c86bc..6f2cf1ee 100644 --- a/modules/hooks/proselint.nix +++ b/modules/hooks/proselint.nix @@ -32,8 +32,6 @@ in }; config = { - name = "proselint"; - description = "A linter for prose."; types = [ "text" ]; package = tools.proselint; entry = diff --git a/modules/hooks/psalm.nix b/modules/hooks/psalm.nix index 50e94436..e191a1b3 100644 --- a/modules/hooks/psalm.nix +++ b/modules/hooks/psalm.nix @@ -16,8 +16,6 @@ in }; config = { - name = "psalm"; - description = "Static Analysis of PHP files."; package = tools.psalm; entry = migrateBinPathToPackage config "/bin/psalm"; types = [ "php" ]; diff --git a/modules/hooks/purs-tidy.nix b/modules/hooks/purs-tidy.nix index ea0dc00e..a441e43f 100644 --- a/modules/hooks/purs-tidy.nix +++ b/modules/hooks/purs-tidy.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "purs-tidy"; - description = "Format purescript files."; package = tools.purs-tidy; entry = "${config.package}/bin/purs-tidy format-in-place"; files = "\.purs$"; diff --git a/modules/hooks/purty.nix b/modules/hooks/purty.nix index 468861e7..6a8ee99e 100644 --- a/modules/hooks/purty.nix +++ b/modules/hooks/purty.nix @@ -1,8 +1,6 @@ { tools, config, lib, ... }: { config = { - name = "purty"; - description = "Format purescript files."; package = tools.purty; entry = "${config.package}/bin/purty"; files = "\\.purs$"; diff --git a/modules/hooks/pylint.nix b/modules/hooks/pylint.nix index 407db15b..8c65078b 100644 --- a/modules/hooks/pylint.nix +++ b/modules/hooks/pylint.nix @@ -28,8 +28,6 @@ in }; config = { - name = "pylint"; - description = "Lint Python files."; package = tools.pylint; entry = let diff --git a/modules/hooks/pyright.nix b/modules/hooks/pyright.nix index e235c16c..10f5f2d3 100644 --- a/modules/hooks/pyright.nix +++ b/modules/hooks/pyright.nix @@ -16,8 +16,6 @@ in }; config = { - name = "pyright"; - description = "Static type checker for Python"; package = tools.pyright; entry = migrateBinPathToPackage config "/bin/pyright"; files = "\\.py$"; diff --git a/modules/hooks/python-debug-statements.nix b/modules/hooks/python-debug-statements.nix index 26155ea3..3eaa9d93 100644 --- a/modules/hooks/python-debug-statements.nix +++ b/modules/hooks/python-debug-statements.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "debug-statements"; - description = "Check for debugger imports and py37+ `breakpoint()` calls in python source."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/debug-statement-hook"; types = [ "python" ]; diff --git a/modules/hooks/pyupgrade.nix b/modules/hooks/pyupgrade.nix index f76d1fa0..d5e16ff1 100644 --- a/modules/hooks/pyupgrade.nix +++ b/modules/hooks/pyupgrade.nix @@ -16,8 +16,6 @@ in }; config = { - name = "pyupgrade"; - description = "Upgrade syntax for newer versions of Python."; package = tools.pyupgrade; entry = migrateBinPathToPackage config "/bin/pyupgrade"; types = [ "python" ]; diff --git a/modules/hooks/reuse.nix b/modules/hooks/reuse.nix index 8c292594..5b24fd57 100644 --- a/modules/hooks/reuse.nix +++ b/modules/hooks/reuse.nix @@ -13,8 +13,6 @@ in }; config = { - name = "reuse"; - description = "reuse is a tool for compliance with the REUSE recommendations."; package = tools.reuse; entry = "${config.package}/bin/reuse lint ${config.settings.flags}"; types = [ "file" ]; diff --git a/modules/hooks/revive.nix b/modules/hooks/revive.nix index ef51998c..ffc690b3 100644 --- a/modules/hooks/revive.nix +++ b/modules/hooks/revive.nix @@ -15,8 +15,6 @@ in }; config = { - name = "revive"; - description = "A linter for Go source code."; package = tools.revive; entry = let diff --git a/modules/hooks/ripsecrets.nix b/modules/hooks/ripsecrets.nix index 8d57179c..41ab6a67 100644 --- a/modules/hooks/ripsecrets.nix +++ b/modules/hooks/ripsecrets.nix @@ -13,8 +13,6 @@ in }; config = { - name = "ripsecrets"; - description = "Prevent committing secret keys into your source code"; package = tools.ripsecrets; entry = let diff --git a/modules/hooks/rome.nix b/modules/hooks/rome.nix index ce2994d1..6c7977d9 100644 --- a/modules/hooks/rome.nix +++ b/modules/hooks/rome.nix @@ -38,8 +38,6 @@ in }; config = { - name = "rome-deprecated"; - description = ""; types_or = [ "javascript" "jsx" "ts" "tsx" "json" ]; package = tools.biome; entry = diff --git a/modules/hooks/ruff-format.nix b/modules/hooks/ruff-format.nix index e5ddc593..ae2eede2 100644 --- a/modules/hooks/ruff-format.nix +++ b/modules/hooks/ruff-format.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "ruff-format"; - description = "An extremely fast Python code formatter, written in Rust."; package = tools.ruff; entry = "${config.package}/bin/ruff format"; types = [ "python" ]; diff --git a/modules/hooks/ruff.nix b/modules/hooks/ruff.nix index 9f3d34ba..0cc4c0ef 100644 --- a/modules/hooks/ruff.nix +++ b/modules/hooks/ruff.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "ruff"; - description = "An extremely fast Python linter, written in Rust."; package = tools.ruff; entry = "${config.package}/bin/ruff check --fix"; types = [ "python" ]; diff --git a/modules/hooks/rustfmt.nix b/modules/hooks/rustfmt.nix index 4f4c36bf..472cf165 100644 --- a/modules/hooks/rustfmt.nix +++ b/modules/hooks/rustfmt.nix @@ -97,8 +97,6 @@ in }; in { - name = "rustfmt"; - description = "Format Rust code."; package = wrapper; packageOverrides = { inherit (tools) cargo rustfmt; }; entry = diff --git a/modules/hooks/selene.nix b/modules/hooks/selene.nix index 5776bd68..3b76ba27 100644 --- a/modules/hooks/selene.nix +++ b/modules/hooks/selene.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "selene"; - description = "A blazing-fast modern Lua linter written in Rust."; package = tools.selene; entry = "${config.package}/bin/selene"; types = [ "lua" ]; diff --git a/modules/hooks/shellcheck.nix b/modules/hooks/shellcheck.nix index 1ca69824..85491c3b 100644 --- a/modules/hooks/shellcheck.nix +++ b/modules/hooks/shellcheck.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "shellcheck"; - description = "Format shell files"; package = tools.shellcheck; entry = "${config.package}/bin/shellcheck"; types = [ "shell" ]; diff --git a/modules/hooks/shfmt.nix b/modules/hooks/shfmt.nix index b0f11368..2d063925 100644 --- a/modules/hooks/shfmt.nix +++ b/modules/hooks/shfmt.nix @@ -12,8 +12,6 @@ in }; config = { - name = "shfmt"; - description = "Format shell files."; types = [ "shell" ]; package = tools.shfmt; entry = diff --git a/modules/hooks/single-quoted-strings.nix b/modules/hooks/single-quoted-strings.nix index 06a33a70..1a76dcd1 100644 --- a/modules/hooks/single-quoted-strings.nix +++ b/modules/hooks/single-quoted-strings.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "single-quoted-strings"; - description = "Replace double quoted strings with single quoted strings."; package = tools.pre-commit-hooks; entry = "${config.package}/bin/double-quote-string-fixer"; types = [ "python" ]; diff --git a/modules/hooks/sort-file-contents.nix b/modules/hooks/sort-file-contents.nix index 1158e4ba..07a72eb6 100644 --- a/modules/hooks/sort-file-contents.nix +++ b/modules/hooks/sort-file-contents.nix @@ -19,8 +19,6 @@ in }; config = { - name = "sort-file-contents"; - description = "Sort the lines in specified files (defaults to alphabetical)."; types = [ "text" ]; package = tools.pre-commit-hooks; entry = diff --git a/modules/hooks/sort-requirements-txt.nix b/modules/hooks/sort-requirements-txt.nix index 7878900f..912a62c6 100644 --- a/modules/hooks/sort-requirements-txt.nix +++ b/modules/hooks/sort-requirements-txt.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "sort-requirements-txt"; - description = "Sort requirements in requirements.txt and constraints.txt files"; package = tools.pre-commit-hooks; entry = "${config.package}/bin/requirements-txt-fixer"; files = "\\.*(requirements|constraints)\\.*\\.txt$"; diff --git a/modules/hooks/sort-simple-yaml.nix b/modules/hooks/sort-simple-yaml.nix index 78f64d29..793b39fd 100644 --- a/modules/hooks/sort-simple-yaml.nix +++ b/modules/hooks/sort-simple-yaml.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "sort-simple-yaml"; - description = "Sort simple YAML files which consist only of top-level keys, preserving comments and blocks"; package = tools.pre-commit-hooks; entry = "${config.package}/bin/sort-simple-yaml"; files = "(\\.yaml$)|(\\.yml$)"; diff --git a/modules/hooks/staticcheck.nix b/modules/hooks/staticcheck.nix index 7e1ce6b0..8afdd4d6 100644 --- a/modules/hooks/staticcheck.nix +++ b/modules/hooks/staticcheck.nix @@ -1,8 +1,6 @@ { tools, lib, config, pkgs, ... }: { config = { - name = "staticcheck"; - description = "State of the art linter for the Go programming language"; package = tools.go-tools; # staticheck works with directories. entry = diff --git a/modules/hooks/statix.nix b/modules/hooks/statix.nix index f7b4030e..78ad834a 100644 --- a/modules/hooks/statix.nix +++ b/modules/hooks/statix.nix @@ -36,8 +36,6 @@ in }; config = { - name = "statix"; - description = "Lints and suggestions for the Nix programming language."; package = tools.statix; entry = let diff --git a/modules/hooks/stylish-haskell.nix b/modules/hooks/stylish-haskell.nix index e6b0e978..8f2592bf 100644 --- a/modules/hooks/stylish-haskell.nix +++ b/modules/hooks/stylish-haskell.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "stylish-haskell"; - description = "A simple Haskell code prettifier."; package = tools.stylish-haskell; entry = "${config.package}/bin/stylish-haskell --inplace"; files = "\\.l?hs(-boot)?$"; diff --git a/modules/hooks/stylua.nix b/modules/hooks/stylua.nix index 0871d43a..25e2b7e0 100644 --- a/modules/hooks/stylua.nix +++ b/modules/hooks/stylua.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "stylua"; - description = "An opinionated code formatter for Lua."; package = tools.stylua; entry = "${config.package}/bin/stylua --respect-ignores"; types = [ "file" "lua" ]; diff --git a/modules/hooks/tagref.nix b/modules/hooks/tagref.nix index 625f75fd..be509bd2 100644 --- a/modules/hooks/tagref.nix +++ b/modules/hooks/tagref.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "tagref"; - description = "Have tagref check all references and tags."; package = tools.tagref; entry = "${config.package}/bin/tagref"; types = [ "text" ]; diff --git a/modules/hooks/taplo.nix b/modules/hooks/taplo.nix index be579a37..a7a244b7 100644 --- a/modules/hooks/taplo.nix +++ b/modules/hooks/taplo.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "taplo"; - description = "Format TOML files with taplo fmt."; package = tools.taplo; entry = "${config.package}/bin/taplo fmt"; types = [ "toml" ]; diff --git a/modules/hooks/terraform-format.nix b/modules/hooks/terraform-format.nix index 53bc7238..33f6da10 100644 --- a/modules/hooks/terraform-format.nix +++ b/modules/hooks/terraform-format.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "terraform-format"; - description = "Format Terraform (`.tf`) files."; package = tools.opentofu; entry = "${lib.getExe config.package} fmt -check -diff"; files = "\\.tf$"; diff --git a/modules/hooks/terraform-validate.nix b/modules/hooks/terraform-validate.nix index 08709d57..e17ba788 100644 --- a/modules/hooks/terraform-validate.nix +++ b/modules/hooks/terraform-validate.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "terraform-validate"; - description = "Validates terraform configuration files (`.tf`)."; package = tools.terraform-validate; entry = "${config.package}/bin/terraform-validate"; files = "\\.(tf(vars)?|terraform\\.lock\\.hcl)$"; diff --git a/modules/hooks/tflint.nix b/modules/hooks/tflint.nix index d27c203f..3c1df742 100644 --- a/modules/hooks/tflint.nix +++ b/modules/hooks/tflint.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "tflint"; - description = "A pluggable Terraform linter."; package = tools.tflint; entry = "${config.package}/bin/tflint"; files = "\\.tf$"; diff --git a/modules/hooks/topiary.nix b/modules/hooks/topiary.nix index cedc3800..56078353 100644 --- a/modules/hooks/topiary.nix +++ b/modules/hooks/topiary.nix @@ -1,8 +1,6 @@ { tools, lib, config, pkgs, ... }: { config = { - name = "topiary"; - description = "A universal formatter engine within the Tree-sitter ecosystem, with support for many languages."; package = tools.topiary; entry = let diff --git a/modules/hooks/treefmt.nix b/modules/hooks/treefmt.nix index f52af423..655d5a2a 100644 --- a/modules/hooks/treefmt.nix +++ b/modules/hooks/treefmt.nix @@ -47,8 +47,6 @@ in }; in { - name = "treefmt"; - description = "One CLI to format the code tree."; types = [ "file" ]; pass_filenames = true; package = wrapper; diff --git a/modules/hooks/trim-trailing-whitespace.nix b/modules/hooks/trim-trailing-whitespace.nix index d0302815..9dd3cbeb 100644 --- a/modules/hooks/trim-trailing-whitespace.nix +++ b/modules/hooks/trim-trailing-whitespace.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "trailing-whitespace"; - description = "Trim trailing whitespace."; types = [ "text" ]; stages = [ "pre-commit" "pre-push" "manual" ]; package = tools.pre-commit-hooks; diff --git a/modules/hooks/trufflehog.nix b/modules/hooks/trufflehog.nix index 88afa5d0..9903eb70 100644 --- a/modules/hooks/trufflehog.nix +++ b/modules/hooks/trufflehog.nix @@ -1,8 +1,6 @@ { tools, lib, pkgs, config, ... }: { config = { - name = "trufflehog"; - description = "Secrets scanner."; package = tools.trufflehog; entry = let diff --git a/modules/hooks/typos.nix b/modules/hooks/typos.nix index 1915321c..7e2aaba1 100644 --- a/modules/hooks/typos.nix +++ b/modules/hooks/typos.nix @@ -132,8 +132,6 @@ in }; config = { - name = "typos"; - description = "Source code spell checker"; package = tools.typos; entry = let diff --git a/modules/hooks/typstfmt.nix b/modules/hooks/typstfmt.nix index f46441d1..be30daf1 100644 --- a/modules/hooks/typstfmt.nix +++ b/modules/hooks/typstfmt.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "typstfmt"; - description = "Format Typst files."; package = tools.typstfmt; entry = "${config.package}/bin/typstfmt"; files = "\\.typ$"; diff --git a/modules/hooks/typstyle.nix b/modules/hooks/typstyle.nix index 28016654..46c52652 100644 --- a/modules/hooks/typstyle.nix +++ b/modules/hooks/typstyle.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "typstyle"; - description = "Beautiful and reliable typst code formatter."; package = tools.typstyle; entry = lib.throwIf diff --git a/modules/hooks/vale.nix b/modules/hooks/vale.nix index d0ab6f84..a28326c3 100644 --- a/modules/hooks/vale.nix +++ b/modules/hooks/vale.nix @@ -30,8 +30,6 @@ in }; config = { - name = "vale"; - description = "A markup-aware linter for prose built with speed and extensibility in mind."; package = tools.vale; entry = let diff --git a/modules/hooks/yamlfmt.nix b/modules/hooks/yamlfmt.nix index d6546380..34693737 100644 --- a/modules/hooks/yamlfmt.nix +++ b/modules/hooks/yamlfmt.nix @@ -24,8 +24,6 @@ in }; config = { - name = "yamlfmt"; - description = "Formatter for YAML files."; types = [ "file" "yaml" ]; package = tools.yamlfmt; entry = diff --git a/modules/hooks/yamllint.nix b/modules/hooks/yamllint.nix index 15866192..e4ea340b 100644 --- a/modules/hooks/yamllint.nix +++ b/modules/hooks/yamllint.nix @@ -54,8 +54,6 @@ in }; config = { - name = "yamllint"; - description = "Linter for YAML files."; types = [ "file" "yaml" ]; package = tools.yamllint; entry = diff --git a/modules/hooks/zprint.nix b/modules/hooks/zprint.nix index dc8ec244..17b8fa0d 100644 --- a/modules/hooks/zprint.nix +++ b/modules/hooks/zprint.nix @@ -1,8 +1,6 @@ { tools, lib, config, ... }: { config = { - name = "zprint"; - description = "Beautifully format Clojure and Clojurescript source code and s-expressions."; package = tools.zprint; entry = "${config.package}/bin/zprint '{:search-config? true}' -w"; types_or = [ "clojure" "clojurescript" "edn" ];