mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-07-20 05:51:46 -04:00
bazel: use prebuilt Go toolchain (go.dev/dl) (#2796)
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: https://github.com/golang/go/issues/57007
This commit is contained in:
parent
c23aef344d
commit
3a4f6ef9d1
3 changed files with 6 additions and 39 deletions
|
@ -131,16 +131,11 @@ load("//bazel/toolchains:go_module_deps.bzl", "go_dependencies")
|
||||||
# gazelle:repository_macro bazel/toolchains/go_module_deps.bzl%go_dependencies
|
# gazelle:repository_macro bazel/toolchains/go_module_deps.bzl%go_dependencies
|
||||||
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()
|
go_rules_dependencies()
|
||||||
|
|
||||||
load("@io_tweag_rules_nixpkgs//nixpkgs:toolchains/go.bzl", "nixpkgs_go_configure")
|
go_register_toolchains(version = "1.21.5")
|
||||||
|
|
||||||
nixpkgs_go_configure(
|
|
||||||
nix_file = "//bazel/go:go.nix",
|
|
||||||
repository = "@nixpkgs",
|
|
||||||
)
|
|
||||||
|
|
||||||
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
|
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
|
||||||
|
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
let
|
|
||||||
pkgs = import <nixpkgs> { };
|
|
||||||
goAttr = pkgs.go_1_21.overrideAttrs (_: rec {
|
|
||||||
version = "1.21.5";
|
|
||||||
src = pkgs.fetchurl {
|
|
||||||
url = "https://go.dev/dl/go${version}.src.tar.gz";
|
|
||||||
hash = "sha256-KFy730tubmLtWPNw8/bYwwgl1uVsWFPGbTwjvNsJ2xk=";
|
|
||||||
};
|
|
||||||
});
|
|
||||||
in
|
|
||||||
pkgs.buildEnv
|
|
||||||
{
|
|
||||||
name = "bazel-go-toolchain";
|
|
||||||
paths = [ goAttr ];
|
|
||||||
postBuild = ''
|
|
||||||
touch $out/ROOT
|
|
||||||
ln -s $out/share/go/{api,doc,lib,misc,pkg,src,go.env} $out/
|
|
||||||
'';
|
|
||||||
} // {
|
|
||||||
version = goAttr.version;
|
|
||||||
}
|
|
|
@ -3,15 +3,8 @@
|
||||||
|
|
||||||
## Steps
|
## Steps
|
||||||
|
|
||||||
1. Replace "1.xx.x" with the new version (see [example](https://github.com/edgelesssys/constellation/commit/9e1a0c06bfda0171958f0776633a9a53f521144d))
|
Replace "1.xx.x" with the new version in [WORKSPACE.bazel](/WORKSPACE.bazel):
|
||||||
2. Update the nix hash
|
|
||||||
|
|
||||||
Once updated run `bazel run //:tidy` and you will see a failure such as:
|
|
||||||
|
|
||||||
|
```starlark
|
||||||
|
go_register_toolchains(version = "1.xx.x")
|
||||||
```
|
```
|
||||||
> 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.
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue