better tree wide formatting#25
Conversation
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant Flake
participant treefmt-nix
participant Formatters
Developer->>Flake: Run `nix fmt` or `nix flake check`
Flake->>treefmt-nix: Delegate formatting/checking
treefmt-nix->>Formatters: Invoke appropriate formatter (alejandra, gofmt, prettier, etc.)
Formatters-->>treefmt-nix: Return formatting results
treefmt-nix-->>Flake: Aggregate results
Flake-->>Developer: Output formatted code or formatting check results
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure ✨ Finishing Touches🧪 Generate Unit Tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
flake.nix (1)
108-115:⚠️ Potential issue
lintscript references tools that are no longer on thePATH
statixanddeadnixwere removed fromdevShells.default.packages, yet thelintscript still calls them explicitly via${pkgs.statix}and${pkgs.deadnix}.
Because those packages are not part of the shell closure, the absolute store paths will not be realised and the commands will fail the first time the script is run.Two options:
- Re-add the packages:
packages = with pkgs; [ # Formatters and Nix tools treefmtEval.config.build.wrapper + statix + deadnix nixd ... ]
- Or delegate to
treefmt(preferred – avoids duplication):- ${pkgs.statix}/bin/statix check $REPO_ROOT/flake.nix - ${pkgs.deadnix}/bin/deadnix $REPO_ROOT/flake.nix + ${treefmtEval.config.build.wrapper}/bin/treefmt --fail-on-change
🧹 Nitpick comments (4)
flake.nix (4)
12-17: Pintreefmt-nixfor reproducible builds
treefmt-nixis currently fetched from the head of the default branch. As that branch moves forward, exactly-identical evaluations of this flake may suddenly start producing different results. Consider pinning the dependency to an explicit revision (e.g.github:numtide/treefmt-nix/<commit-sha>) or a tag to guarantee repeatability.
25-30: Minor pattern nit: unnecessaryselfrebindingThe
inputs @ { self, flake-utils, treefmt-nix, ... }:pattern already forwardsselfautomatically; there is no need to list it explicitly unless you want to make it shadowable.
Keeping only the required inputs (flake-utils,treefmt-nix,...) slightly simplifies the pattern and avoids accidental shadowing ofself.-outputs = inputs @ { - self, - flake-utils, - treefmt-nix, - ... -}: +outputs = inputs @ { flake-utils, treefmt-nix, ... }:
46-80: Duplicate/overlapping Go formatters may fight each otherBoth
gofmtandgofumpt(as well asgolines) rewrite code.
gofumptis a strict superset ofgofmt, so running them sequentially does not add value and may create unstable diffs if their rules ever diverge. A lighter configuration is to keep one canonical Go formatter (commonlygofumpt) and drop the others fromprograms.- gofmt.enable = true; + # gofmt is implied by gofumpt; enabling both is redundant gofumpt.enable = true; goimports.enable = true; golines.enable = true;
85-89: Expose a convenienceformatscript for contributors
treefmtEval.config.build.wrapperis correctly exposed viaformatter, but contributors accustomed to the previousformatscript will now get a “command not found”.
Adding a tiny alias keeps muscle-memory intact:dx = { … }; gx = { … }; +format = { + exec = ''${treefmtEval.config.build.wrapper}/bin/treefmt''; + description = "Format the entire tree"; +};
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
flake.lockis excluded by!**/*.lock
📒 Files selected for processing (1)
flake.nix(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: MacOS Build (aarch64-darwin)
- GitHub Check: test
Summary by CodeRabbit