From 27f412e26b7ea2c358a5a6c19eb753675a697e05 Mon Sep 17 00:00:00 2001 From: William Phetsinorath Date: Sat, 22 Nov 2025 14:26:58 +0100 Subject: [PATCH] fix: staticcheck missing go bin when using nix flake check Signed-off-by: William Phetsinorath Change-Id: Ia9ddf457f964389171ca5fbc1110bb976a6a6964 --- modules/hooks.nix | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/modules/hooks.nix b/modules/hooks.nix index 9933d3a5..1cdbb8b9 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -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 { @@ -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" ''