Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom tag to go_sdk #3546

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ylecornec
Copy link
Contributor

Depends on #3543

What type of PR is this?

Feature

What does this PR do? Why is it needed?

This PR adds a new custom tag to the go_sdk module extension.
This tag is used to declare custom go toolchains to rules_go, to take them into consideration when creating the go_host_compatible_sdk repository introduced in #3543.

Which issues(s) does this PR fix?
See bazel-contrib/bazel-gazelle#1469

Other notes for review

  • The attribute of the custom tag is not directly the label of a toolchain, but the label of a file containing a toolchain variable. This way the file can be generated by the user in a repository rule (and the toolchain variable can be set to None to be deactivated if some conditions are not met).

  • Custom toolchains have precedence over other ones (defined in the same module) because the user can deactivate them if needed.

@fmeum
Copy link
Member

fmeum commented Apr 25, 2023

Thanks for performing the split.

This adds sufficient complexity that I would first want to get back to the formulating the exact use case(s) we are trying to address with it. Non-Bzlmod rules_go offers go_wrap_sdk, which I think may help us here as well.

@ylecornec If we had e.g. go_sdk.wrap(root_files = {"linux_amd64": "@my_nix_go_sdk//:ROOT"}), would that adress your use case? If not, could you provide more details including perhaps some code snippets to explain how you fetch your SDKs?

@ylecornec
Copy link
Contributor Author

Ah, something like go_sdk.wrap is close, but to replicate the setup of non bzlmod rules_haskell, the @my_nix_go_sdk//:ROOT value would need to depend on some environment variable (to test whether we are in a nix-shell or not).

Here is an example use-case that replicates this with bzlmod (using the custom tag) and has more details in the README.
(The nix toolchains are defined in non_module_deps.bzl using nixpkgs_go_configure).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants