Nixpkgs source formatters and code suggestion tools?

I 'm in the middle of review of my first packaged application and I’ll guess some of the comments and changes would have been easy catches for some automated tools. Discourse didn’t seem to contain anything about nixpkgs source code formatters nor code suggestion tools (e.g. hlint used in Haskell / some other linter like tools).

E.g. nixpkgs-hint could have said that

You do not need to enable parallel building if you use `qmake`.
Please, remove "enableParallelBuilding = true;" at line 15.

Similarly, a small & simple nixpkgs-frm could have checked some formatting conventions. To be helpful, there is no need to be super good coverage of every possible rule. Even some editor style & color modes could do here.

What tools people use / are there any?

There is an old thread about formatters Formatting rules for Nixpkgs

One thing to add to formatter discussion: if people do ask on review for stylistic changes, it would be really cool to have a commonly accepted style guide.

There are at least 2 competing formatters already packaged:

And I am also aware of 2 linters:

I used the first one of those a while ago, though it disagreed with some things you have to do for flakes and it became annoying. It hasn’t covered something like your example though. It was more about general nix (the language) linting, it was not really aware of any of the utility and builder functions from nixpkgs.

1 Like

There is also nixpkgs-hammering, which is much more strict than the others. It has some really good suggestions and explanations too – in fact, it will give an enableParallelBuilding suggestion very similar to your hypothetical nixpkgs-hint.