1{ stdenv, go, buildGoPackage, fetchgit }:
2
3buildGoPackage rec {
4 name = "gotools-unstable-${version}";
5 version = "2019-02-11";
6 rev = "44bee7e801e4a70b5fc9a91ff23830ab4df55d5e";
7
8 goPackagePath = "golang.org/x/tools";
9 goPackageAliases = [ "code.google.com/p/go.tools" ];
10
11 src = fetchgit {
12 inherit rev;
13 url = "https://go.googlesource.com/tools";
14 sha256 = "1y0k6a6vphd01l2mzdm14aqax4qyslgcbyzl6zkbilj55hfp97y4";
15 };
16
17 goDeps = ./deps.nix;
18
19 preConfigure = ''
20 # Make the builtin tools available here
21 mkdir -p $bin/bin
22 eval $(go env | grep GOTOOLDIR)
23 find $GOTOOLDIR -type f | while read x; do
24 ln -sv "$x" "$bin/bin"
25 done
26 export GOTOOLDIR=$bin/bin
27 '';
28
29 excludedPackages = "\\("
30 + stdenv.lib.concatStringsSep "\\|" ([ "testdata" ] ++ stdenv.lib.optionals (stdenv.lib.versionAtLeast go.meta.branch "1.5") [ "vet" "cover" ])
31 + "\\)";
32
33 # Do not copy this without a good reason for enabling
34 # In this case tools is heavily coupled with go itself and embeds paths.
35 allowGoReference = true;
36
37 # Set GOTOOLDIR for derivations adding this to buildInputs
38 postInstall = ''
39 mkdir -p $bin/nix-support
40 substituteAll ${../../go-modules/tools/setup-hook.sh} $bin/nix-support/setup-hook.tmp
41 cat $bin/nix-support/setup-hook.tmp >> $bin/nix-support/setup-hook
42 rm $bin/nix-support/setup-hook.tmp
43 '';
44}