jtojnar / nixpkgs-hammering

Beat your package expressions into a shape
MIT License
253 stars 15 forks source link

attribute-ordering: Add attribute ordering check #6

Closed jtojnar closed 4 years ago

jtojnar commented 4 years ago

Based on https://discourse.nixos.org/t/document-attribute-ordering-in-package-expressions/4887.

cc @worldofpeace

worldofpeace commented 4 years ago

The ordering documented here is exactly as what seems to be, i guess logically, the preferred order.

Edit: I thing I remembered that I do is *Inputs and mesonFlags (etc.) are alphabetized. I do this with a editor plugin, but I wonder if it would be a good idea to either mention that in docs. It could be nice to do that with the tool also.

jtojnar commented 4 years ago

I wanted to add meta orderings and output orderings but was not sure if it should all be in attribute-ordering linter. The former maybe, the latter probably not.

*Inputs will be hard, as the Nix code is not aware what are the value names, only the values. I guess we could approximate it by taking drv.name but it would be far from perfect. Ideally, we could also access Nix AST but I have not yet came up with a battle plan (will need to choose between rnix and hnix).

I am still not 100% on mesonFlags alphabetization, there are some benefits to having the same order as meson_options.txt, yet alphabetization makes sense too. I will think on it some more.