juspay / services-flake

NixOS-like services for Nix flakes
https://community.flake.parts/services-flake
MIT License
390 stars 31 forks source link

chore(nix): Remove treefmt #393

Closed srid closed 6 days ago

srid commented 6 days ago

We already use pre-commit and that supports nixpkgs-fmt.

cf. https://github.com/srid/haskell-template/pull/144

Also, this PR updates git-hooks.nix while making a non-flake thereby reducing the number of lock file (dev/flake.lock) entries.

shivaraj-bh commented 6 days ago

The stdout when there is something to be formatted:

services-flake on  main [$!] via ❄️  impure (nix-shell-env) took 6s
❯ just fmt
pre-commit run -a
nixpkgs-fmt..............................................................Failed
- hook id: nixpkgs-fmt
- files were modified by this hook

flake.nix
1 / 8 have been reformatted
0 / 8 have been reformatted
0 / 8 have been reformatted
0 / 8 have been reformatted
0 / 8 have been reformatted
0 / 8 have been reformatted
0 / 8 have been reformatted
0 / 3 have been reformatted

error: Recipe `fmt` failed on line 29 with exit code 1

The error at the end is a bit misleading because it makes one think that formatting didn’t run successfully.

srid commented 5 days ago

I should have thought more on this.

pre-commit does not have a notion of "run all hooks unconditionally". Let's just get rid of the fmt target entirely, and briefly document pre-commit in the README like haskell-template now does:

https://github.com/srid/haskell-template/commit/b224c24f7db6afea775d80a994c12ded162ecbf4

Besides, fmt naming is now inaccurate anyway - since you can do more than formatting (e.g.: run hlint).