feat(git-hooks): Update

- Patch git-hooks.nix source to rename `nixfmt` to `nixfmt-classic` and
avoid annoying warnings when reloading the shell
This commit is contained in:
Tom Hubrecht 2024-07-29 16:49:23 +02:00
parent 60267b4ff6
commit 2cb6c24535
Signed by: thubrecht
SSH key fingerprint: SHA256:r+nK/SIcWlJ0zFZJGHtlAoRwq1Rm+WcKAm5ADYMoQPc
3 changed files with 75 additions and 31 deletions

View file

@ -41,25 +41,33 @@
}:
let
pre-commit-check = (import sources.pre-commit-hooks).run {
src = ./.;
git-checks =
(import (
pkgs.applyPatches {
name = "git-hooks.nix";
src = builtins.storePath sources.git-hooks;
patches = [ ./patches/00-git-hooks-nixfmt.patch ];
}
)).run
{
src = ./.;
hooks = {
# Nix Hooks
statix.enable = true;
deadnix.enable = true;
rfc101 = {
enable = true;
hooks = {
# Nix Hooks
statix.enable = true;
deadnix.enable = true;
rfc101 = {
enable = true;
name = "RFC-101 formatting";
entry = "${pkgs.lib.getExe pkgs.nixfmt-rfc-style}";
files = "\\.nix$";
name = "RFC-101 formatting";
entry = "${pkgs.lib.getExe pkgs.nixfmt-rfc-style}";
files = "\\.nix$";
};
# Misc Hooks
commitizen.enable = true;
};
};
# Misc Hooks
commitizen.enable = true;
};
};
in
{
@ -86,7 +94,7 @@ in
] ++ (import ./scripts { inherit pkgs; });
shellHook = ''
${pre-commit-check.shellHook}
${git-checks.shellHook}
'';
preferLocalBuild = true;
@ -96,7 +104,7 @@ in
name = "pre-commit-shell";
shellHook = ''
${pre-commit-check.shellHook}
${git-checks.shellHook}
'';
};
};

View file

@ -79,6 +79,18 @@
"url": null,
"hash": "1bashjbh71dqs32yld7ihw2vz0vrad73pc35crf3qck8ssgpzv7d"
},
"git-hooks": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "cachix",
"repo": "git-hooks.nix"
},
"branch": "master",
"revision": "0ff4381bbb8f7a52ca4a851660fc7a437a4c6e07",
"url": "https://github.com/cachix/git-hooks.nix/archive/0ff4381bbb8f7a52ca4a851660fc7a437a4c6e07.tar.gz",
"hash": "0bmgc731c5rvky6qxc4f6gvgyiic8dna5dv3j19kya86idf7wn0p"
},
"kadenios": {
"type": "Git",
"repository": {
@ -233,18 +245,6 @@
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-24.11pre647518.1afc5440469f/nixexprs.tar.xz",
"hash": "1y526xag5s2jyrs3w08pgwa8891zv2ibwl5jmkbr94x4vpyir8hz"
},
"pre-commit-hooks": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "cachix",
"repo": "pre-commit-hooks.nix"
},
"branch": "master",
"revision": "0ff4381bbb8f7a52ca4a851660fc7a437a4c6e07",
"url": "https://github.com/cachix/pre-commit-hooks.nix/archive/0ff4381bbb8f7a52ca4a851660fc7a437a4c6e07.tar.gz",
"hash": "0bmgc731c5rvky6qxc4f6gvgyiic8dna5dv3j19kya86idf7wn0p"
},
"signal-irc-bridge": {
"type": "Git",
"repository": {
@ -281,4 +281,4 @@
}
},
"version": 3
}
}

View file

@ -0,0 +1,36 @@
diff --git a/modules/hooks.nix b/modules/hooks.nix
index bb194ee..8505794 100644
--- a/modules/hooks.nix
+++ b/modules/hooks.nix
@@ -2848,7 +2848,7 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
{
name = "nixfmt";
description = "Nix code prettifier.";
- package = tools.nixfmt;
+ package = tools.nixfmt-classic;
entry = "${hooks.nixfmt.package}/bin/nixfmt ${lib.optionalString (hooks.nixfmt.settings.width != null) "--width=${toString hooks.nixfmt.settings.width}"}";
files = "\\.nix$";
};
diff --git a/nix/tools.nix b/nix/tools.nix
index 9bcc89d..9fec5d5 100644
--- a/nix/tools.nix
+++ b/nix/tools.nix
@@ -44,7 +44,7 @@
, mdl
, mdsh
, nil
-, nixfmt
+, nixfmt-classic
, nixpkgs-fmt
, nodePackages
, ocamlPackages
@@ -131,7 +131,7 @@ in
mdl
mdsh
nil
- nixfmt
+ nixfmt-classic
nixpkgs-fmt
ormolu
pre-commit-hook-ensure-sops