Skip to content

feat: add treefmt-nix to dev flake - #708

Open
gabyx wants to merge 7 commits into
juspay:mainfrom
gabyx:feat/treefmt-nix
Open

feat: add treefmt-nix to dev flake#708
gabyx wants to merge 7 commits into
juspay:mainfrom
gabyx:feat/treefmt-nix

Conversation

@gabyx

@gabyx gabyx commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Things Done

Closes: #707

  • Added treefmt setup in dev flake to format treewide all files.
  • Needed to update nixpkgs since treefmt-nix needs a newer input.
  • Flake check in dev with nix flake check runs the formatting check. (Should be integrated in omnix by default?)
  • Replaced nixpkgs-fmt with treefmt on pre-commit.
  • .prettierrc.yaml in root (could be maybe somewhere else ...) to format all markdown files consistently.

How it works:

  • just format will format all files: Once happy with the setup one can format the files on main in one commit. The docs folder with the markdown files look well treated by prettier and there is not much to change I guess.

Note: When merging, one should apply just format on main directly afterwards as chore: formatting all files treewide

Assisted-by: no agent.

@gabyx
gabyx force-pushed the feat/treefmt-nix branch 4 times, most recently from 3722901 to 7b66cf6 Compare July 25, 2026 10:18
@gabyx
gabyx marked this pull request as ready for review July 25, 2026 10:22
@gabyx gabyx changed the title feat: add treefmt nix to dev flake feat: add treefmt-nix to dev flake Jul 25, 2026
@gabyx

gabyx commented Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

@shivaraj-bh: Could you maybe run just format on that branch and check how it looks?

@shivaraj-bh

Copy link
Copy Markdown
Member

@gabyx Why use treefmt-nix when pre-commit has a nixfmt hook?

@gabyx

gabyx commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@shivaraj-bh : Cause running hooks and formatting are two orthogonal things. Running hooks is fine but having one global process which formats treewide (with caching) is something which is not super easy achievable with hooks.

Running the format step (the exact same treefmt build and not again another nixfmt hook) in pre-commit is however the better option IMO.
Also you dont need to worry about other formats, its covered all.

Treefmt is awesome btw :). Once used you will probably deploy it everywhere :) (We did so and its a game changer :))

@shivaraj-bh

Copy link
Copy Markdown
Member

Running hooks is fine but having one global process which formats treewide (with caching) is something which is not super easy achievable with hooks.

I run pre-commit run nixpkgs-fmt which formats treewide. It doesn’t cache though. Since speed was never (not yet) really a problem I didn’t bother switching.

Treefmt is awesome btw :). Once used you will probably deploy it everywhere :) (We did so and its a game changer :))

I agree. I use it in multiple projects. I don’t mind adding it here.

Comment thread dev/nix/treefmt.nix Outdated
Comment thread justfile Outdated
Comment thread justfile Outdated
@shivaraj-bh

shivaraj-bh commented Aug 11, 2026

Copy link
Copy Markdown
Member

@shivaraj-bh: Could you maybe run just format on that branch and check how it looks?

@gabyx looks good. I will merge this and then format in a different PR.

EDIT: or maybe just another commit in the same PR and then “Rebase and merge"

@gabyx
gabyx force-pushed the feat/treefmt-nix branch 4 times, most recently from 1a697f7 to 38c8334 Compare August 12, 2026 07:10
@gabyx

gabyx commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@srid: Last commit contains all changes for an inspection.

@gabyx
gabyx force-pushed the feat/treefmt-nix branch from 38c8334 to abde338 Compare August 12, 2026 07:11
- Run `treefmt` directly.
- Comment on `justfile`.

Signed-off-by: Gabriel Nützi <gnuetzi@gmail.com>
@gabyx
gabyx force-pushed the feat/treefmt-nix branch from abde338 to 2159bb7 Compare August 12, 2026 07:12
@shivaraj-bh

Copy link
Copy Markdown
Member

Thanks @gabyx !

Let me know if it is good for me to take over. I will squash the existing commits into one; add a treewide format commit; run CI; Rebase and merge.

@gabyx

gabyx commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@srid: Yes, its good, to take over, thanks a lot.

@gabyx

gabyx commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@srid: maybe some precaution, maybe check the documentation is not destroyed, since markdown files are formatted, if yes -> let me know -> set a global ignore until the markdown is fixed. It looked good, but just saying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: add treewide formatting with nixfmt and others

3 participants