feat(plugin-go): support target-ref Go toolchain (host bin, nix)#113
Open
raphaelvigee wants to merge 1 commit into
Open
feat(plugin-go): support target-ref Go toolchain (host bin, nix)#113raphaelvigee wants to merge 1 commit into
raphaelvigee wants to merge 1 commit into
Conversation
`gotool` now accepts a third form besides "host" and a pinned version: a
target address starting with `//` that produces the `go` toolchain — e.g.
`//@heph/bin:go` (host `go` via the hostbin provider) or `//some/pkg:go`
(a `go` built by the nix driver).
Classify `gotool` via `toolchain::classify` -> Toolchain::{Host, Target,
Hermetic}. In target mode the build deps that address in the `gosdk` group
(read-only staged like the hermetic SDK) and passes the host module/cache
env through. The staged path isn't known ahead of time, so `go`/`GOROOT`
are resolved from the staged output at runtime, auto-detecting a full
GOROOT tree (a directory whose `bin/go` is used) vs. a bare `go` binary:
- sh/exec targets: prelude reads `$SRC_GOSDK` and derives GOROOT from
`go env GOROOT`.
- golist driver (in-process): finds the `dep|gosdk|*` input, walks its
artifact for `go`-named entries, prefers `.../bin/go` over a wrapper,
then queries `go env GOROOT`.
Contract: the target must expose exactly one output — a `go` binary file
or a GOROOT directory containing `bin/go`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
gotoolnow accepts a third form besides"host"and a pinned version: a target address starting with//that produces thegotoolchain.gotool"1.26.4""//@heph/bin:go""//some/pkg:go"How
Classify
gotoolviatoolchain::classify→Toolchain::{Host, Target(&str), Hermetic(&str)}.In target mode the build deps that address in the
gosdkgroup (read-only staged like the hermetic SDK) and passes the host module/cache env through (thirdparty modcache + wrapperPATH/HOME). The staged path isn't known ahead of time, sogo/GOROOTare resolved from the staged output at runtime, auto-detecting a full GOROOT tree (a directory whosebin/gois used) vs. a baregobinary:go_goroot_prelude): prelude reads$SRC_GOSDK; dir →$GOSDK/bin/go, file → thegobinary; thenGOROOT="$("$GO" env GOROOT)".dep|gosdk|*ManagedRunInput, walks its artifact forgo-named entries,pick_go_binaryprefers.../bin/goover a bare wrapper, thengo_env_gorootqueriesgo env GOROOT(renamed fromhost_goroot, now shared by host + target).Contract: the target must expose exactly one output — a
gobinary file or a GOROOT directory containingbin/go.Files
toolchain.rs—Toolchainenum,classify,is_target_ref+ module docs.addr_util.rs—go_sdk_dep/go_host_runtime_pass_env/go_goroot_preludehandle all three kinds.driver_golist.rs— Target branch,resolve_target_go,pick_go_binary,host_goroot→go_env_goroot, PATH passthrough for non-hermetic.provider.rs—gotooldocs + error message.Tests
279 plugin-go tests pass; production clippy clean. New unit tests cover classify, per-kind dep wiring, target env + read-only staging, prelude auto-detect, and
pick_go_binarypreference. No e2e (needs network + real nix/host go); coverage targets the pure logic.Caveat
Nix wrappers reference
/nix/store; the go build sandbox must be allowed to read/nix/storeat runtime. That's a sandbox-exposure concern outside this plugin's wiring.🤖 Generated with Claude Code