Skip to content

Commit 27f412e

Browse files
committed
fix: staticcheck missing go bin when using nix flake check
Signed-off-by: William Phetsinorath <[email protected]> Change-Id: Ia9ddf457f964389171ca5fbc1110bb976a6a6964
1 parent 20e71a4 commit 27f412e

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

modules/hooks.nix

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,6 +1739,22 @@ in
17391739
};
17401740
};
17411741
};
1742+
staticcheck = mkOption {
1743+
description = "staticcheck hook";
1744+
type = types.submodule ({ config, ... }: {
1745+
imports = [ hookModule ];
1746+
options.packageOverrides = {
1747+
go = mkOption {
1748+
type = types.package;
1749+
description = "The go package to use";
1750+
};
1751+
go-tools = mkOption {
1752+
type = types.package;
1753+
description = "The go-tools package to use";
1754+
};
1755+
};
1756+
});
1757+
};
17421758
statix = mkOption {
17431759
description = "statix hook";
17441760
type = types.submodule {
@@ -4018,11 +4034,18 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.fourm
40184034
files = "(\\.yaml$)|(\\.yml$)";
40194035
};
40204036
staticcheck =
4037+
let
4038+
inherit (hooks.staticcheck) packageOverrides;
4039+
wrapper = pkgs.runCommand "staticcheck-wrapped" { buildInputs = [ pkgs.makeWrapper ]; } ''
4040+
makeWrapper ${packageOverrides.go-tools}/bin/staticcheck $out/bin/staticcheck \
4041+
--prefix PATH : ${packageOverrides.go}/bin
4042+
'';
4043+
in
40214044
{
40224045
name = "staticcheck";
40234046
description = "State of the art linter for the Go programming language";
4024-
package = tools.go-tools;
4025-
# staticheck works with directories.
4047+
package = wrapper;
4048+
packageOverrides = { go = tools.go; go-tools = tools.go-tools; };
40264049
entry =
40274050
let
40284051
script = pkgs.writeShellScript "precommit-staticcheck" ''

0 commit comments

Comments
 (0)