Skip to content

Commit d82a37a

Browse files
committed
Add nix fmt hook
fixes: cachix#287
1 parent 4e743a6 commit d82a37a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

modules/hooks.nix

+7
Original file line numberDiff line numberDiff line change
@@ -2894,6 +2894,13 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
28942894
builtins.toString script;
28952895
files = "\\.nix$";
28962896
};
2897+
nix-fmt =
2898+
{
2899+
name = "nix-fmt";
2900+
description = "Format Nix files using the formatter specified in your flake.";
2901+
package = tools.nix;
2902+
entry = "${hooks.nix-fmt.package}/bin/nix fmt";
2903+
};
28972904
# nixfmt was renamed to nixfmt-classic.
28982905
# The hook has been deprecated to free up the name for when the new RFC-style nixfmt becomes stable.
28992906
nixfmt = nixfmt-classic;

nix/tools.nix

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
, mdl
4545
, mdsh
4646
, nil
47+
, nix
4748
, nixfmt
4849
, nixfmt-classic ? null
4950
, nixfmt-rfc-style ? null
@@ -134,6 +135,7 @@ in
134135
mdl
135136
mdsh
136137
nil
138+
nix
137139
nixpkgs-fmt
138140
ormolu
139141
pre-commit-hook-ensure-sops

0 commit comments

Comments
 (0)