1diff --git a/misc/makerelease/makerelease.go b/misc/makerelease/makerelease.go
2index 3b511b1..a46ebd8 100644
3--- a/misc/makerelease/makerelease.go
4+++ b/misc/makerelease/makerelease.go
5@@ -65,9 +65,6 @@ const (
6 // These must be the command that cmd/go knows to install to $GOROOT/bin
7 // or $GOROOT/pkg/tool.
8 var toolPaths = []string{
9- "golang.org/x/tools/cmd/cover",
10- "golang.org/x/tools/cmd/godoc",
11- "golang.org/x/tools/cmd/vet",
12 }
13
14 var preBuildCleanFiles = []string{
15diff --git a/src/cmd/dist/build.c b/src/cmd/dist/build.c
16index b6c61b4..2006bc2 100644
17--- a/src/cmd/dist/build.c
18+++ b/src/cmd/dist/build.c
19@@ -210,7 +210,9 @@ init(void)
20 workdir = xworkdir();
21 xatexit(rmworkdir);
22
23- bpathf(&b, "%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch);
24+ xgetenv(&b, "GOTOOLDIR");
25+ if (b.len == 0)
26+ bpathf(&b, "%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch);
27 tooldir = btake(&b);
28
29 bfree(&b);
30diff --git a/src/cmd/go/pkg.go b/src/cmd/go/pkg.go
31index b71feb7..8468ea8 100644
32--- a/src/cmd/go/pkg.go
33+++ b/src/cmd/go/pkg.go
34@@ -401,9 +401,9 @@ var goTools = map[string]targetDir{
35 "cmd/pack": toTool,
36 "cmd/pprof": toTool,
37 "cmd/yacc": toTool,
38- "golang.org/x/tools/cmd/cover": toTool,
39- "golang.org/x/tools/cmd/godoc": toBin,
40- "golang.org/x/tools/cmd/vet": toTool,
41+ "nixos.org/x/tools/cmd/cover": toTool,
42+ "nixos.org/x/tools/cmd/godoc": toBin,
43+ "nixos.org/x/tools/cmd/vet": toTool,
44 "code.google.com/p/go.tools/cmd/cover": stalePath,
45 "code.google.com/p/go.tools/cmd/godoc": stalePath,
46 "code.google.com/p/go.tools/cmd/vet": stalePath,
47diff --git a/src/go/build/build.go b/src/go/build/build.go
48index 311ecb0..f151d8f 100644
49--- a/src/go/build/build.go
50+++ b/src/go/build/build.go
51@@ -1367,7 +1367,7 @@ func init() {
52 }
53
54 // ToolDir is the directory containing build tools.
55-var ToolDir = filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
56+var ToolDir = runtime.GOTOOLDIR()
57
58 // IsLocalImport reports whether the import path is
59 // a local import path, like ".", "..", "./foo", or "../foo".
60diff --git a/src/runtime/extern.go b/src/runtime/extern.go
61index 6cc5df8..9a9a964 100644
62--- a/src/runtime/extern.go
63+++ b/src/runtime/extern.go
64@@ -152,6 +152,17 @@ func GOROOT() string {
65 return defaultGoroot
66 }
67
68+// GOTOOLDIR returns the root of the Go tree.
69+// It uses the GOTOOLDIR environment variable, if set,
70+// or else the root used during the Go build.
71+func GOTOOLDIR() string {
72+ s := gogetenv("GOTOOLDIR")
73+ if s != "" {
74+ return s
75+ }
76+ return GOROOT() + "/pkg/tool/" + GOOS + "_" + GOARCH
77+}
78+
79 // Version returns the Go tree's version string.
80 // It is either the commit hash and date at the time of the build or,
81 // when possible, a release tag like "go1.3".