Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at gcc-offload 56 lines 1.5 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 version, 6 hashes, 7}: 8let 9 toGoKernel = platform: if platform.isDarwin then "darwin" else platform.parsed.kernel.name; 10 11 toGoCPU = 12 platform: 13 { 14 "i686" = "386"; 15 "x86_64" = "amd64"; 16 "aarch64" = "arm64"; 17 "armv6l" = "armv6l"; 18 "armv7l" = "armv6l"; 19 "powerpc64le" = "ppc64le"; 20 "riscv64" = "riscv64"; 21 } 22 .${platform.parsed.cpu.name} or (throw "Unsupported CPU ${platform.parsed.cpu.name}"); 23 24 toGoPlatform = platform: "${toGoKernel platform}-${toGoCPU platform}"; 25 26 platform = toGoPlatform stdenv.hostPlatform; 27in 28stdenv.mkDerivation { 29 name = "go-${version}-${platform}-bootstrap"; 30 31 src = fetchurl { 32 url = "https://go.dev/dl/go${version}.${platform}.tar.gz"; 33 sha256 = hashes.${platform} or (throw "Missing Go bootstrap hash for platform ${platform}"); 34 }; 35 36 # We must preserve the signature on Darwin 37 dontStrip = stdenv.hostPlatform.isDarwin; 38 39 installPhase = '' 40 runHook preInstall 41 mkdir -p $out/share/go $out/bin 42 cp -r . $out/share/go 43 ln -s $out/share/go/bin/go $out/bin/go 44 runHook postInstall 45 ''; 46 47 meta = { 48 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; 49 changelog = "https://go.dev/doc/devel/release#go${lib.versions.majorMinor version}"; 50 description = "The Go Programming language"; 51 homepage = "https://go.dev/"; 52 license = lib.licenses.bsd3; 53 maintainers = lib.teams.golang.members; 54 platforms = lib.platforms.darwin ++ lib.platforms.linux; 55 }; 56}