Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,22 @@ in
};
};
};
staticcheck = mkOption {
description = "staticcheck hook";
type = types.submodule ({ config, ... }: {
imports = [ hookModule ];
options.packageOverrides = {
go = mkOption {
type = types.package;
description = "The go package to use";
};
go-tools = mkOption {
type = types.package;
description = "The go-tools package to use";
};
};
});
};
statix = mkOption {
description = "statix hook";
type = types.submodule {
Expand Down Expand Up @@ -4018,11 +4034,18 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.fourm
files = "(\\.yaml$)|(\\.yml$)";
};
staticcheck =
let
inherit (hooks.staticcheck) packageOverrides;
wrapper = pkgs.runCommand "staticcheck-wrapped" { buildInputs = [ pkgs.makeWrapper ]; } ''
makeWrapper ${packageOverrides.go-tools}/bin/staticcheck $out/bin/staticcheck \
--prefix PATH : ${packageOverrides.go}/bin
'';
in
{
name = "staticcheck";
description = "State of the art linter for the Go programming language";
package = tools.go-tools;
# staticheck works with directories.
package = wrapper;
packageOverrides = { go = tools.go; go-tools = tools.go-tools; };
entry =
let
script = pkgs.writeShellScript "precommit-staticcheck" ''
Expand Down