Capture the version of Nix in addition to the nix store version#108
Capture the version of Nix in addition to the nix store version#108
Conversation
✅ Deploy Preview for detsys-ts-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
WalkthroughAdds a Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Runner as Action Runner
participant Pre as Preflight
participant Nix as Nix CLI
participant Facts as Facts Store
Runner->>Pre: preflight()
Note over Pre: existing preflight steps (e.g., preflightNixStoreInfo)
Pre->>Nix: `nix --version` (silent)
Nix-->>Pre: stdout (version) or error
Pre->>Facts: addFact("nix_version", version or "unknown")
Pre-->>Runner: preflight complete
sequenceDiagram
autonumber
actor Runner as Action Runner
participant Main as Main Execution
participant Nix as Nix CLI
participant Facts as Facts Store
Runner->>Main: run main()
Main-->>Runner: main complete
Note over Runner: before shutdown/cleanup
Runner->>Nix: `nix --version` (silent) [preflightNixVersion]
Nix-->>Runner: stdout (version) or error
Runner->>Facts: addFact("nix_version", version or "unknown")
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/index.ts (3)
50-50: Please document the new factAdd a short note in the README/docs explaining the new
nix_versionfact (format, when it’s set, possible value"unknown").I can draft the doc blurb if you want.
517-519: Move the second nix-version probe to finally to capture error pathsIf
main()throws, the post-main()probe won’t run. Move it tofinally(guarded byisMain) so shutdown/exception events also have the updated version.Apply this removal near the end of the main block:
- // Run the preflight of the nix version a second time so our "shutdown" events have updated version info. - await this.preflightNixVersion();Then insert before
await this.complete();in thefinallyblock:// Ensure shutdown/exception events have the latest nix version too if (this.isMain) { try { await this.preflightNixVersion(); } catch { // ignore } }Also applies to: 524-526
1113-1130: Normalize the captured version to just the numeric component
nix --versionoften returns strings like “nix (Nix) 2.24.0”. Storing only the version number makes downstream analytics/filters simpler while keeping compatibility when the command output changes slightly.- this.addFact(FACT_NIX_VERSION, output); + const match = output.match(/\b\d+(?:\.\d+)+\b/); + this.addFact(FACT_NIX_VERSION, match?.[0] ?? output);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (3)
dist/index.d.tsis excluded by!**/dist/**dist/index.jsis excluded by!**/dist/**dist/index.js.mapis excluded by!**/dist/**,!**/*.map
📒 Files selected for processing (1)
src/index.ts(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/index.ts (1)
dist/index.js (2)
output(1588-1588)output(1628-1628)
⏰ 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). (1)
- GitHub Check: Run all checks
🔇 Additional comments (2)
src/index.ts (2)
50-50: New FACT_NIX_VERSION constant — LGTMConsistent naming and placement with existing fact keys.
1113-1130: No rebuild needed; dist is up to date
dist/index.js already defines FACT_NIX_VERSION (line 899) and invokesnix --version(line 1632).
bd53edf to
12a8d93
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/index.ts (2)
524-526: Run the “final” nix_version capture even on failure.Right now, if main() throws, the second capture won’t run. Prefer moving this to finally so shutdown/exception events always include the latest version.
Apply this diff:
@@ if (this.isMain) { await this.main(); - - // Run the preflight of the nix version a second time so our "shutdown" events have updated version info. - await this.preflightNixVersion(); } else if (this.isPost) { await this.post(); } @@ } finally { + // Ensure shutdown/exception events carry the latest Nix version. + await this.preflightNixVersion(); if (this.isPost) { await this.collectBacktraces(); } await this.complete(); }
1113-1131: Also record a parsed/normalized version for easier analytics.Keep nix_version as-is, but additionally extract a semver-like token when present. This avoids downstream parsing in analytics queries.
Apply these diffs:
@@ -const FACT_NIX_VERSION = "nix_version"; +const FACT_NIX_VERSION = "nix_version"; +const FACT_NIX_VERSION_SEMVER = "nix_version_semver";private async preflightNixVersion(): Promise<void> { let output = "unknown"; try { ({ stdout: output } = await actionsExec.getExecOutput( "nix", ["--version"], { silent: true, }, )); output = output.trim() || "unknown"; } catch { // That's fine. } this.addFact(FACT_NIX_VERSION, output); + // Try to pull out a semver-ish token, e.g., "2.24.2" from "nix (Nix) 2.24.2". + const m = output.match(/\b\d+\.\d+\.\d+(?:[0-9A-Za-z.-]*)?\b/); + if (m?.[0]) { + this.addFact(FACT_NIX_VERSION_SEMVER, m[0]); + } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (4)
dist/index.d.tsis excluded by!**/dist/**dist/index.jsis excluded by!**/dist/**dist/index.js.mapis excluded by!**/dist/**,!**/*.mappnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
package.json(1 hunks)src/index.ts(5 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/index.ts (1)
dist/index.js (2)
output(1588-1588)output(1628-1628)
⏰ 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). (1)
- GitHub Check: Run all checks
🔇 Additional comments (6)
package.json (2)
30-35: Deps bumps look fine.ESM-only packages like got are consistent with "type": "module". Nothing blocking here.
38-52: Compatibility confirmed: eslint-plugin-github v6 and @typescript-eslint/eslint-plugin v8 support ESLint v9.34.0
Both plugins declare support for ESLint v9 (>= 9.0.0) and are compatible with v9.34.0—no further changes needed.src/index.ts (4)
50-51: New fact key is well-scoped.FACT_NIX_VERSION name is clear and consistent with existing fact keys.
245-246: Facts map now allows numbers — good future-proofing.This aligns with potential numeric fact values without forcing stringification.
403-405: addFact signature widening is backward-compatible.Public API remains source-compatible while supporting numeric values.
512-519: Capturing nix_version early is the right call.Recording it alongside store info improves event context.
Description
Checklist
Summary by CodeRabbit
New Features
Bug Fixes
Chores
Notes