🤖 fix: stamp real version in Nix flake builds - #3686
Conversation
Nix strips .git from the build sandbox, so generate-version.sh's git describe/rev-parse fell back to "unknown" and the title bar showed "unknown". Feed the revision the flake already resolves (self.rev / dirtyRev) into the build via RELEASE_TAG + a new GIT_COMMIT override.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f7a292e2f4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
Plain GIT_COMMIT is exported ambiently by some CI systems (Jenkins), which could pair a stale commit with HEAD's describe.
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Nix flake builds displayed
unknownas the app version (top-left title bar and About dialog) because the version stamp could never be computed inside the build sandbox. This feeds the revision the flake already knows into the build so the version is stamped correctly.Background
The version shown in the UI comes from
src/version.ts, which is generated at build time byscripts/generate-version.shusinggit describe --tags --always --dirtyandgit rev-parse --short HEAD. Both fall back to the literal string"unknown"when the git commands fail.Nix copies only git-tracked files into the build sandbox and strips the
.gitdirectory, so those git commands have no repository to read and both fall back to"unknown". HavinggitinnativeBuildInputsonly provides the binary, not the repo metadata, so it doesn't help.Ironically the flake already computes the revision (
version = self.rev or self.dirtyRev or "dev") but never passed it into the build, so that value was discarded before the script ran.Implementation
The version script already supports a
RELEASE_TAGoverride that skips the git calls and setsgit_describedirectly (used by CI release builds). The flake'sbuildPhasenow exports that revision:RELEASE_TAG="${version}"setsgit_describe.GIT_COMMIT="${builtins.substring 0 12 version}"sets the commit field via a new override.generate-version.shnow honors an incomingGIT_COMMITenv var, keeping the git-based default when it's unset so non-Nix builds are unchanged.Risks
Low. The change only affects build-time version stamping. Non-Nix builds keep their existing git-based behavior (the
GIT_COMMITdefault is unchanged when the env var is unset), and the script'sunknownfallback still applies when neither git nor overrides are available.One cosmetic note: Nix dev builds now log
Release build: using RELEASE_TAG=...in build output, which is slightly misleading but harmless.Generated with
mux• Model:anthropic:claude-opus-4-8• Thinking:xhigh• Cost:$1.11