-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go 1.20 does not provide a `goos_goarch` folder for the standard library anymore. And the `go_sdk` function from rules_go now accepts a `version` parameter.
- Loading branch information
Showing
4 changed files
with
75 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Exactly one of goAttrPath or goExpr must be set. | ||
# If a custom `goExpr` derivation is provided by the user, we add the `go_version.bzl` file to it. | ||
# Otherwise we create a toolchain based on the `goAttrPath` attribute path from <nixpkgs> | ||
|
||
let | ||
pkgs = import <nixpkgs> { | ||
config = { }; | ||
overlays = [ ]; | ||
}; | ||
in args@{ goAttrPath ? null, goExpr ? null }: | ||
let | ||
getVersion = s: | ||
s.version or (throw | ||
"nix_pkgs_go_configure: the provided go derivation should contain a `version` attribute."); | ||
|
||
bazelGoToolchain = args.goExpr or (let | ||
goAttr = | ||
pkgs.lib.attrByPath (pkgs.lib.splitString "." goAttrPath) null pkgs; | ||
in pkgs.buildEnv { | ||
name = "bazel-go-toolchain"; | ||
paths = [ goAttr ]; | ||
postBuild = '' | ||
touch $out/ROOT | ||
ln -s $out/share/go/{api,doc,lib,misc,pkg,src} $out/ | ||
''; | ||
} // { | ||
version = getVersion goAttr; | ||
}); | ||
|
||
goVersionFile = pkgs.runCommand "bazel-go-toolchain-go-version" { } '' | ||
mkdir $out | ||
echo 'go_version = "${getVersion bazelGoToolchain}"' >> $out/go_version.bzl | ||
''; | ||
|
||
in pkgs.symlinkJoin { | ||
name = "bazel-go-toolchain"; | ||
paths = [ bazelGoToolchain goVersionFile ]; | ||
} |