git.iko.soy/typeable/nixpkgs
on master help sign in
go: init 1.9 (and set as default)
commit3189b016470f68ccae2b76d0a15a5ccd4c60b523 authorCharles Strahan <charles@cstrahan.com> dateTue 5 Sep 2017, 16:24 (9 years ago) parent8706664
5 files changed+327−1
pkgs/development/compilers/go/1.9.nix+181 pkgs/development/compilers/go/remove-test-pie-1.9.patch+26 pkgs/development/compilers/go/remove-tools-1.9.patch+35 pkgs/development/compilers/go/ssl-cert-file-1.9.patch+80 pkgs/top-level/all-packages.nix+5−1
pkgs/development/compilers/go/1.9.nixnew file+181
@@ -0,0 +1,181 @@
1+{ stdenv, fetchFromGitHub, tzdata, iana-etc, go_bootstrap, runCommand, writeScriptBin
2+, perl, which, pkgconfig, patch, fetchpatch
3+, pcre, cacert, llvm
4+, Security, Foundation, bash
5+, makeWrapper, git, subversion, mercurial, bazaar }:
6+
7+let
8+
9+ inherit (stdenv.lib) optional optionals optionalString;
10+
11+ clangHack = writeScriptBin "clang" ''
12+ #!${stdenv.shell}
13+ exec ${stdenv.cc}/bin/clang "$@" 2> >(sed '/ld: warning:.*ignoring unexpected dylib file/ d' 1>&2)
14+ '';
15+
16+ goBootstrap = runCommand "go-bootstrap" {} ''
17+ mkdir $out
18+ cp -rf ${go_bootstrap}/* $out/
19+ chmod -R u+w $out
20+ find $out -name "*.c" -delete
21+ cp -rf $out/bin/* $out/share/go/bin/
22+ '';
23+
24+in
25+
26+stdenv.mkDerivation rec {
27+ name = "go-${version}";
28+ version = "1.9";
29+
30+ src = fetchFromGitHub {
31+ owner = "golang";
32+ repo = "go";
33+ rev = "go${version}";
34+ sha256 = "06k66x387r93m7d3bd5yzwdm8f8xc43cdjfamqldfc1v8ngak0y9";
35+ };
36+
37+ # perl is used for testing go vet
38+ nativeBuildInputs = [ perl which pkgconfig patch makeWrapper ];
39+ buildInputs = [ pcre ]
40+ ++ optionals stdenv.isLinux [ stdenv.glibc.out stdenv.glibc.static ];
41+ propagatedBuildInputs = optionals stdenv.isDarwin [ Security Foundation ];
42+
43+ hardeningDisable = [ "all" ];
44+
45+ prePatch = ''
46+ patchShebangs ./ # replace /bin/bash
47+
48+ # This source produces shell script at run time,
49+ # and thus it is not corrected by patchShebangs.
50+ substituteInPlace misc/cgo/testcarchive/carchive_test.go \
51+ --replace '#!/usr/bin/env bash' '#!${stdenv.shell}'
52+
53+ # Disabling the 'os/http/net' tests (they want files not available in
54+ # chroot builds)
55+ rm src/net/{listen,parse}_test.go
56+ rm src/syscall/exec_linux_test.go
57+
58+ # !!! substituteInPlace does not seems to be effective.
59+ # The os test wants to read files in an existing path. Just don't let it be /usr/bin.
60+ sed -i 's,/usr/bin,'"`pwd`", src/os/os_test.go
61+ sed -i 's,/bin/pwd,'"`type -P pwd`", src/os/os_test.go
62+ # Disable the unix socket test
63+ sed -i '/TestShutdownUnix/areturn' src/net/net_test.go
64+ # Disable the hostname test
65+ sed -i '/TestHostname/areturn' src/os/os_test.go
66+ # ParseInLocation fails the test
67+ sed -i '/TestParseInSydney/areturn' src/time/format_test.go
68+ # Remove the api check as it never worked
69+ sed -i '/src\/cmd\/api\/run.go/ireturn nil' src/cmd/dist/test.go
70+ # Remove the coverage test as we have removed this utility
71+ sed -i '/TestCoverageWithCgo/areturn' src/cmd/go/go_test.go
72+ # Remove the timezone naming test
73+ sed -i '/TestLoadFixed/areturn' src/time/time_test.go
74+ # Remove disable setgid test
75+ sed -i '/TestRespectSetgidDir/areturn' src/cmd/go/internal/work/build_test.go
76+ # Remove cert tests that conflict with NixOS's cert resolution
77+ sed -i '/TestEnvVars/areturn' src/crypto/x509/root_unix_test.go
78+
79+ sed -i 's,/etc/protocols,${iana-etc}/etc/protocols,' src/net/lookup_unix.go
80+ sed -i 's,/etc/services,${iana-etc}/etc/services,' src/net/port_unix.go
81+
82+ # Disable cgo lookup tests not works, they depend on resolver
83+ rm src/net/cgo_unix_test.go
84+
85+ '' + optionalString stdenv.isLinux ''
86+ sed -i 's,/usr/share/zoneinfo/,${tzdata}/share/zoneinfo/,' src/time/zoneinfo_unix.go
87+ '' + optionalString stdenv.isArm ''
88+ sed -i '/TestCurrent/areturn' src/os/user/user_test.go
89+ echo '#!/usr/bin/env bash' > misc/cgo/testplugin/test.bash
90+ '' + optionalString stdenv.isDarwin ''
91+ substituteInPlace src/race.bash --replace \
92+ "sysctl machdep.cpu.extfeatures | grep -qv EM64T" true
93+ sed -i 's,strings.Contains(.*sysctl.*,true {,' src/cmd/dist/util.go
94+ sed -i 's,"/etc","'"$TMPDIR"'",' src/os/os_test.go
95+ sed -i 's,/_go_os_test,'"$TMPDIR"'/_go_os_test,' src/os/path_test.go
96+
97+ sed -i '/TestChdirAndGetwd/areturn' src/os/os_test.go
98+ sed -i '/TestRead0/areturn' src/os/os_test.go
99+ sed -i '/TestNohup/areturn' src/os/signal/signal_test.go
100+ sed -i '/TestCurrent/areturn' src/os/user/user_test.go
101+ sed -i '/TestSystemRoots/areturn' src/crypto/x509/root_darwin_test.go
102+
103+ sed -i '/TestGoInstallRebuildsStalePackagesInOtherGOPATH/areturn' src/cmd/go/go_test.go
104+ sed -i '/TestBuildDashIInstallsDependencies/areturn' src/cmd/go/go_test.go
105+
106+ sed -i '/TestDisasmExtld/areturn' src/cmd/objdump/objdump_test.go
107+
108+ sed -i 's/unrecognized/unknown/' src/cmd/link/internal/ld/lib.go
109+ sed -i 's/unrecognized/unknown/' src/cmd/go/build.go
110+
111+ touch $TMPDIR/group $TMPDIR/hosts $TMPDIR/passwd
112+
113+ sed -i '1 a\exit 0' misc/cgo/errors/test.bash
114+ '';
115+
116+ patches =
117+ [ ./remove-tools-1.9.patch
118+ ./ssl-cert-file-1.9.patch
119+ ./creds-test.patch
120+ ./remove-test-pie-1.9.patch
121+ ];
122+
123+ postPatch = optionalString stdenv.isDarwin ''
124+ echo "substitute hardcoded dsymutil with ${llvm}/bin/llvm-dsymutil"
125+ substituteInPlace "src/cmd/link/internal/ld/lib.go" --replace dsymutil ${llvm}/bin/llvm-dsymutil
126+ '';
127+
128+ NIX_SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
129+
130+ GOOS = if stdenv.isDarwin then "darwin" else "linux";
131+ GOARCH = if stdenv.isDarwin then "amd64"
132+ else if stdenv.system == "i686-linux" then "386"
133+ else if stdenv.system == "x86_64-linux" then "amd64"
134+ else if stdenv.isArm then "arm"
135+ else throw "Unsupported system";
136+ GOARM = optionalString (stdenv.system == "armv5tel-linux") "5";
137+ GO386 = 387; # from Arch: don't assume sse2 on i686
138+ CGO_ENABLED = 1;
139+ GOROOT_BOOTSTRAP = "${goBootstrap}/share/go";
140+
141+ # The go build actually checks for CC=*/clang and does something different, so we don't
142+ # just want the generic `cc` here.
143+ CC = if stdenv.isDarwin then "clang" else "cc";
144+
145+ configurePhase = ''
146+ mkdir -p $out/share/go/bin
147+ export GOROOT=$out/share/go
148+ export GOBIN=$GOROOT/bin
149+ export PATH=$GOBIN:$PATH
150+ '';
151+
152+ postConfigure = optionalString stdenv.isDarwin ''
153+ export PATH=${clangHack}/bin:$PATH
154+ '';
155+
156+ installPhase = ''
157+ cp -r . $GOROOT
158+ ( cd $GOROOT/src && ./all.bash )
159+
160+ # (https://github.com/golang/go/wiki/GoGetTools)
161+ wrapProgram $out/share/go/bin/go --prefix PATH ":" "${stdenv.lib.makeBinPath [ git subversion mercurial bazaar ]}"
162+ '';
163+
164+ preFixup = ''
165+ rm -r $out/share/go/pkg/bootstrap
166+ ln -s $out/share/go/bin $out/bin
167+ '';
168+
169+ setupHook = ./setup-hook.sh;
170+
171+ disallowedReferences = [ go_bootstrap ];
172+
173+ meta = with stdenv.lib; {
174+ branch = "1.8";
175+ homepage = http://golang.org/;
176+ description = "The Go Programming language";
177+ license = licenses.bsd3;
178+ maintainers = with maintainers; [ cstrahan wkennington ];
179+ platforms = platforms.linux ++ platforms.darwin;
180+ };
181+}
pkgs/development/compilers/go/remove-test-pie-1.9.patchnew file+26
@@ -0,0 +1,26 @@
1+diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go
2+index 73432d31ea..3310f5298d 100644
3+--- a/src/cmd/dist/test.go
4++++ b/src/cmd/dist/test.go
5+@@ -510,21 +510,6 @@ func (t *tester) registerTests() {
6+ })
7+ }
8+
9+- // Test internal linking of PIE binaries where it is supported.
10+- if t.goos == "linux" && t.goarch == "amd64" && !isAlpineLinux() {
11+- // Issue 18243: We don't have a way to set the default
12+- // dynamic linker used in internal linking mode. So
13+- // this test is skipped on Alpine.
14+- t.tests = append(t.tests, distTest{
15+- name: "pie_internal",
16+- heading: "internal linking of -buildmode=pie",
17+- fn: func(dt *distTest) error {
18+- t.addCmd(dt, "src", "go", "test", "reflect", "-short", "-buildmode=pie", "-ldflags=-linkmode=internal", t.timeout(60), t.tags(), t.runFlag(""))
19+- return nil
20+- },
21+- })
22+- }
23+-
24+ // sync tests
25+ t.tests = append(t.tests, distTest{
26+ name: "sync_cpu",
pkgs/development/compilers/go/remove-tools-1.9.patchnew file+35
@@ -0,0 +1,35 @@
1+diff --git a/src/go/build/build.go b/src/go/build/build.go
2+index d8163d0172..dd80a70473 100644
3+--- a/src/go/build/build.go
4++++ b/src/go/build/build.go
5+@@ -1592,7 +1592,7 @@ func init() {
6+ }
7+
8+ // ToolDir is the directory containing build tools.
9+-var ToolDir = filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
10++var ToolDir = runtime.GOTOOLDIR()
11+
12+ // IsLocalImport reports whether the import path is
13+ // a local import path, like ".", "..", "./foo", or "../foo".
14+diff --git a/src/runtime/extern.go b/src/runtime/extern.go
15+index 6e6c674d96..e9f62f96dc 100644
16+--- a/src/runtime/extern.go
17++++ b/src/runtime/extern.go
18+@@ -223,6 +223,17 @@ func GOROOT() string {
19+ return sys.DefaultGoroot
20+ }
21+
22++// GOTOOLDIR returns the root of the Go tree.
23++// It uses the GOTOOLDIR environment variable, if set,
24++// or else the root used during the Go build.
25++func GOTOOLDIR() string {
26++ s := gogetenv("GOTOOLDIR")
27++ if s != "" {
28++ return s
29++ }
30++ return GOROOT() + "/pkg/tool/" + GOOS + "_" + GOARCH
31++}
32++
33+ // Version returns the Go tree's version string.
34+ // It is either the commit hash and date at the time of the build or,
35+ // when possible, a release tag like "go1.3".
pkgs/development/compilers/go/ssl-cert-file-1.9.patchnew file+80
@@ -0,0 +1,80 @@
1+diff --git a/src/crypto/x509/root_cgo_darwin.go b/src/crypto/x509/root_cgo_darwin.go
2+index 8e80533590..31c0c666ec 100644
3+--- a/src/crypto/x509/root_cgo_darwin.go
4++++ b/src/crypto/x509/root_cgo_darwin.go
5+@@ -201,11 +201,20 @@ int FetchPEMRoots(CFDataRef *pemRoots, CFDataRef *untrustedPemRoots) {
6+ import "C"
7+ import (
8+ "errors"
9++ "io/ioutil"
10++ "os"
11+ "unsafe"
12+ )
13+
14+ func loadSystemRoots() (*CertPool, error) {
15+ roots := NewCertPool()
16++ if file := os.Getenv("NIX_SSL_CERT_FILE"); file != "" {
17++ data, err := ioutil.ReadFile(file)
18++ if err == nil {
19++ roots.AppendCertsFromPEM(data)
20++ return roots, nil
21++ }
22++ }
23+
24+ var data C.CFDataRef = nil
25+ var untrustedData C.CFDataRef = nil
26+diff --git a/src/crypto/x509/root_darwin.go b/src/crypto/x509/root_darwin.go
27+index bc35a1cf21..21e52bec51 100644
28+--- a/src/crypto/x509/root_darwin.go
29++++ b/src/crypto/x509/root_darwin.go
30+@@ -81,18 +81,26 @@ func execSecurityRoots() (*CertPool, error) {
31+ )
32+ }
33+
34+- cmd := exec.Command("/usr/bin/security", args...)
35+- data, err := cmd.Output()
36+- if err != nil {
37+- return nil, err
38+- }
39+-
40+ var (
41+ mu sync.Mutex
42+ roots = NewCertPool()
43+ numVerified int // number of execs of 'security verify-cert', for debug stats
44+ )
45+
46++ if file := os.Getenv("NIX_SSL_CERT_FILE"); file != "" {
47++ data, err := ioutil.ReadFile(file)
48++ if err == nil {
49++ roots.AppendCertsFromPEM(data)
50++ return roots, nil
51++ }
52++ }
53++
54++ cmd := exec.Command("/usr/bin/security", args...)
55++ data, err := cmd.Output()
56++ if err != nil {
57++ return nil, err
58++ }
59++
60+ blockCh := make(chan *pem.Block)
61+ var wg sync.WaitGroup
62+
63+diff --git a/src/crypto/x509/root_unix.go b/src/crypto/x509/root_unix.go
64+index 65b5a5fdbc..c9c7ac6a74 100644
65+--- a/src/crypto/x509/root_unix.go
66++++ b/src/crypto/x509/root_unix.go
67+@@ -37,6 +37,13 @@ func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate
68+
69+ func loadSystemRoots() (*CertPool, error) {
70+ roots := NewCertPool()
71++ if file := os.Getenv("NIX_SSL_CERT_FILE"); file != "" {
72++ data, err := ioutil.ReadFile(file)
73++ if err == nil {
74++ roots.AppendCertsFromPEM(data)
75++ return roots, nil
76++ }
77++ }
78+
79+ files := certFiles
80+ if f := os.Getenv(certFileEnv); f != "" {
pkgs/top-level/all-packages.nix+5−1
@@ -5699,7 +5699,11 @@ with pkgs;
56995699 inherit (darwin.apple_sdk.frameworks) Security Foundation;
57005700 };
57015701
5702− go = go_1_8;
5702+ go_1_9 = callPackage ../development/compilers/go/1.9.nix {
5703+ inherit (darwin.apple_sdk.frameworks) Security Foundation;
5704+ };
5705+
5706+ go = go_1_9;
57035707
57045708 go-repo-root = callPackage ../development/tools/go-repo-root { };
57055709