go: cleanup

(cherry picked from commit 88f1ca731cd772843c05a3395ae4eb283b1ef98d)
This commit is contained in:
zowoq 2021-06-04 13:52:04 +10:00 committed by Maxine Aubrey
parent 46fc5b82ea
commit 8f3ec9ee43
No known key found for this signature in database
GPG Key ID: F6FE033DFCB899F7
4 changed files with 42 additions and 64 deletions

View File

@ -22,11 +22,6 @@
}: }:
let let
inherit (lib) optionals optionalString;
version = "1.14.15";
go_bootstrap = buildPackages.callPackage ./bootstrap.nix { }; go_bootstrap = buildPackages.callPackage ./bootstrap.nix { };
goBootstrap = runCommand "go-bootstrap" { } '' goBootstrap = runCommand "go-bootstrap" { } ''
@ -55,7 +50,7 @@ in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "go"; pname = "go";
inherit version; version = "1.14.15";
src = fetchurl { src = fetchurl {
url = "https://dl.google.com/go/go${version}.src.tar.gz"; url = "https://dl.google.com/go/go${version}.src.tar.gz";
@ -65,10 +60,10 @@ stdenv.mkDerivation rec {
# perl is used for testing go vet # perl is used for testing go vet
nativeBuildInputs = [ perl which pkg-config patch procps ]; nativeBuildInputs = [ perl which pkg-config patch procps ];
buildInputs = [ cacert pcre ] buildInputs = [ cacert pcre ]
++ optionals stdenv.isLinux [ stdenv.cc.libc.out ] ++ lib.optionals stdenv.isLinux [ stdenv.cc.libc.out ]
++ optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ]; ++ lib.optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ];
depsTargetTargetPropagated = optionals stdenv.isDarwin [ Security Foundation ]; depsTargetTargetPropagated = lib.optionals stdenv.isDarwin [ Security Foundation ];
hardeningDisable = [ "all" ]; hardeningDisable = [ "all" ];
@ -120,14 +115,14 @@ stdenv.mkDerivation rec {
# Disable cgo lookup tests not works, they depend on resolver # Disable cgo lookup tests not works, they depend on resolver
rm src/net/cgo_unix_test.go rm src/net/cgo_unix_test.go
'' + optionalString stdenv.isLinux '' '' + lib.optionalString stdenv.isLinux ''
# prepend the nix path to the zoneinfo files but also leave the original value for static binaries # prepend the nix path to the zoneinfo files but also leave the original value for static binaries
# that run outside a nix server # that run outside a nix server
sed -i 's,\"/usr/share/zoneinfo/,"${tzdata}/share/zoneinfo/\"\,\n\t&,' src/time/zoneinfo_unix.go sed -i 's,\"/usr/share/zoneinfo/,"${tzdata}/share/zoneinfo/\"\,\n\t&,' src/time/zoneinfo_unix.go
'' + optionalString stdenv.isAarch32 '' '' + lib.optionalString stdenv.isAarch32 ''
echo '#!${runtimeShell}' > misc/cgo/testplugin/test.bash echo '#!${runtimeShell}' > misc/cgo/testplugin/test.bash
'' + optionalString stdenv.isDarwin '' '' + lib.optionalString stdenv.isDarwin ''
substituteInPlace src/race.bash --replace \ substituteInPlace src/race.bash --replace \
"sysctl machdep.cpu.extfeatures | grep -qv EM64T" true "sysctl machdep.cpu.extfeatures | grep -qv EM64T" true
sed -i 's,strings.Contains(.*sysctl.*,true {,' src/cmd/dist/util.go sed -i 's,strings.Contains(.*sysctl.*,true {,' src/cmd/dist/util.go
@ -227,7 +222,7 @@ stdenv.mkDerivation rec {
export PATH=$(pwd)/bin:$PATH export PATH=$(pwd)/bin:$PATH
${optionalString (stdenv.buildPlatform != stdenv.targetPlatform) '' ${lib.optionalString (stdenv.buildPlatform != stdenv.targetPlatform) ''
# Independent from host/target, CC should produce code for the building system. # Independent from host/target, CC should produce code for the building system.
# We only set it when cross-compiling. # We only set it when cross-compiling.
export CC=${buildPackages.stdenv.cc}/bin/cc export CC=${buildPackages.stdenv.cc}/bin/cc
@ -255,12 +250,12 @@ stdenv.mkDerivation rec {
'' + (if (stdenv.buildPlatform != stdenv.hostPlatform) then '' '' + (if (stdenv.buildPlatform != stdenv.hostPlatform) then ''
mv bin/*_*/* bin mv bin/*_*/* bin
rmdir bin/*_* rmdir bin/*_*
${optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) '' ${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH} rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH}
''} ''}
'' else if (stdenv.hostPlatform != stdenv.targetPlatform) then '' '' else if (stdenv.hostPlatform != stdenv.targetPlatform) then ''
rm -rf bin/*_* rm -rf bin/*_*
${optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) '' ${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOOS}_${GOARCH} pkg/tool/${GOOS}_${GOARCH} rm -rf pkg/${GOOS}_${GOARCH} pkg/tool/${GOOS}_${GOARCH}
''} ''}
'' else ""); '' else "");

View File

@ -22,11 +22,6 @@
}: }:
let let
inherit (lib) optionals optionalString;
version = "1.15.13";
go_bootstrap = buildPackages.callPackage ./bootstrap.nix { }; go_bootstrap = buildPackages.callPackage ./bootstrap.nix { };
goBootstrap = runCommand "go-bootstrap" { } '' goBootstrap = runCommand "go-bootstrap" { } ''
@ -55,7 +50,7 @@ in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "go"; pname = "go";
inherit version; version = "1.15.13";
src = fetchurl { src = fetchurl {
url = "https://dl.google.com/go/go${version}.src.tar.gz"; url = "https://dl.google.com/go/go${version}.src.tar.gz";
@ -65,10 +60,10 @@ stdenv.mkDerivation rec {
# perl is used for testing go vet # perl is used for testing go vet
nativeBuildInputs = [ perl which pkg-config patch procps ]; nativeBuildInputs = [ perl which pkg-config patch procps ];
buildInputs = [ cacert pcre ] buildInputs = [ cacert pcre ]
++ optionals stdenv.isLinux [ stdenv.cc.libc.out ] ++ lib.optionals stdenv.isLinux [ stdenv.cc.libc.out ]
++ optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ]; ++ lib.optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ];
depsTargetTargetPropagated = optionals stdenv.isDarwin [ Security Foundation ]; depsTargetTargetPropagated = lib.optionals stdenv.isDarwin [ Security Foundation ];
hardeningDisable = [ "all" ]; hardeningDisable = [ "all" ];
@ -128,14 +123,14 @@ stdenv.mkDerivation rec {
# Disable cgo lookup tests not works, they depend on resolver # Disable cgo lookup tests not works, they depend on resolver
rm src/net/cgo_unix_test.go rm src/net/cgo_unix_test.go
'' + optionalString stdenv.isLinux '' '' + lib.optionalString stdenv.isLinux ''
# prepend the nix path to the zoneinfo files but also leave the original value for static binaries # prepend the nix path to the zoneinfo files but also leave the original value for static binaries
# that run outside a nix server # that run outside a nix server
sed -i 's,\"/usr/share/zoneinfo/,"${tzdata}/share/zoneinfo/\"\,\n\t&,' src/time/zoneinfo_unix.go sed -i 's,\"/usr/share/zoneinfo/,"${tzdata}/share/zoneinfo/\"\,\n\t&,' src/time/zoneinfo_unix.go
'' + optionalString stdenv.isAarch32 '' '' + lib.optionalString stdenv.isAarch32 ''
echo '#!${runtimeShell}' > misc/cgo/testplugin/test.bash echo '#!${runtimeShell}' > misc/cgo/testplugin/test.bash
'' + optionalString stdenv.isDarwin '' '' + lib.optionalString stdenv.isDarwin ''
substituteInPlace src/race.bash --replace \ substituteInPlace src/race.bash --replace \
"sysctl machdep.cpu.extfeatures | grep -qv EM64T" true "sysctl machdep.cpu.extfeatures | grep -qv EM64T" true
sed -i 's,strings.Contains(.*sysctl.*,true {,' src/cmd/dist/util.go sed -i 's,strings.Contains(.*sysctl.*,true {,' src/cmd/dist/util.go
@ -230,7 +225,7 @@ stdenv.mkDerivation rec {
export PATH=$(pwd)/bin:$PATH export PATH=$(pwd)/bin:$PATH
${optionalString (stdenv.buildPlatform != stdenv.targetPlatform) '' ${lib.optionalString (stdenv.buildPlatform != stdenv.targetPlatform) ''
# Independent from host/target, CC should produce code for the building system. # Independent from host/target, CC should produce code for the building system.
# We only set it when cross-compiling. # We only set it when cross-compiling.
export CC=${buildPackages.stdenv.cc}/bin/cc export CC=${buildPackages.stdenv.cc}/bin/cc
@ -258,12 +253,12 @@ stdenv.mkDerivation rec {
'' + (if (stdenv.buildPlatform != stdenv.hostPlatform) then '' '' + (if (stdenv.buildPlatform != stdenv.hostPlatform) then ''
mv bin/*_*/* bin mv bin/*_*/* bin
rmdir bin/*_* rmdir bin/*_*
${optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) '' ${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH} rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH}
''} ''}
'' else if (stdenv.hostPlatform != stdenv.targetPlatform) then '' '' else if (stdenv.hostPlatform != stdenv.targetPlatform) then ''
rm -rf bin/*_* rm -rf bin/*_*
${optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) '' ${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOOS}_${GOARCH} pkg/tool/${GOOS}_${GOARCH} rm -rf pkg/${GOOS}_${GOARCH} pkg/tool/${GOOS}_${GOARCH}
''} ''}
'' else ""); '' else "");

View File

@ -18,16 +18,10 @@
, runtimeShell , runtimeShell
, buildPackages , buildPackages
, pkgsBuildTarget , pkgsBuildTarget
, fetchpatch
, callPackage , callPackage
}: }:
let let
inherit (lib) optionals optionalString;
version = "1.16.5";
go_bootstrap = buildPackages.callPackage ./bootstrap.nix { }; go_bootstrap = buildPackages.callPackage ./bootstrap.nix { };
goBootstrap = runCommand "go-bootstrap" { } '' goBootstrap = runCommand "go-bootstrap" { } ''
@ -56,7 +50,7 @@ in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "go"; pname = "go";
inherit version; version = "1.16.5";
src = fetchurl { src = fetchurl {
url = "https://dl.google.com/go/go${version}.src.tar.gz"; url = "https://dl.google.com/go/go${version}.src.tar.gz";
@ -66,12 +60,12 @@ stdenv.mkDerivation rec {
# perl is used for testing go vet # perl is used for testing go vet
nativeBuildInputs = [ perl which pkg-config patch procps ]; nativeBuildInputs = [ perl which pkg-config patch procps ];
buildInputs = [ cacert pcre ] buildInputs = [ cacert pcre ]
++ optionals stdenv.isLinux [ stdenv.cc.libc.out ] ++ lib.optionals stdenv.isLinux [ stdenv.cc.libc.out ]
++ optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ]; ++ lib.optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ];
propagatedBuildInputs = optionals stdenv.isDarwin [ xcbuild ]; propagatedBuildInputs = lib.optionals stdenv.isDarwin [ xcbuild ];
depsTargetTargetPropagated = optionals stdenv.isDarwin [ Security Foundation ]; depsTargetTargetPropagated = lib.optionals stdenv.isDarwin [ Security Foundation ];
hardeningDisable = [ "all" ]; hardeningDisable = [ "all" ];
@ -131,14 +125,14 @@ stdenv.mkDerivation rec {
# Disable cgo lookup tests not works, they depend on resolver # Disable cgo lookup tests not works, they depend on resolver
rm src/net/cgo_unix_test.go rm src/net/cgo_unix_test.go
'' + optionalString stdenv.isLinux '' '' + lib.optionalString stdenv.isLinux ''
# prepend the nix path to the zoneinfo files but also leave the original value for static binaries # prepend the nix path to the zoneinfo files but also leave the original value for static binaries
# that run outside a nix server # that run outside a nix server
sed -i 's,\"/usr/share/zoneinfo/,"${tzdata}/share/zoneinfo/\"\,\n\t&,' src/time/zoneinfo_unix.go sed -i 's,\"/usr/share/zoneinfo/,"${tzdata}/share/zoneinfo/\"\,\n\t&,' src/time/zoneinfo_unix.go
'' + optionalString stdenv.isAarch32 '' '' + lib.optionalString stdenv.isAarch32 ''
echo '#!${runtimeShell}' > misc/cgo/testplugin/test.bash echo '#!${runtimeShell}' > misc/cgo/testplugin/test.bash
'' + optionalString stdenv.isDarwin '' '' + lib.optionalString stdenv.isDarwin ''
substituteInPlace src/race.bash --replace \ substituteInPlace src/race.bash --replace \
"sysctl machdep.cpu.extfeatures | grep -qv EM64T" true "sysctl machdep.cpu.extfeatures | grep -qv EM64T" true
sed -i 's,strings.Contains(.*sysctl.*,true {,' src/cmd/dist/util.go sed -i 's,strings.Contains(.*sysctl.*,true {,' src/cmd/dist/util.go
@ -226,7 +220,7 @@ stdenv.mkDerivation rec {
export PATH=$(pwd)/bin:$PATH export PATH=$(pwd)/bin:$PATH
${optionalString (stdenv.buildPlatform != stdenv.targetPlatform) '' ${lib.optionalString (stdenv.buildPlatform != stdenv.targetPlatform) ''
# Independent from host/target, CC should produce code for the building system. # Independent from host/target, CC should produce code for the building system.
# We only set it when cross-compiling. # We only set it when cross-compiling.
export CC=${buildPackages.stdenv.cc}/bin/cc export CC=${buildPackages.stdenv.cc}/bin/cc
@ -254,12 +248,12 @@ stdenv.mkDerivation rec {
'' + (if (stdenv.buildPlatform != stdenv.hostPlatform) then '' '' + (if (stdenv.buildPlatform != stdenv.hostPlatform) then ''
mv bin/*_*/* bin mv bin/*_*/* bin
rmdir bin/*_* rmdir bin/*_*
${optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) '' ${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH} rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH}
''} ''}
'' else if (stdenv.hostPlatform != stdenv.targetPlatform) then '' '' else if (stdenv.hostPlatform != stdenv.targetPlatform) then ''
rm -rf bin/*_* rm -rf bin/*_*
${optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) '' ${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOOS}_${GOARCH} pkg/tool/${GOOS}_${GOARCH} rm -rf pkg/${GOOS}_${GOARCH} pkg/tool/${GOOS}_${GOARCH}
''} ''}
'' else ""); '' else "");

View File

@ -1,7 +1,5 @@
{ pkgs { lib
, lib
, stdenv , stdenv
, fetchurl
, fetchgit , fetchgit
, tzdata , tzdata
, iana-etc , iana-etc
@ -19,14 +17,10 @@
, runtimeShell , runtimeShell
, buildPackages , buildPackages
, pkgsBuildTarget , pkgsBuildTarget
, fetchpatch
, callPackage , callPackage
}: }:
let let
inherit (lib) optionals optionalString;
go_bootstrap = buildPackages.callPackage ./bootstrap.nix { }; go_bootstrap = buildPackages.callPackage ./bootstrap.nix { };
goBootstrap = runCommand "go-bootstrap" { } '' goBootstrap = runCommand "go-bootstrap" { } ''
@ -58,7 +52,7 @@ stdenv.mkDerivation rec {
version = "2021-04-13"; version = "2021-04-13";
src = fetchgit { src = fetchgit {
url = https://go.googlesource.com/go; url = "https://go.googlesource.com/go";
rev = "9cd52cf2a93a958e8e001aea36886e7846c91f2f"; rev = "9cd52cf2a93a958e8e001aea36886e7846c91f2f";
sha256 = "sha256:0hybm93y4i4j7bs86y7h73nc1wqnspkq75if7n1032zf9bs8sm96"; sha256 = "sha256:0hybm93y4i4j7bs86y7h73nc1wqnspkq75if7n1032zf9bs8sm96";
}; };
@ -66,10 +60,10 @@ stdenv.mkDerivation rec {
# perl is used for testing go vet # perl is used for testing go vet
nativeBuildInputs = [ perl which pkg-config patch procps ]; nativeBuildInputs = [ perl which pkg-config patch procps ];
buildInputs = [ cacert pcre ] buildInputs = [ cacert pcre ]
++ optionals stdenv.isLinux [ stdenv.cc.libc.out ] ++ lib.optionals stdenv.isLinux [ stdenv.cc.libc.out ]
++ optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ]; ++ lib.optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ];
depsTargetTargetPropagated = optionals stdenv.isDarwin [ Security Foundation ]; depsTargetTargetPropagated = lib.optionals stdenv.isDarwin [ Security Foundation ];
hardeningDisable = [ "all" ]; hardeningDisable = [ "all" ];
@ -130,14 +124,14 @@ stdenv.mkDerivation rec {
# Disable cgo lookup tests not works, they depend on resolver # Disable cgo lookup tests not works, they depend on resolver
rm src/net/cgo_unix_test.go rm src/net/cgo_unix_test.go
'' + optionalString stdenv.isLinux '' '' + lib.optionalString stdenv.isLinux ''
# prepend the nix path to the zoneinfo files but also leave the original value for static binaries # prepend the nix path to the zoneinfo files but also leave the original value for static binaries
# that run outside a nix server # that run outside a nix server
sed -i 's,\"/usr/share/zoneinfo/,"${tzdata}/share/zoneinfo/\"\,\n\t&,' src/time/zoneinfo_unix.go sed -i 's,\"/usr/share/zoneinfo/,"${tzdata}/share/zoneinfo/\"\,\n\t&,' src/time/zoneinfo_unix.go
'' + optionalString stdenv.isAarch32 '' '' + lib.optionalString stdenv.isAarch32 ''
echo '#!${runtimeShell}' > misc/cgo/testplugin/test.bash echo '#!${runtimeShell}' > misc/cgo/testplugin/test.bash
'' + optionalString stdenv.isDarwin '' '' + lib.optionalString stdenv.isDarwin ''
substituteInPlace src/race.bash --replace \ substituteInPlace src/race.bash --replace \
"sysctl machdep.cpu.extfeatures | grep -qv EM64T" true "sysctl machdep.cpu.extfeatures | grep -qv EM64T" true
sed -i 's,strings.Contains(.*sysctl.*,true {,' src/cmd/dist/util.go sed -i 's,strings.Contains(.*sysctl.*,true {,' src/cmd/dist/util.go
@ -224,7 +218,7 @@ stdenv.mkDerivation rec {
export PATH=$(pwd)/bin:$PATH export PATH=$(pwd)/bin:$PATH
${optionalString (stdenv.buildPlatform != stdenv.targetPlatform) '' ${lib.optionalString (stdenv.buildPlatform != stdenv.targetPlatform) ''
# Independent from host/target, CC should produce code for the building system. # Independent from host/target, CC should produce code for the building system.
# We only set it when cross-compiling. # We only set it when cross-compiling.
export CC=${buildPackages.stdenv.cc}/bin/cc export CC=${buildPackages.stdenv.cc}/bin/cc
@ -252,12 +246,12 @@ stdenv.mkDerivation rec {
'' + (if (stdenv.buildPlatform != stdenv.hostPlatform) then '' '' + (if (stdenv.buildPlatform != stdenv.hostPlatform) then ''
mv bin/*_*/* bin mv bin/*_*/* bin
rmdir bin/*_* rmdir bin/*_*
${optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) '' ${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH} rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH}
''} ''}
'' else if (stdenv.hostPlatform != stdenv.targetPlatform) then '' '' else if (stdenv.hostPlatform != stdenv.targetPlatform) then ''
rm -rf bin/*_* rm -rf bin/*_*
${optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) '' ${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOOS}_${GOARCH} pkg/tool/${GOOS}_${GOARCH} rm -rf pkg/${GOOS}_${GOARCH} pkg/tool/${GOOS}_${GOARCH}
''} ''}
'' else ""); '' else "");