Open knl opened 1 year ago
The go
version determined is here:
https://github.com/cachix/pre-commit-hooks.nix/blob/29dbe1efaa91c3a415d8b45d62d48325a4748816/modules/hooks.nix#L875
Which in turn, is passed in to the tools map here:
https://github.com/cachix/pre-commit-hooks.nix/blob/29dbe1efaa91c3a415d8b45d62d48325a4748816/nix/tools.nix#L64
Which comes from the pkgs.go
attribute.
Devenv language modules should probably override the tools.$LANG
package, with the .package
version specified.
@knl until the above is done, you can proceed with:
{ pkgs, config, lib, ... }:
{
languages.go.enable = true;
languages.go.package = pkgs.go_1_20;
pre-commit = {
tools = { go = lib.mkForce config.languages.go.package; };
hooks = {
govet.enable = true;
gofmt.enable = true;
gotest.enable = true;
};
};
}
Proof:
tail -n +3 .pre-commit-config.yaml | jq '.repos[0].hooks[] | .entry' | xargs grep go-1
/nix/store/hjrlnifv8509wy4pyqxnbpin8qyb7ffc-precommit-gofmt: if ! /nix/store/3wpbn0nv1yhb47njlb3z3vicj20cp2mj-go-1.20.2/bin/gofmt -l -w "$file" 2>&1
/nix/store/5mkhiyab4r3l59lgjlbfrzzs6jrq5rlj-precommit-gotest: /nix/store/3wpbn0nv1yhb47njlb3z3vicj20cp2mj-go-1.20.2/bin/go test "./$dir"
/nix/store/qsm3h7j7qx6h5finybcz3s8rxfrjgcfc-precommit-govet: /nix/store/3wpbn0nv1yhb47njlb3z3vicj20cp2mj-go-1.20.2/bin/go vet ./"$dir"
Languages should be setting pre-commit.tools
to match the versions.
It's now possible to set pre-commit.hooks.govet.package = pkgs...
, if someone wants to make a PR
Describe the bug
I have the following in my
devenv.nix
:When I run
devenv shell pre-commit run -a
, I get a bunch of error from govet in the form:If I look at the pre-commit script for govet, it has:
This is clearly not the right go version that I enabled in
devenv.nix
.To Reproduce Please provide an sscce by creating a gist using
devenv.nix
,devenv.yaml
and optionallydevenv.lock
.Version
Paste here the output of
$ devenv version
.