nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 makeWrapper,
6 go,
7}:
8
9buildGoModule (finalAttrs: {
10 pname = "gotools";
11 version = "0.34.0";
12
13 # using GitHub instead of https://go.googlesource.com/tools because Gitiles UI is too basic to browse
14 src = fetchFromGitHub {
15 owner = "golang";
16 repo = "tools";
17 tag = "v${finalAttrs.version}";
18 hash = "sha256-C+P2JoD4NzSAkAQuA20bVrfLZrMHXekvXn8KPOM5Nj4=";
19 };
20
21 allowGoReference = true;
22 doCheck = false;
23
24 vendorHash = "sha256-UZNYHx5y+kRp3AJq6s4Wy+k789GDG7FBTSzCTorVjgg=";
25
26 nativeBuildInputs = [ makeWrapper ];
27
28 postPatch = ''
29 # The gopls folder contains a Go submodule which causes a build failure
30 # and lives in its own package named gopls.
31 rm -r gopls
32 # cmd/auth folder is similar and is scheduled to be removed https://github.com/golang/go/issues/70872
33 rm -r cmd/auth
34 '';
35
36 # Set GOTOOLDIR for derivations adding this to buildInputs
37 postInstall = ''
38 mkdir -p $out/nix-support
39 substitute ${./setup-hook.sh} $out/nix-support/setup-hook \
40 --subst-var-by bin $out
41 '';
42
43 postFixup = ''
44 wrapProgram $out/bin/goimports \
45 --suffix PATH : ${lib.makeBinPath [ go ]}
46 '';
47
48 meta = {
49 description = "Additional tools for Go development";
50 longDescription = ''
51 This package contains tools like: godoc, goimports, callgraph, digraph, stringer or toolstash.
52 '';
53 homepage = "https://go.googlesource.com/tools";
54 license = lib.licenses.bsd3;
55 maintainers = with lib.maintainers; [
56 SuperSandro2000
57 techknowlogick
58 ];
59 };
60})