feat(build-time-versioning): nix packages compute build time at build phase

First attempt used builtins.currentTime at flake-evaluation time -- this
broke the plain, documented `nix build .#xcecore_debug` command entirely
(pure-eval strips builtins.currentTime, requiring --impure) and produced
a raw epoch-seconds string instead of UTC ISO-8601. Caught by task-local
review (REJECTED, round 1) before merge.

Fixed by moving the computation into each derivation's own build phase:
a preConfigure hook in xce.nix/xcecli.nix runs `date -u` (stdenv's
bundled coreutils, unaffected by pure-eval) and appends -Dbuild_time= to
mesonFlagsArray, with a fail-loud guard against empty output. commit_id's
existing self.shortRev/self.dirtyShortRev eval-time mechanism is
untouched. Verified via nix eval (no --impure) and nix build reaching
configure with real values on both xcecore_debug and xcecli (round 2,
APPROVED).

Task 2.2/13 of build-time-versioning. Also corrects design.md/research.md,
which described the now-superseded builtins.currentTime approach.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-08-20 09:32:34 +00:00
parent dc574abf54
commit d08fda76a5
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
7 changed files with 64 additions and 9 deletions

View file

@ -4,6 +4,12 @@
...
}:
let
# NOTE (build-time-versioning task 2.2, remediation round): build-time is
# no longer threaded through here -- it's computed inside each
# derivation's own build phase (xce.nix/xcecli.nix `preConfigure`), since
# builtins.currentTime is unavailable under flake pure-eval. Only
# myCommitId (a genuine eval-time/flake-level value) still needs to be
# passed down.
xcecore = pkgs.callPackage ./xce.nix {
inherit pkgs myCommitId;
withDebug = false;