diff --git a/CHANGELOG.md b/CHANGELOG.md
index 62f0f58a5..b194c5f85 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
### Added
- nixpkgs_nodejs_configure_platforms for platform transparent npm_install
See [#309]
+
+### Breaking changes
+- rules_nixpkgs_go: Custom derivations passed to `nixpkgs_go_configure` (via `nix-file`, `nix-file-content` or `attribute_path`) must now contain a `version` attribute.
## [0.9.0] - 2022-07-19
diff --git a/toolchains/go/README.md b/toolchains/go/README.md
index be254f1f4..2d49ebb66 100644
--- a/toolchains/go/README.md
+++ b/toolchains/go/README.md
@@ -171,7 +171,7 @@ default is None
-An expression for a Nix environment derivation. The environment should expose the whole go SDK (`bin`, `src`, ...) at the root of package. It also must contain a `ROOT` file in the root of pacakge. Takes precedence over attribute_path. +An expression for a Nix environment derivation. The environment should expose the whole go SDK (`bin`, `src`, ...) at the root of package. It also must contain a `ROOT` file in the root of package. Takes precedence over attribute_path.
@@ -181,7 +181,7 @@ An expression for a Nix environment derivation. The environment should expose thNone
+default is []
diff --git a/toolchains/go/go.bzl b/toolchains/go/go.bzl
index 96c5d8605..cb0f26ad8 100644
--- a/toolchains/go/go.bzl
+++ b/toolchains/go/go.bzl
@@ -71,11 +71,12 @@ def _detect_host_platform(ctx):
go_helpers_build = """
load("@{rules_go}//go:def.bzl", "go_sdk")
-def go_sdk_for_arch():
+def go_sdk_for_arch(go_version):
native.filegroup(
name = "libs",
srcs = native.glob(
["pkg/{goos}_{goarch}/**/*.a"],
+ allow_empty = True,
exclude = ["pkg/{goos}_{goarch}/**/cmd/**"],
),
)
@@ -91,6 +92,7 @@ def go_sdk_for_arch():
srcs = [":srcs"],
tools = [":tools"],
go = "bin/go{exe}",
+ version = go_version,
)
"""
@@ -211,10 +213,11 @@ load("@{rules_go}//go/private/rules:binary.bzl", "go_tool_binary")
load("@{rules_go}//go/private/rules:sdk.bzl", "package_list")
load("@{rules_go}//go:def.bzl", "go_sdk")
load("@{helpers}//:go_sdk.bzl", "go_sdk_for_arch")
+load(":go_version.bzl", "go_version")
package(default_visibility = ["//visibility:public"])
-go_sdk_for_arch()
+go_sdk_for_arch(go_version)
filegroup(
name = "headers",
@@ -265,7 +268,7 @@ def nixpkgs_go_configure(
repositories = {},
attribute_path = "go",
nix_file = None,
- nix_file_deps = None,
+ nix_file_deps = [],
nix_file_content = None,
nixopts = [],
fail_not_supported = True,
@@ -343,7 +346,7 @@ def nixpkgs_go_configure(
Args:
sdk_name: Go sdk name to pass to rules_go
attribute_path: The nixpkgs attribute path for the `go` to use.
- nix_file: An expression for a Nix environment derivation. The environment should expose the whole go SDK (`bin`, `src`, ...) at the root of package. It also must contain a `ROOT` file in the root of pacakge. Takes precedence over attribute_path.
+ nix_file: An expression for a Nix environment derivation. The environment should expose the whole go SDK (`bin`, `src`, ...) at the root of package. It also must contain a `ROOT` file in the root of package. Takes precedence over attribute_path.
nix_file_deps: Dependencies of `nix_file` if any.
nix_file_content: An expression for a Nix environment derivation. Takes precedence over attribute_path.
repository: A repository label identifying which Nixpkgs to use. Equivalent to `repositories = { "nixpkgs": ...}`.
@@ -362,19 +365,30 @@ def nixpkgs_go_configure(
rules_go_repo_name: The name of the rules_go repository. Defaults to rules_go under bzlmod and io_bazel_rules_go otherwise.",
"""
- if not nix_file and not nix_file_content:
- nix_file_content = """
- with import