nix flake check: Show which outputs failed or succeeded#285
Conversation
Cherry-picked from #217.
WalkthroughThe pull request refactors attribute path formatting and flake check logic. A new helper function Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/nix/flake.cc (1)
850-877: Build result reporting logic is sound, but map lookups could be safer.The three-phase reporting (successes, cancellations, failures) provides clear user feedback. However, using
operator[]on the map (lines 856, 862, 872) will silently insert empty vectors ifbuildResult.pathisn't found, which could mask issues during debugging.Consider using
.find()or.at()for defensive lookups:- for (auto & attrPath : (*derivedPathToAttrPaths)[buildResult.path]) + auto it = derivedPathToAttrPaths->find(buildResult.path); + if (it != derivedPathToAttrPaths->end()) + for (auto & attrPath : it->second)Alternatively, use
.at()to get an exception if the path is unexpectedly missing, which would surface bugs earlier.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/libexpr/eval-cache.cc(1 hunks)src/libexpr/include/nix/expr/eval-cache.hh(1 hunks)src/nix/flake.cc(5 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/nix/flake.cc (3)
src/libstore/include/nix/store/store-api.hh (4)
drvPath(684-684)drvPath(769-769)drvPath(774-774)drvPath(779-779)src/libstore/include/nix/store/legacy-ssh-store.hh (1)
drvPaths(142-143)src/libexpr/eval-cache.cc (2)
toAttrPathStr(382-385)toAttrPathStr(382-382)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build_aarch64-darwin / build
- GitHub Check: build_x86_64-linux / build
🔇 Additional comments (4)
src/libexpr/include/nix/expr/eval-cache.hh (1)
16-18: LGTM! Clean API addition for attribute path handling.The new
AttrPathtype alias andtoAttrPathStrfunction provide a reusable way to format attribute paths outside ofAttrCursorcontext, which is needed for the flake check reporting feature.src/libexpr/eval-cache.cc (1)
382-395: LGTM! Good refactoring to extract common attribute path formatting.The
toAttrPathStrhelper centralizes the attribute path formatting logic, and theAttrCursormethods now delegate to it appropriately. This enables reuse fromflake.ccfor build result reporting.src/nix/flake.cc (2)
637-643: Attribute path tracking for checks is implemented correctly.The code properly records the mapping before moving
derivedPath, avoiding use-after-move. The attribute path usesSymbolvalues which are efficient indices into the symbol table.
886-889: Clean exit handling for error conditions.Using
throw Exit(1)provides a proper exit code without a stack trace, which is appropriate for user-facing build failures. Thestd::atomic_bool hasErrorscorrectly aggregates errors from parallel evaluation and build phases.
This is already implied by the fact that it inherits from std::variant.
Motivation
Similar to #281, this makes
nix flake checkprint at the end which flake outputs failed or succeeded to build.Cherry-picked from #217.
Also fixes a potential crash in
nix flake checkwhen parallel eval is enabled.Context
Summary by CodeRabbit
Refactor
Bug Fixes
Breaking Change
✏️ Tip: You can customize this high-level summary in your review settings.