diff --git a/pkgs/development/compilers/go/1.17.nix b/pkgs/development/compilers/go/1.17.nix index d1dd64eca153..77b3fd9d0b91 100644 --- a/pkgs/development/compilers/go/1.17.nix +++ b/pkgs/development/compilers/go/1.17.nix @@ -3,7 +3,6 @@ , fetchurl , tzdata , iana-etc -, runCommand , perl , which , pkg-config @@ -21,15 +20,7 @@ }: let - go_bootstrap = buildPackages.callPackage ./bootstrap116.nix { }; - - goBootstrap = runCommand "go-bootstrap" { } '' - mkdir $out - cp -rf ${go_bootstrap}/* $out/ - chmod -R u+w $out - find $out -name "*.c" -delete - cp -rf $out/bin/* $out/share/go/bin/ - ''; + goBootstrap = buildPackages.callPackage ./bootstrap116.nix { }; goarch = platform: { "aarch64" = "arm64"; @@ -277,6 +268,10 @@ stdenv.mkDerivation rec { disallowedReferences = [ goBootstrap ]; + passthru = { + inherit goBootstrap; + }; + meta = with lib; { description = "The Go Programming language"; homepage = "https://go.dev/"; diff --git a/pkgs/development/compilers/go/1.18.nix b/pkgs/development/compilers/go/1.18.nix index 394c5f92723a..e64421035bbe 100644 --- a/pkgs/development/compilers/go/1.18.nix +++ b/pkgs/development/compilers/go/1.18.nix @@ -3,7 +3,6 @@ , fetchurl , tzdata , iana-etc -, runCommand , perl , which , pkg-config @@ -21,15 +20,7 @@ }: let - go_bootstrap = buildPackages.callPackage ./bootstrap116.nix { }; - - goBootstrap = runCommand "go-bootstrap" { } '' - mkdir $out - cp -rf ${go_bootstrap}/* $out/ - chmod -R u+w $out - find $out -name "*.c" -delete - cp -rf $out/bin/* $out/share/go/bin/ - ''; + goBootstrap = buildPackages.callPackage ./bootstrap116.nix { }; goarch = platform: { "aarch64" = "arm64"; @@ -271,6 +262,10 @@ stdenv.mkDerivation rec { disallowedReferences = [ goBootstrap ]; + passthru = { + inherit goBootstrap; + }; + meta = with lib; { description = "The Go Programming language"; homepage = "https://go.dev/"; diff --git a/pkgs/development/compilers/go/1.19.nix b/pkgs/development/compilers/go/1.19.nix index f5b511633465..cdb4938d4013 100644 --- a/pkgs/development/compilers/go/1.19.nix +++ b/pkgs/development/compilers/go/1.19.nix @@ -3,7 +3,6 @@ , fetchurl , tzdata , iana-etc -, runCommand , perl , which , pkg-config @@ -21,15 +20,7 @@ }: let - go_bootstrap = buildPackages.callPackage ./bootstrap116.nix { }; - - goBootstrap = runCommand "go-bootstrap" { } '' - mkdir $out - cp -rf ${go_bootstrap}/* $out/ - chmod -R u+w $out - find $out -name "*.c" -delete - cp -rf $out/bin/* $out/share/go/bin/ - ''; + goBootstrap = buildPackages.callPackage ./bootstrap116.nix { }; goarch = platform: { "aarch64" = "arm64"; @@ -270,6 +261,10 @@ stdenv.mkDerivation rec { disallowedReferences = [ goBootstrap ]; + passthru = { + inherit goBootstrap; + }; + meta = with lib; { description = "The Go Programming language"; homepage = "https://go.dev/"; diff --git a/pkgs/development/compilers/go/binary.nix b/pkgs/development/compilers/go/binary.nix index d8e6b9e71de2..352e0e395206 100644 --- a/pkgs/development/compilers/go/binary.nix +++ b/pkgs/development/compilers/go/binary.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchurl, version, hashes }: +{ lib, stdenv, fetchurl, version, hashes, autoPatchelfHook }: let toGoKernel = platform: if platform.isDarwin then "darwin" @@ -25,19 +25,16 @@ stdenv.mkDerivation rec { sha256 = hashes.${platform} or (throw "Missing Go bootstrap hash for platform ${platform}"); }; + nativeBuildInputs = lib.optionals stdenv.isLinux [ autoPatchelfHook ]; + # We must preserve the signature on Darwin dontStrip = stdenv.hostPlatform.isDarwin; installPhase = '' runHook preInstall mkdir -p $out/share/go $out/bin - mv bin/* $out/bin cp -r . $out/share/go - ${lib.optionalString stdenv.isLinux ('' - patchelf \ - --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ - $out/bin/go - '')} + ln -s $out/share/go/bin/go $out/bin/go runHook postInstall ''; }