2024-09-04 14:44:43 +00:00
|
|
|
{ lib, stdenv, fetchurl, version, hashes }:
|
2021-02-15 20:52:43 +00:00
|
|
|
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 00:51:05 +00:00
|
|
|
"armv6l" = "armv6l";
|
|
|
|
"armv7l" = "armv6l";
|
2021-02-15 20:52:43 +00:00
|
|
|
"powerpc64le" = "ppc64le";
|
2023-08-03 08:36:00 +00:00
|
|
|
"riscv64" = "riscv64";
|
2021-02-15 20:52:43 +00:00
|
|
|
}.${platform.parsed.cpu.name} or (throw "Unsupported CPU ${platform.parsed.cpu.name}");
|
|
|
|
|
|
|
|
toGoPlatform = platform: "${toGoKernel platform}-${toGoCPU platform}";
|
|
|
|
|
|
|
|
platform = toGoPlatform stdenv.hostPlatform;
|
|
|
|
in
|
2024-09-04 14:27:27 +00:00
|
|
|
stdenv.mkDerivation {
|
2021-02-15 20:52:43 +00:00
|
|
|
name = "go-${version}-${platform}-bootstrap";
|
|
|
|
|
|
|
|
src = fetchurl {
|
2021-11-26 09:11:14 +00:00
|
|
|
url = "https://go.dev/dl/go${version}.${platform}.tar.gz";
|
2021-02-15 20:52:43 +00:00
|
|
|
sha256 = hashes.${platform} or (throw "Missing Go bootstrap hash for platform ${platform}");
|
|
|
|
};
|
|
|
|
|
2021-02-16 21:39:08 +00:00
|
|
|
# We must preserve the signature on Darwin
|
|
|
|
dontStrip = stdenv.hostPlatform.isDarwin;
|
|
|
|
|
2021-02-15 20:52:43 +00:00
|
|
|
installPhase = ''
|
2021-06-04 04:33:26 +00:00
|
|
|
runHook preInstall
|
2021-02-15 20:52:43 +00:00
|
|
|
mkdir -p $out/share/go $out/bin
|
|
|
|
cp -r . $out/share/go
|
2022-08-04 22:23:52 +00:00
|
|
|
ln -s $out/share/go/bin/go $out/bin/go
|
2021-06-04 04:33:26 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
2024-09-04 14:27:27 +00:00
|
|
|
|
2024-09-04 14:44:43 +00:00
|
|
|
meta = {
|
|
|
|
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
2024-09-04 14:27:27 +00:00
|
|
|
changelog = "https://go.dev/doc/devel/release#go${lib.versions.majorMinor version}";
|
|
|
|
description = "The Go Programming language";
|
|
|
|
homepage = "https://go.dev/";
|
2024-09-04 14:44:43 +00:00
|
|
|
license = lib.licenses.bsd3;
|
|
|
|
maintainers = lib.teams.golang.members;
|
|
|
|
platforms = lib.platforms.darwin ++ lib.platforms.linux;
|
2024-09-04 14:27:27 +00:00
|
|
|
};
|
2021-02-15 20:52:43 +00:00
|
|
|
}
|