input-output-hk / bitte

Nix Ops for Terraform, Consul, Vault, Nomad
Apache License 2.0
155 stars 15 forks source link

Consider adding a code formatter #42

Open nrdxp opened 3 years ago

nrdxp commented 3 years ago

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

kaii-zen commented 3 years ago

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.

manveru commented 3 years ago

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 :)

nrdxp commented 3 years ago

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.

blaggacao commented 2 years ago

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.