From 2dee9e8b1503949b7f426d215866ff2b2491ae4f Mon Sep 17 00:00:00 2001 From: William Phetsinorath Date: Fri, 20 Sep 2024 17:11:44 +0000 Subject: [PATCH] Add nix fmt hook fixes: https://github.com/cachix/git-hooks.nix/issues/287 --- modules/hooks.nix | 9 ++++++++- nix/tools.nix | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/hooks.nix b/modules/hooks.nix index 10d2c577..e794ba3c 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -49,7 +49,7 @@ in ++ [ (mkRenamedOptionModule [ "settings" "rome" ] [ "hooks" "biome" "settings" ]) ] # Rename the remaining `settings.` to `hooks..settings` ++ map (name: mkRenamedOptionModule [ "settings" name ] [ "hooks" name "settings" ]) - [ "ansible-lint" "autoflake" "biome" "clippy" "cmake-format" "credo" "deadnix" "denofmt" "denolint" "dune-fmt" "eslint" "flake8" "headache" "hlint" "hpack" "isort" "latexindent" "lychee" "mkdocs-linkcheck" "mypy" "nixfmt" "ormolu" "php-cs-fixer" "phpcbf" "phpcs" "phpstan" "prettier" "psalm" "pylint" "pyright" "pyupgrade" "revive" "statix" ]; + [ "ansible-lint" "autoflake" "biome" "clippy" "cmake-format" "credo" "deadnix" "denofmt" "denolint" "dune-fmt" "eslint" "flake8" "headache" "hlint" "hpack" "isort" "latexindent" "lychee" "mkdocs-linkcheck" "mypy" "nix" "nixfmt" "ormolu" "php-cs-fixer" "phpcbf" "phpcs" "phpstan" "prettier" "psalm" "pylint" "pyright" "pyupgrade" "revive" "statix" ]; options.hookModule = lib.mkOption { type = types.deferredModule; @@ -2894,6 +2894,13 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol builtins.toString script; files = "\\.nix$"; }; + nix-fmt = + { + name = "nix-fmt"; + description = "Nix formatter."; + package = tools.nix; + entry = "${hooks.nix.package}/bin/nix fmt"; + }; # nixfmt was renamed to nixfmt-classic. # The hook has been deprecated to free up the name for when the new RFC-style nixfmt becomes stable. nixfmt = nixfmt-classic; diff --git a/nix/tools.nix b/nix/tools.nix index 10d97fc3..30e32d06 100644 --- a/nix/tools.nix +++ b/nix/tools.nix @@ -134,6 +134,7 @@ in mdl mdsh nil + nix nixpkgs-fmt ormolu pre-commit-hook-ensure-sops