Skip to content

Commit

Permalink
Merge pull request cachix#441 from therealpxc/trufflehog-module
Browse files Browse the repository at this point in the history
Add support for TruffleHog
  • Loading branch information
sandydoo authored Sep 19, 2024
2 parents 7570de7 + 0ec644c commit 4e743a6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
35 changes: 26 additions & 9 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3462,15 +3462,6 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
);
files = "(\\.json$)|(\\.toml$)|(\\.mli?$)";
};
trim-trailing-whitespace =
{
name = "trim-trailing-whitespace";
description = "Trim trailing whitespace.";
types = [ "text" ];
stages = [ "commit" "push" "manual" ];
package = tools.pre-commit-hooks;
entry = "${hooks.trim-trailing-whitespace.package}/bin/trailing-whitespace-fixer";
};
treefmt =
let
inherit (hooks.treefmt) packageOverrides settings;
Expand All @@ -3496,6 +3487,32 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
packageOverrides = { treefmt = tools.treefmt; };
entry = "${hooks.treefmt.package}/bin/treefmt --fail-on-change";
};
trim-trailing-whitespace =
{
name = "trim-trailing-whitespace";
description = "Trim trailing whitespace.";
types = [ "text" ];
stages = [ "commit" "push" "manual" ];
package = tools.pre-commit-hooks;
entry = "${hooks.trim-trailing-whitespace.package}/bin/trailing-whitespace-fixer";
};
trufflehog =
{
name = "trufflehog";
description = "Secrets scanner";
entry =
let
script = pkgs.writeShellScript "precommit-trufflehog" ''
set -e
${hooks.trufflehog.package}/bin/trufflehog --no-update git "file://$(git rev-parse --show-top-level)" --since-commit HEAD --only-verified --fail
'';
in
builtins.toString script;
package = tools.trufflehog;

# trufflehog expects to run across the whole repo, not particular files
pass_filenames = false;
};
typos =
{
name = "typos";
Expand Down
2 changes: 2 additions & 0 deletions nix/tools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
, texlive
, topiary ? null ## Added in nixpkgs on Dec 2, 2022
, treefmt
, trufflehog
, typos
, typstfmt
, typstyle ? null ## Add in nixpkgs added on commit 800ca60
Expand Down Expand Up @@ -152,6 +153,7 @@ in
taplo
topiary
treefmt
trufflehog
typos
typstfmt
typstyle
Expand Down

0 comments on commit 4e743a6

Please sign in to comment.