From b3dc9ccd7a5be7dc07cef60707fe6eab41e1cf76 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) (cherry picked from commit d88c63d4bab1db59398ad0603292abd222b1ec48) --- 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 c033beabdbb37..f8ad4187af7d5 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -401,6 +401,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 } }