about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/go
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/go')
-rw-r--r--nixpkgs/pkgs/development/compilers/go/1.20.nix4
-rw-r--r--nixpkgs/pkgs/development/compilers/go/1.21.nix38
2 files changed, 10 insertions, 32 deletions
diff --git a/nixpkgs/pkgs/development/compilers/go/1.20.nix b/nixpkgs/pkgs/development/compilers/go/1.20.nix
index 3364ea354019..26fbc9e7df2e 100644
--- a/nixpkgs/pkgs/development/compilers/go/1.20.nix
+++ b/nixpkgs/pkgs/development/compilers/go/1.20.nix
@@ -46,11 +46,11 @@ let
 in
 stdenv.mkDerivation rec {
   pname = "go";
-  version = "1.20.7";
+  version = "1.20.8";
 
   src = fetchurl {
     url = "https://go.dev/dl/go${version}.src.tar.gz";
-    hash = "sha256-LF7pyeweczsNu8K9/tP2IwblHYFyvzj09OVCsnUg9Zc=";
+    hash = "sha256-ONcXFPpSeflyQEUZVtjkfjwbal3ny4QTeUnWK13TGC4=";
   };
 
   strictDeps = true;
diff --git a/nixpkgs/pkgs/development/compilers/go/1.21.nix b/nixpkgs/pkgs/development/compilers/go/1.21.nix
index 56da1bc52dde..ef935e73f61f 100644
--- a/nixpkgs/pkgs/development/compilers/go/1.21.nix
+++ b/nixpkgs/pkgs/development/compilers/go/1.21.nix
@@ -64,10 +64,6 @@ stdenv.mkDerivation rec {
 
   depsTargetTarget = lib.optional stdenv.targetPlatform.isWindows threadsCross.package;
 
-  postPatch = ''
-    patchShebangs .
-  '';
-
   patches = [
     (substituteAll {
       src = ./iana-etc-1.17.patch;
@@ -92,8 +88,6 @@ stdenv.mkDerivation rec {
   GOOS = stdenv.targetPlatform.parsed.kernel.name;
   GOARCH = goarch stdenv.targetPlatform;
   # GOHOSTOS/GOHOSTARCH must match the building system, not the host system.
-  # Go will nevertheless build a for host system that we will copy over in
-  # the install phase.
   GOHOSTOS = stdenv.buildPlatform.parsed.kernel.name;
   GOHOSTARCH = goarch stdenv.buildPlatform;
 
@@ -116,14 +110,16 @@ stdenv.mkDerivation rec {
 
   GOROOT_BOOTSTRAP = if useGccGoBootstrap then goBootstrap else "${goBootstrap}/share/go";
 
+  # Note that we use distpack to avoid moving around cross-compiled binaries.
+  # The paths are slightly different when buildPlatform != hostPlatform and
+  # distpack handles assembling outputs in the right place, same as the official
+  # Go binary releases. See also https://pkg.go.dev/cmd/distpack
   buildPhase = ''
     runHook preBuild
     export GOCACHE=$TMPDIR/go-cache
     # this is compiled into the binary
     export GOROOT_FINAL=$out/share/go
 
-    export PATH=$(pwd)/bin:$PATH
-
     ${lib.optionalString isCross ''
     # Independent from host/target, CC should produce code for the building system.
     # We only set it when cross-compiling.
@@ -132,34 +128,16 @@ stdenv.mkDerivation rec {
     ulimit -a
 
     pushd src
-    ./make.bash
+    bash make.bash -no-banner -distpack
     popd
     runHook postBuild
   '';
 
-  preInstall = ''
-    # Contains the wrong perl shebang when cross compiling,
-    # since it is not used for anything we can deleted as well.
-    rm src/regexp/syntax/make_perl_groups.pl
-  '' + (if (stdenv.buildPlatform.system != stdenv.hostPlatform.system) then ''
-    mv bin/*_*/* bin
-    rmdir bin/*_*
-    ${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
-      rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH}
-    ''}
-  '' else lib.optionalString (stdenv.hostPlatform.system != stdenv.targetPlatform.system) ''
-    rm -rf bin/*_*
-    ${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
-      rm -rf pkg/${GOOS}_${GOARCH} pkg/tool/${GOOS}_${GOARCH}
-    ''}
-  '');
-
   installPhase = ''
     runHook preInstall
-    mkdir -p $GOROOT_FINAL
-    cp -a bin pkg src lib misc api doc go.env $GOROOT_FINAL
-    mkdir -p $out/bin
-    ln -s $GOROOT_FINAL/bin/* $out/bin
+    mkdir -p $out/{share,bin}
+    tar -C $out/share -x -z -f "pkg/distpack/go${version}.$GOOS-$GOARCH.tar.gz"
+    ln -s $out/share/go/bin/* $out/bin
     runHook postInstall
   '';