From 9e87586c45e2c2aec6329770ff1556ca4586d358 Mon Sep 17 00:00:00 2001 From: Sander Date: Sat, 10 Feb 2024 22:25:06 +0000 Subject: [PATCH] Move hook-specific settings under hooks..settings --- modules/hooks.nix | 268 +++++++++++++++++++++++----------------------- 1 file changed, 133 insertions(+), 135 deletions(-) diff --git a/modules/hooks.nix b/modules/hooks.nix index c62be1c6..b993fdbd 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -1,10 +1,10 @@ { config, lib, pkgs, ... }: let inherit (config) tools; - # TODO: rename all uses of settings. with hooks. - settings = config.hooks; - inherit (lib) mkOption mkRenamedOptionModule types; cfg = config; + hooks = config.hooks; + settings = config.settings; + inherit (lib) mkOption mkRenamedOptionModule types; hookModule = [ @@ -14,8 +14,8 @@ let cargoManifestPathArg = lib.optionalString - (config.settings.rust.cargoManifestPath != null) - "--manifest-path ${lib.escapeShellArg config.settings.rust.cargoManifestPath}"; + (settings.rust.cargoManifestPath != null) + "--manifest-path ${lib.escapeShellArg settings.rust.cargoManifestPath}"; mkCmdArgs = predActionList: lib.concatStringsSep @@ -29,7 +29,7 @@ let in { imports = - map (o: mkRenamedOptionModule [ "settings" o ] [ "hooks" o ]) + map (o: mkRenamedOptionModule [ "settings" o ] [ "hooks" o "settings" ]) [ "alejandra" "ansible-lint" "autoflake" "clippy" "cmake-format" "credo" "deadnix" "denofmt" "denolint" "dune-fmt" "eclint" "eslint" "flake8" "flynt" "headache" "hlint" "hpack" "isort" "latexindent" "lua-ls" "lychee" "markdownlint" "mdl" "mkdocs-linkcheck" "mypy" "nixfmt" "ormolu" "php-cs-fixer" "phpcbf" "phpcs" "phpstan" "prettier" "psalm" "pylint" "pyright" "pyupgrade" "revive" "rome" "statix" "treefmt" "typos" "vale" "yamllint" ]; # PLEASE keep this sorted alphabetically. @@ -46,7 +46,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { check = mkOption { type = types.bool; @@ -82,7 +82,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { configPath = mkOption { type = types.str; description = lib.mdDoc "Path to the YAML configuration file."; @@ -102,7 +102,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { binPath = mkOption { type = types.str; @@ -126,7 +126,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { denyWarnings = mkOption { type = types.bool; description = lib.mdDoc "Fail when warnings are present"; @@ -149,7 +149,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { configPath = mkOption { type = types.str; description = lib.mdDoc "Path to the configuration file (.json,.python,.yaml)"; @@ -163,7 +163,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { strict = mkOption { type = types.bool; @@ -177,7 +177,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { edit = mkOption { type = types.bool; @@ -233,7 +233,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { write = mkOption { type = types.bool; @@ -255,7 +255,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { format = mkOption { type = types.enum [ "default" "compact" "json" ]; @@ -278,7 +278,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { auto-promote = mkOption { type = types.bool; @@ -299,7 +299,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { fix = mkOption { type = types.bool; @@ -337,7 +337,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { binPath = mkOption { type = types.path; @@ -361,7 +361,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { binPath = mkOption { type = types.str; @@ -391,7 +391,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { aggressive = mkOption { type = types.bool; @@ -402,8 +402,8 @@ in mkOption { type = types.str; description = lib.mdDoc "flynt binary path. Can be used to specify the flynt binary from an existing Python environment."; - default = "${settings.flynt.package}/bin/flynt"; - defaultText = "\${settings.flynt.package}/bin/flynt"; + default = "${hooks.flynt.package}/bin/flynt"; + defaultText = "\${hooks.flynt.package}/bin/flynt"; }; dry-run = mkOption { @@ -453,13 +453,12 @@ in description = lib.mdDoc "Replace string concatenations with f-strings."; default = false; }; - # TODO: clashes with hook setting - # verbose = - # mkOption { - # type = types.bool; - # description = lib.mdDoc "Run with verbose output."; - # default = false; - # }; + verbose = + mkOption { + type = types.bool; + description = lib.mdDoc "Run with verbose output."; + default = false; + }; }; }; }; @@ -467,7 +466,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { header-file = mkOption { type = types.str; description = lib.mdDoc "Path to the header file."; @@ -480,7 +479,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { hintFile = mkOption { type = types.nullOr types.path; @@ -494,7 +493,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { silent = mkOption { type = types.bool; @@ -508,7 +507,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { profile = mkOption { type = types.enum [ "" "black" "django" "pycharm" "google" "open_stack" "plone" "attrs" "hug" "wemake" "appnexus" ]; @@ -528,7 +527,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { flags = mkOption { type = types.str; @@ -542,7 +541,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { checklevel = mkOption { type = types.enum [ "Error" "Warning" "Information" "Hint" ]; description = lib.mdDoc @@ -562,7 +561,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { configPath = mkOption { type = types.str; @@ -582,7 +581,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { config = mkOption { type = types.attrs; @@ -597,7 +596,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { configPath = mkOption { type = types.str; @@ -664,13 +663,12 @@ in description = lib.mdDoc "Markdown rules to use for linting containing the given tags. Per default all rules are processed."; default = [ ]; }; - # TODO: clases with hook setting - # verbose = - # mkOption { - # type = types.bool; - # description = lib.mdDoc "Increase verbosity."; - # default = false; - # }; + verbose = + mkOption { + type = types.bool; + description = lib.mdDoc "Increase verbosity."; + default = false; + }; }; }; }; @@ -678,7 +676,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { binPath = mkOption { type = types.path; @@ -730,7 +728,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { binPath = mkOption { type = types.str; @@ -747,7 +745,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { width = mkOption { type = types.nullOr types.int; @@ -761,7 +759,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { defaultExtensions = mkOption { type = types.listOf types.str; @@ -781,7 +779,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { binPath = mkOption { type = types.str; @@ -798,7 +796,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { binPath = mkOption { type = types.str; @@ -815,7 +813,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { binPath = mkOption { type = types.str; @@ -832,7 +830,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { binPath = mkOption { type = types.str; @@ -851,7 +849,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { binPath = mkOption { description = lib.mdDoc @@ -1094,7 +1092,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { binPath = mkOption { type = types.str; @@ -1111,7 +1109,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { binPath = mkOption { type = types.str; @@ -1140,7 +1138,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { binPath = mkOption { type = types.str; @@ -1157,7 +1155,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { binPath = mkOption { type = types.str; @@ -1174,7 +1172,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { configPath = mkOption { type = types.str; @@ -1190,7 +1188,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { binPath = mkOption { type = types.path; @@ -1220,7 +1218,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { format = mkOption { type = types.enum [ "stderr" "errfmt" "json" ]; @@ -1242,7 +1240,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { # package = mkOption { # type = types.package; # description = lib.mdDoc @@ -1275,7 +1273,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { color = mkOption { type = types.enum [ "auto" "always" "never" ]; @@ -1357,7 +1355,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { config = mkOption { type = types.str; @@ -1388,7 +1386,7 @@ in description = ""; type = types.submodule { imports = hookModule; - options = { + options.settings = { relaxed = mkOption { type = types.bool; description = lib.mdDoc "Whether to use the relaxed configuration."; @@ -1426,7 +1424,7 @@ in entry = let cmdArgs = - mkCmdArgs (with settings.alejandra; [ + mkCmdArgs (with hooks.alejandra.settings; [ [ check "--check" ] [ (exclude != [ ]) "--exclude ${lib.escapeShellArgs (lib.unique exclude)}" ] [ (verbosity == "quiet") "-q" ] @@ -1434,7 +1432,7 @@ in [ (threads != null) "--threads ${toString threads}" ] ]); in - "${settings.alejandra.package}/bin/alejandra ${cmdArgs}"; + "${hooks.alejandra.package}/bin/alejandra ${cmdArgs}"; files = "\\.nix$"; }; annex = @@ -1452,17 +1450,17 @@ in let cmdArgs = mkCmdArgs [ - [ (settings.ansible-lint.configPath != "") "-c ${settings.ansible-lint.configPath}" ] + [ (hooks.ansible-lint.settings.configPath != "") "-c ${hooks.ansible-lint.settings.configPath}" ] ]; in "${tools.ansible-lint}/bin/ansible-lint ${cmdArgs}"; - files = if settings.ansible-lint.subdir != "" then "${settings.ansible-lint.subdir}/" else ""; + 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."; - entry = "${settings.autoflake.binPath} ${settings.autoflake.flags}"; + entry = "${hooks.autoflake.settings.binPath} ${hooks.autoflake.settings.flags}"; types = [ "python" ]; }; bats = @@ -1568,7 +1566,7 @@ in { name = "clippy"; description = "Lint Rust code."; - entry = "${wrapper}/bin/cargo-clippy clippy ${cargoManifestPathArg} ${lib.optionalString settings.clippy.offline "--offline"} ${lib.optionalString settings.clippy.allFeatures "--all-features"} -- ${lib.optionalString settings.clippy.denyWarnings "-D warnings"}"; + entry = "${wrapper}/bin/cargo-clippy clippy ${cargoManifestPathArg} ${lib.optionalString hooks.clippy.settings.offline "--offline"} ${lib.optionalString hooks.clippy.settings.allFeatures "--all-features"} -- ${lib.optionalString hooks.clippy.settings.denyWarnings "-D warnings"}"; files = "\\.rs$"; pass_filenames = false; }; @@ -1586,10 +1584,10 @@ in entry = let maybeConfigPath = - if settings.cmake-format.configPath == "" + if hooks.cmake-format.settings.configPath == "" # Searches automatically for the config path. then "" - else "-C ${settings.cmake-format.configPath}"; + else "-C ${hooks.cmake-format.settings.configPath}"; in "${tools.cmake-format}/bin/cmake-format --check ${maybeConfigPath}"; files = "\\.cmake$|CMakeLists.txt"; @@ -1628,7 +1626,7 @@ in name = "credo"; description = "Runs a static code analysis using Credo"; entry = - let strict = if settings.credo.strict then "--strict" else ""; + let strict = if hooks.credo.settings.strict then "--strict" else ""; in "${pkgs.elixir}/bin/mix credo"; files = "\\.exs?$"; }; @@ -1651,7 +1649,7 @@ in entry = let cmdArgs = - mkCmdArgs (with settings.deadnix; [ + mkCmdArgs (with hooks.deadnix.settings; [ [ noLambdaArg "--no-lambda-arg" ] [ noLambdaPatternNames "--no-lambda-pattern-names" ] [ noUnderscore "--no-underscore" ] @@ -1673,8 +1671,8 @@ in let cmdArgs = mkCmdArgs [ - [ (!settings.denofmt.write) "--check" ] - [ (settings.denofmt.configPath != "") "-c ${settings.denofmt.configPath}" ] + [ (!hooks.denofmt.settings.write) "--check" ] + [ (hooks.denofmt.settings.configPath != "") "-c ${hooks.denofmt.settings.configPath}" ] ]; in "${tools.deno}/bin/deno fmt ${cmdArgs}"; @@ -1688,9 +1686,9 @@ in let cmdArgs = mkCmdArgs [ - [ (settings.denolint.format == "compact") "--compact" ] - [ (settings.denolint.format == "json") "--json" ] - [ (settings.denolint.configPath != "") "-c ${settings.denolint.configPath}" ] + [ (hooks.denolint.settings.format == "compact") "--compact" ] + [ (hooks.denolint.settings.format == "json") "--json" ] + [ (hooks.denolint.settings.configPath != "") "-c ${hooks.denolint.settings.configPath}" ] ]; in "${tools.deno}/bin/deno lint ${cmdArgs}"; @@ -1712,10 +1710,10 @@ in description = "Runs Dune's formatters on the code tree."; entry = let - auto-promote = if settings.dune-fmt.auto-promote then "--auto-promote" else ""; + auto-promote = if hooks.dune-fmt.settings.auto-promote then "--auto-promote" else ""; run-dune-fmt = pkgs.writeShellApplication { name = "run-dune-fmt"; - runtimeInputs = settings.dune-fmt.extraRuntimeInputs; + runtimeInputs = hooks.dune-fmt.settings.extraRuntimeInputs; text = "${tools.dune-fmt}/bin/dune-fmt ${auto-promote}"; }; in @@ -1742,7 +1740,7 @@ in let cmdArgs = mkCmdArgs - (with settings.eclint; [ + (with hooks.eclint.settings; [ [ fix "-fix" ] [ summary "-summary" ] [ (color != "auto") "-color ${color}" ] @@ -1750,7 +1748,7 @@ in [ (verbosity != 0) "-verbosity ${toString verbosity}" ] ]); in - "${settings.eclint.package}/bin/eclint ${cmdArgs}"; + "${hooks.eclint.package}/bin/eclint ${cmdArgs}"; }; editorconfig-checker = { @@ -1787,20 +1785,20 @@ in { name = "eslint"; description = "Find and fix problems in your JavaScript code."; - entry = "${settings.eslint.binPath} --fix"; - files = "${settings.eslint.extensions}"; + entry = "${hooks.eslint.settings.binPath} --fix"; + files = "${hooks.eslint.settings.extensions}"; }; flake8 = let extendIgnoreStr = - if lib.lists.length settings.flake8.extendIgnore > 0 - then "--extend-ignore " + builtins.concatStringsSep "," settings.flake8.extendIgnore + 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."; - entry = "${settings.flake8.binPath} --format ${settings.flake8.format} ${extendIgnoreStr}"; + entry = "${hooks.flake8.settings.binPath} --format ${hooks.flake8.settings.format} ${extendIgnoreStr}"; types = [ "python" ]; }; flynt = @@ -1811,7 +1809,7 @@ in entry = let cmdArgs = - mkCmdArgs (with settings.flynt; [ + mkCmdArgs (with hooks.flynt.settings; [ [ aggressive "--aggressive" ] [ dry-run "--dry-run" ] [ (exclude != [ ]) "--exclude ${lib.escapeShellArgs exclude}" ] @@ -1824,7 +1822,7 @@ in [ verbose "--verbose" ] ]); in - "${settings.flynt.binPath} ${cmdArgs}"; + "${hooks.flynt.settings.binPath} ${cmdArgs}"; types = [ "python" ]; }; fourmolu = @@ -1833,7 +1831,7 @@ in description = "Haskell code prettifier."; entry = "${tools.fourmolu}/bin/fourmolu --mode inplace ${ - lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) settings.ormolu.defaultExtensions) + lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormolu.settings.defaultExtensions) }"; files = "\\.l?hs(-boot)?$"; }; @@ -1980,7 +1978,7 @@ in lib.throwIf (tools.headache == null) "The version of nixpkgs used by pre-commit-hooks.nix does not have `ocamlPackages.headache`. Please use a more recent version of nixpkgs." - "${tools.headache}/bin/headache -h ${settings.headache.header-file}"; + "${tools.headache}/bin/headache -h ${hooks.headache.settings.header-file}"; }; hindent = { @@ -1994,7 +1992,7 @@ in name = "hlint"; description = "HLint gives suggestions on how to improve your source code."; - entry = "${tools.hlint}/bin/hlint${if settings.hlint.hintFile == null then "" else " --hint=${settings.hlint.hintFile}"}"; + entry = "${tools.hlint}/bin/hlint${if hooks.hlint.settings.hintFile == null then "" else " --hint=${hooks.hlint.settings.hintFile}"}"; files = "\\.l?hs(-boot)?$"; }; hpack = @@ -2002,7 +2000,7 @@ in name = "hpack"; description = "`hpack` converts package definitions in the hpack format (`package.yaml`) to Cabal files."; - entry = "${tools.hpack-dir}/bin/hpack-dir --${if settings.hpack.silent then "silent" else "verbose"}"; + entry = "${tools.hpack-dir}/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: @@ -2037,11 +2035,11 @@ in let cmdArgs = mkCmdArgs - (with settings.isort; [ + (with hooks.isort.settings; [ [ (profile != "") " --profile ${profile}" ] ]); in - "${tools.isort}/bin/isort${cmdArgs} ${settings.isort.flags}"; + "${tools.isort}/bin/isort${cmdArgs} ${hooks.isort.settings.flags}"; }; juliaformatter = { @@ -2068,13 +2066,13 @@ in name = "latexindent"; description = "Perl script to add indentation to LaTeX files."; types = [ "file" "tex" ]; - entry = "${tools.latexindent}/bin/latexindent ${settings.latexindent.flags}"; + entry = "${tools.latexindent}/bin/latexindent ${hooks.latexindent.settings.flags}"; }; 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 settings.lua-ls.config); + luarc = pkgs.writeText ".luarc.json" (builtins.toJSON hooks.lua-ls.settings.config); luarc-dir = pkgs.stdenv.mkDerivation { name = "luarc"; unpackPhase = "true"; @@ -2091,7 +2089,7 @@ in set -e export logpath="$(mktemp -d)" lua-language-server --check $(realpath .) \ - --checklevel="${settings.lua-ls.checklevel}" \ + --checklevel="${hooks.lua-ls.settings.checklevel}" \ --configpath="${luarc-dir}/.luarc.json" \ --logpath="$logpath" if [[ -f $logpath/check.json ]]; then @@ -2123,18 +2121,18 @@ in let cmdArgs = mkCmdArgs - (with settings.lychee; [ + (with hooks.lychee.settings; [ [ (configPath != "") " --config ${configPath}" ] ]); in - "${pkgs.lychee}/bin/lychee${cmdArgs} ${settings.lychee.flags}"; + "${pkgs.lychee}/bin/lychee${cmdArgs} ${hooks.lychee.settings.flags}"; types = [ "text" ]; }; markdownlint = { name = "markdownlint"; description = "Style checker and linter for markdown files."; - entry = "${tools.markdownlint-cli}/bin/markdownlint -c ${pkgs.writeText "markdownlint.json" (builtins.toJSON settings.markdownlint.config)}"; + entry = "${tools.markdownlint-cli}/bin/markdownlint -c ${pkgs.writeText "markdownlint.json" (builtins.toJSON hooks.markdownlint.settings.config)}"; files = "\\.md$"; }; mdl = @@ -2146,7 +2144,7 @@ in let cmdArgs = mkCmdArgs - (with settings.mdl; [ + (with hooks.mdl.settings; [ [ (configPath != "") "--config ${configPath}" ] [ git-recurse "--git-recurse" ] [ ignore-front-matter "--ignore-front-matter" ] @@ -2161,7 +2159,7 @@ in [ verbose "--verbose" ] ]); in - "${settings.mdl.package}/bin/mdl ${cmdArgs}"; + "${hooks.mdl.package}/bin/mdl ${cmdArgs}"; files = "\\.md$"; }; mdsh = @@ -2197,7 +2195,7 @@ in let cmdArgs = mkCmdArgs - (with settings.mkdocs-linkcheck; [ + (with hooks.mkdocs-linkcheck.settings; [ [ local-only " --local" ] [ recurse " --recurse" ] [ (extension != "") " --ext ${extension}" ] @@ -2205,14 +2203,14 @@ in [ (path != "") " ${path}" ] ]); in - "${settings.mkdocs-linkcheck.binPath}${cmdArgs}"; + "${hooks.mkdocs-linkcheck.settings.binPath}${cmdArgs}"; types = [ "text" "markdown" ]; }; mypy = { name = "mypy"; description = "Static type checker for Python"; - entry = settings.mypy.binPath; + entry = hooks.mypy.settings.binPath; files = "\\.py$"; }; nil = @@ -2245,7 +2243,7 @@ in { name = "nixfmt"; description = "Nix code prettifier."; - entry = "${tools.nixfmt}/bin/nixfmt ${lib.optionalString (settings.nixfmt.width != null) "--width=${toString settings.nixfmt.width}"}"; + entry = "${tools.nixfmt}/bin/nixfmt ${lib.optionalString (hooks.nixfmt.settings.width != null) "--width=${toString hooks.nixfmt.settings.width}"}"; files = "\\.nix$"; }; nixpkgs-fmt = @@ -2276,9 +2274,9 @@ in entry = let extensions = - lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) settings.ormolu.defaultExtensions); + lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormolu.settings.defaultExtensions); cabalExtensions = - if settings.ormolu.cabalDefaultExtensions then "--cabal-default-extensions" else ""; + if hooks.ormolu.settings.cabalDefaultExtensions then "--cabal-default-extensions" else ""; in "${tools.ormolu}/bin/ormolu --mode inplace ${extensions} ${cabalExtensions}"; files = "\\.l?hs(-boot)?$"; @@ -2287,7 +2285,7 @@ in { name = "php-cs-fixer"; description = "Lint PHP files."; - entry = with settings.php-cs-fixer; + entry = with hooks.php-cs-fixer.settings; "${binPath} fix"; types = [ "php" ]; }; @@ -2295,7 +2293,7 @@ in { name = "phpcbf"; description = "Lint PHP files."; - entry = with settings.phpcbf; + entry = with hooks.phpcbf.settings; "${binPath}"; types = [ "php" ]; }; @@ -2303,7 +2301,7 @@ in { name = "phpcs"; description = "Lint PHP files."; - entry = with settings.phpcs; + entry = with hooks.phpcs.settings; "${binPath}"; types = [ "php" ]; }; @@ -2311,7 +2309,7 @@ in { name = "phpstan"; description = "Static Analysis of PHP files."; - entry = with settings.phpstan; + entry = with hooks.phpstan.settings; "${binPath} analyse"; types = [ "php" ]; }; @@ -2340,7 +2338,7 @@ in let cmdArgs = mkCmdArgs - (with settings.prettier; [ + (with hooks.prettier.settings; [ [ (allow-parens != "always") "--allow-parens ${allow-parens}" ] [ bracket-same-line "--bracket-same-line" ] [ cache "--cache" ] @@ -2380,13 +2378,13 @@ in [ write "--write" ] ]); in - "${settings.prettier.binPath} ${cmdArgs}"; + "${hooks.prettier.settings.binPath} ${cmdArgs}"; }; psalm = { name = "psalm"; description = "Static Analysis of PHP files."; - entry = with settings.psalm; + entry = with hooks.psalm.settings; "${binPath}"; types = [ "php" ]; }; @@ -2408,7 +2406,7 @@ in { name = "pylint"; description = "Lint Python files."; - entry = with settings.pylint; + entry = with hooks.pylint.settings; "${binPath} ${lib.optionalString reports "-ry"} ${lib.optionalString (! score) "-sn"}"; types = [ "python" ]; }; @@ -2416,14 +2414,14 @@ in { name = "pyright"; description = "Static type checker for Python"; - entry = settings.pyright.binPath; + entry = hooks.pyright.settings.binPath; files = "\\.py$"; }; pyupgrade = { name = "pyupgrade"; description = "Automatically upgrade syntax for newer versions."; - entry = with settings.pyupgrade; + entry = with hooks.pyupgrade.settings; "${binPath}"; types = [ "python" ]; }; @@ -2436,7 +2434,7 @@ in cmdArgs = mkCmdArgs [ [ true "-set_exit_status" ] - [ (settings.revive.configPath != "") "-config ${settings.revive.configPath}" ] + [ (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 @@ -2464,11 +2462,11 @@ in let cmdArgs = mkCmdArgs [ - [ (settings.rome.write) "--apply" ] - [ (settings.rome.configPath != "") "--config-path ${settings.rome.configPath}" ] + [ (hooks.rome.settings.write) "--apply" ] + [ (hooks.rome.settings.configPath != "") "--config-path ${hooks.rome.settings.configPath}" ] ]; in - "${settings.rome.binPath} check ${cmdArgs}"; + "${hooks.rome.settings.binPath} check ${cmdArgs}"; }; ruff = { @@ -2539,7 +2537,7 @@ in { name = "statix"; description = "Lints and suggestions for the Nix programming language."; - entry = with settings.statix; + entry = with hooks.statix.settings; "${tools.statix}/bin/statix check -o ${format} ${if (ignore != [ ]) then "-i ${lib.escapeShellArgs (lib.unique ignore)}" else ""}"; files = "\\.nix$"; pass_filenames = false; @@ -2621,7 +2619,7 @@ in description = "One CLI to format the code tree."; types = [ "file" ]; pass_filenames = true; - entry = "${settings.treefmt.package}/bin/treefmt --fail-on-change"; + entry = "${hooks.treefmt.package}/bin/treefmt --fail-on-change"; }; typos = { @@ -2629,10 +2627,10 @@ in description = "Source code spell checker"; entry = let - configFile = builtins.toFile "config.toml" "${settings.typos.config}"; + configFile = builtins.toFile "config.toml" "${hooks.typos.settings.config}"; cmdArgs = mkCmdArgs - (with settings.typos; [ + (with hooks.typos.settings; [ [ (color != "") "--color ${color}" ] [ (configPath != "") "--config ${configPath}" ] [ (config != "" && configPath == "") "--config ${configFile}" ] @@ -2642,7 +2640,7 @@ in [ (write && !diff) "--write-changes" ] ]); in - "${tools.typos}/bin/typos ${cmdArgs}${lib.optionalString settings.typos.diff " --diff"}${lib.optionalString settings.typos.hidden " --hidden"}"; + "${tools.typos}/bin/typos ${cmdArgs}${lib.optionalString hooks.typos.settings.diff " --diff"}${lib.optionalString settings.typos.hidden " --hidden"}"; types = [ "text" ]; # Typos is supposed to run on the whole tree. If this is set to true, # the system gets stuck for large projects due to very high memory @@ -2662,15 +2660,15 @@ in entry = let # TODO: was .vale.ini, throwed error in Nix - configFile = builtins.toFile "vale.ini" "${settings.vale.config}"; + configFile = builtins.toFile "vale.ini" "${hooks.vale.settings.config}"; cmdArgs = mkCmdArgs - (with settings.vale; [ + (with hooks.vale.settings; [ [ (configPath != "") " --config ${configPath}" ] [ (config != "" && configPath == "") " --config ${configFile}" ] ]); in - "${pkgs.vale}/bin/vale${cmdArgs} ${settings.vale.flags}"; + "${pkgs.vale}/bin/vale${cmdArgs} ${hooks.vale.settings.flags}"; types = [ "text" ]; }; yamllint = @@ -2682,8 +2680,8 @@ in let cmdArgs = mkCmdArgs [ - [ (settings.yamllint.relaxed) "-d relaxed" ] - [ (settings.yamllint.configPath != "") "-c ${settings.yamllint.configPath}" ] + [ (hooks.yamllint.settings.relaxed) "-d relaxed" ] + [ (hooks.yamllint.settings.configPath != "") "-c ${hooks.yamllint.settings.configPath}" ] ]; in "${tools.yamllint}/bin/yamllint ${cmdArgs}";