Skip to content

Commit

Permalink
[tailscale] cmd/dist: support embedding of toolchain rev by env var
Browse files Browse the repository at this point in the history
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 <jz@tailscale.com>
(cherry picked from commit 6a17f14)
(cherry picked from commit d88c63d)
  • Loading branch information
phirework authored and bradfitz committed Aug 21, 2024
1 parent 179980e commit b3dc9cc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/cmd/dist/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit b3dc9cc

Please sign in to comment.