From d88c63d4bab1db59398ad0603292abd222b1ec48 Mon Sep 17 00:00:00 2001 From: Jenny Zhang Date: Wed, 21 Jun 2023 14:26:30 -0400 Subject: [PATCH] [tailscale] cmd/dist: support embedding of toolchain rev by env var Git checkouts are not reproducible (in particular, the .git directory's hashes vary according to the moods of git re: packing and other local settings), so building our Go toolchain via Nix leads to source hashes that change from machine to machine and over time. Since Nix already knows the exact git revision it's building from, this change lets Nix provide that hash to cmd/dist directly, skipping the rooting around in .git to find the right hash. Signed-off-by: Jenny Zhang (cherry picked from commit 6a17f14) --- src/cmd/dist/build.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index 32e59b446a5d9..a687709300a10 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -393,6 +393,12 @@ func findgoversion() string { // its content if available, which is empty at this point. // Only use the VERSION file if it is non-empty. if b != "" { + if rev := os.Getenv("TAILSCALE_TOOLCHAIN_REV"); rev != "" { + if len(rev) > 10 { + rev = rev[:10] + } + b += "-ts" + chomp(rev) + } return b } }