1diff --git a/src/cmd/go/pkg.go b/src/cmd/go/pkg.go
2index 61e3d8d..b8422ad 100644
3--- a/src/cmd/go/pkg.go
4+++ b/src/cmd/go/pkg.go
5@@ -678,7 +678,7 @@ var goTools = map[string]targetDir{
6 "cmd/trace": toTool,
7 "cmd/vet": toTool,
8 "cmd/yacc": toTool,
9- "golang.org/x/tools/cmd/godoc": toBin,
10+ "nixos.org/x/tools/cmd/godoc": toBin,
11 "code.google.com/p/go.tools/cmd/cover": stalePath,
12 "code.google.com/p/go.tools/cmd/godoc": stalePath,
13 "code.google.com/p/go.tools/cmd/vet": stalePath,
14diff --git a/src/go/build/build.go b/src/go/build/build.go
15index 496fe11..8c81dbd 100644
16--- a/src/go/build/build.go
17+++ b/src/go/build/build.go
18@@ -1388,7 +1388,7 @@ func init() {
19 }
20
21 // ToolDir is the directory containing build tools.
22-var ToolDir = filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
23+var ToolDir = runtime.GOTOOLDIR()
24
25 // IsLocalImport reports whether the import path is
26 // a local import path, like ".", "..", "./foo", or "../foo".
27diff --git a/src/runtime/extern.go b/src/runtime/extern.go
28index d346362..fb22b6e 100644
29--- a/src/runtime/extern.go
30+++ b/src/runtime/extern.go
31@@ -194,6 +194,17 @@ func GOROOT() string {
32 return defaultGoroot
33 }
34
35+// GOTOOLDIR returns the root of the Go tree.
36+// It uses the GOTOOLDIR environment variable, if set,
37+// or else the root used during the Go build.
38+func GOTOOLDIR() string {
39+ s := gogetenv("GOTOOLDIR")
40+ if s != "" {
41+ return s
42+ }
43+ return GOROOT() + "/pkg/tool/" + GOOS + "_" + GOARCH
44+}
45+
46 // Version returns the Go tree's version string.
47 // It is either the commit hash and date at the time of the build or,
48 // when possible, a release tag like "go1.3".