2021-02-15 21:52:43 +01:00
|
|
|
{ lib, stdenv, fetchurl, version, hashes }:
|
|
|
|
let
|
|
|
|
toGoKernel = platform:
|
|
|
|
if platform.isDarwin then "darwin"
|
|
|
|
else platform.parsed.kernel.name;
|
|
|
|
|
|
|
|
toGoCPU = platform: {
|
|
|
|
"i686" = "386";
|
|
|
|
"x86_64" = "amd64";
|
|
|
|
"aarch64" = "arm64";
|
2021-03-03 01:51:05 +01:00
|
|
|
"armv6l" = "armv6l";
|
|
|
|
"armv7l" = "armv6l";
|
2021-02-15 21:52:43 +01:00
|
|
|
"powerpc64le" = "ppc64le";
|
|
|
|
}.${platform.parsed.cpu.name} or (throw "Unsupported CPU ${platform.parsed.cpu.name}");
|
|
|
|
|
|
|
|
toGoPlatform = platform: "${toGoKernel platform}-${toGoCPU platform}";
|
|
|
|
|
|
|
|
platform = toGoPlatform stdenv.hostPlatform;
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "go-${version}-${platform}-bootstrap";
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://golang.org/dl/go${version}.${platform}.tar.gz";
|
|
|
|
sha256 = hashes.${platform} or (throw "Missing Go bootstrap hash for platform ${platform}");
|
|
|
|
};
|
|
|
|
|
2021-02-16 22:39:08 +01:00
|
|
|
# We must preserve the signature on Darwin
|
|
|
|
dontStrip = stdenv.hostPlatform.isDarwin;
|
|
|
|
|
2021-02-15 21:52:43 +01:00
|
|
|
installPhase = ''
|
2021-06-04 06:33:26 +02:00
|
|
|
runHook preInstall
|
2021-02-15 21:52:43 +01:00
|
|
|
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
|
|
|
|
'')}
|
2021-06-04 06:33:26 +02:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
2021-02-15 21:52:43 +01:00
|
|
|
}
|