1{ stdenv, lib, go, buildGoPackage, fetchgit, fetchhg, fetchbzr, fetchsvn }:
2
3buildGoPackage rec {
4 name = "gotools-${version}";
5 version = "20170807-${stdenv.lib.strings.substring 0 7 rev}";
6 rev = "5d2fd3ccab986d52112bf301d47a819783339d0e";
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 = "0r3fp7na6pg0bc5xfycjvv951f0vma1qfnpw5zy6l75yxm5r47kn";
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}