1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{ pkgs, lib, ... }:

# The Go toolchain runGoCommand compiles builders with: the official release,
# not nixpkgs' go. A fixed-output fetch is addressed by its hash alone, so
# this path, and every builder compiled with it, stays the same when nixpkgs
# (its go, its patches, stdenv) moves. See runGoCommand.7, "REBUILDS".
#
# One tarball per build platform, since the go binary runs on the machine
# that builds. Keep `version` in step with go.work. To bump:
#
#   nix store prefetch-file --unpack https://go.dev/dl/go<version>.linux-amd64.tar.gz
#   nix store prefetch-file --unpack https://go.dev/dl/go<version>.linux-arm64.tar.gz
let
  version = "1.26.5";

  platforms = {
    x86_64-linux = { goPlatform = "linux-amd64"; hash = "sha256-gIhMbkEwrEAQeHD3iC4XXopJTB9TxRKUYlWD7mqPeHc="; };
    aarch64-linux = { goPlatform = "linux-arm64"; hash = "sha256-imQ2mXgSZ7NJCESit6h7UhWLc9ERLcejFkFT7qSXMZg="; };
  };

  system = pkgs.stdenv.buildPlatform.system;
  p = platforms.${system} or (throw ''
    runGoCommand: no Go ${version} release pinned for build platform ${system}.
    Add it to nix/runGoCommand/go.nix (see the comment there for the prefetch command).'');
in
pkgs.fetchzip {
  name = "go-${version}-${p.goPlatform}";
  url = "https://go.dev/dl/go${version}.${p.goPlatform}.tar.gz";
  inherit (p) hash;
  passthru = { inherit version; };
}