|
22 | 22 |
|
23 | 23 | { |
24 | 24 | git-hooks.hooks = { |
25 | | - # lint shell scripts |
| 25 | + # Format Nix code |
| 26 | + nixfmt.enable = true; |
| 27 | +
|
| 28 | + # Format Python code |
| 29 | + black.enable = true; |
| 30 | +
|
| 31 | + # Lint shell scripts |
26 | 32 | shellcheck.enable = true; |
27 | | - # execute example shell from Markdown files |
| 33 | +
|
| 34 | + # Execute shell examples in Markdown files |
28 | 35 | mdsh.enable = true; |
29 | | - # format Python code |
30 | | - black.enable = true; |
31 | 36 |
|
32 | | - # override a package with a different version |
| 37 | + # Override a package with a different version |
33 | 38 | ormolu.enable = true; |
34 | 39 | ormolu.package = pkgs.haskellPackages.ormolu; |
35 | 40 |
|
36 | | - # some hooks have more than one package, like clippy: |
| 41 | + # Some hooks have more than one package, like clippy: |
37 | 42 | clippy.enable = true; |
38 | 43 | clippy.packageOverrides.cargo = pkgs.cargo; |
39 | 44 | clippy.packageOverrides.clippy = pkgs.clippy; |
40 | | - # some hooks provide settings |
| 45 | + # Some hooks provide settings |
41 | 46 | clippy.settings.allFeatures = true; |
| 47 | +
|
| 48 | + # Define your own custom hooks |
| 49 | + my-custom-hook = { |
| 50 | + name = "My own hook"; |
| 51 | + exec = "on-pre-commit.sh"; |
| 52 | + }; |
42 | 53 | }; |
43 | 54 | } |
44 | 55 | ``` |
@@ -89,7 +100,7 @@ Given the following `flake.nix` example: |
89 | 100 | pre-commit-check = inputs.git-hooks.lib.${system}.run { |
90 | 101 | src = ./.; |
91 | 102 | hooks = { |
92 | | - nixfmt-rfc-style.enable = true; |
| 103 | + nixfmt.enable = true; |
93 | 104 | }; |
94 | 105 | }; |
95 | 106 | }); |
@@ -371,6 +382,7 @@ use nix |
371 | 382 | - [deadnix](https://github.com/astro/deadnix) |
372 | 383 | - [flake-checker](https://github.com/DeterminateSystems/flake-checker) |
373 | 384 | - [nil](https://github.com/oxalica/nil) |
| 385 | +- [nixfmt](https://github.com/NixOS/nixfmt/) (supports `nixfmt` >=v1.0) |
374 | 386 | - [nixfmt-classic](https://github.com/NixOS/nixfmt/tree/v0.6.0) |
375 | 387 | - [nixfmt-rfc-style](https://github.com/NixOS/nixfmt/) |
376 | 388 | - [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) |
|
0 commit comments