Skip to content

Commit

Permalink
bazel: use prebuilt Go toolchain (go.dev/dl)
Browse files Browse the repository at this point in the history
We had to switch to a Go toolchain from nixpkgs,
since prebuilt Go toolchain versions were not usable on NixOS.
Since Go 1.21, the prebuilt Go toolchain is statically linked
and works out of the box.

Reference: golang/go#57007
  • Loading branch information
malt3 committed Jan 5, 2024
1 parent c23aef3 commit 853a455
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 39 deletions.
9 changes: 2 additions & 7 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,11 @@ load("//bazel/toolchains:go_module_deps.bzl", "go_dependencies")
# gazelle:repository_macro bazel/toolchains/go_module_deps.bzl%go_dependencies
go_dependencies()

load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

load("@io_tweag_rules_nixpkgs//nixpkgs:toolchains/go.bzl", "nixpkgs_go_configure")

nixpkgs_go_configure(
nix_file = "//bazel/go:go.nix",
repository = "@nixpkgs",
)
go_register_toolchains(version = "1.21.5")

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

Expand Down
21 changes: 0 additions & 21 deletions bazel/go/go.nix

This file was deleted.

15 changes: 4 additions & 11 deletions dev-docs/workflows/bump-go-version.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,8 @@

## Steps

1. Replace "1.xx.x" with the new version (see [example](https://github.com/edgelesssys/constellation/commit/9e1a0c06bfda0171958f0776633a9a53f521144d))
2. Update the nix hash
Replace "1.xx.x" with the new version in [WORKSPACE.bazel](/WORKSPACE.bazel):

Once updated run `bazel run //:tidy` and you will see a failure such as:

```
> error: hash mismatch in fixed-output derivation '/nix/store/r85bdj6vrim7m5vlybdmzgca7d0kcb4n-go1.21.4.src.tar.gz.drv':
> specified: sha256-GG8rb4yLcE5paCGwmrIEGlwe4T3LwxVqE63PdZMe5Ig=
> got: sha256-R7Jqg9K2WjwcG8rOJztpvuSaentRaKdgTe09JqN714c=
```
Simple replace the hash with the got value.
3. Ask @katexochen to build the thing and push it into his cache.
```starlark
go_register_toolchains(version = "1.xx.x")
```

0 comments on commit 853a455

Please sign in to comment.