diff --git a/default.nix b/default.nix index 4c52319..7af8da7 100644 --- a/default.nix +++ b/default.nix @@ -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} ''; }; }; diff --git a/npins/sources.json b/npins/sources.json index d94f97a..a3f67d4 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -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 -} \ No newline at end of file +} diff --git a/patches/00-git-hooks-nixfmt.patch b/patches/00-git-hooks-nixfmt.patch new file mode 100644 index 0000000..d9ec03a --- /dev/null +++ b/patches/00-git-hooks-nixfmt.patch @@ -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 +