bitte icon indicating copy to clipboard operation
bitte copied to clipboard

Consider adding a code formatter

Open nrdxp opened this issue 4 years ago • 4 comments

I've been using nixfmt in accordance with @manveru's preference since I started, but I've come to notice that not everyone seems to be doing this. This leads to larger diffs in commits than is really necessary. I can add a pre-commit hook to run a formatter, but I'd first like to gain a bit of feedback about which to use.

The only real contenders at this point are nixfmt and nixpkgs-fmt. While I actually agree that nixfmt has nicer output atm, my vote would be for nixpkgs-fmt simply because it seems to be what nixpkgs will eventually use, and so it's more likely to not be abandoned.

/cc @jonringer @kreisys @johnalotoski @sevanspowell @cleverca22

nrdxp avatar Jul 06 '21 22:07 nrdxp

I'm good with anything that's applied consistently. I think I like the output of nixpkgs-fmt better but I'm too lazy to double check atm.

kaii-zen avatar Jul 07 '21 17:07 kaii-zen

I format everything with nixfmt automatically, so please stick to that. And yes, I have a hook for that in git, but applying that for everyone is kinda hard. This might actually be a good first step for the new ci.nix :)

manveru avatar Jul 07 '21 17:07 manveru

devshell has a way of setting git hooks inside a nix-shell. Perhaps we could just steal that? I am currently using it in DevOS to run a formatter there as well.

nrdxp avatar Jul 07 '21 17:07 nrdxp

https://github.com/input-output-hk/makes/blob/main/src/evaluator/modules/format-nix/entrypoint.sh must be amended & maintained if it will be nixfmt.

blaggacao avatar Sep 30 '21 19:09 blaggacao