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:
parent
dc574abf54
commit
d08fda76a5
7 changed files with 64 additions and 9 deletions
|
|
@ -25,6 +25,17 @@ stdenv.mkDerivation {
|
|||
|
||||
impureEnvVars = [ "HOME" ];
|
||||
|
||||
# See xce.nix for why build_time is computed here (build phase) rather
|
||||
# than at flake-evaluation time.
|
||||
preConfigure = ''
|
||||
buildTime="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
if [ -z "$buildTime" ]; then
|
||||
echo "xcecli.nix: date -u produced an empty build time -- the -Dbuild_time= meson option would not reach the binary" >&2
|
||||
exit 1
|
||||
fi
|
||||
mesonFlagsArray+=("-Dbuild_time=$buildTime")
|
||||
'';
|
||||
|
||||
mesonFlags = [
|
||||
"-Dcomponent=xcecli"
|
||||
("-Dcommit_id=" + myCommitId)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue