Many different tools are being developed for nix formatting and at this current moment I am still confused which one would be the best to use. Related to code formatting I see transformations to nix code as an equally important topic for automation that could take advantage of the parsers written for formatting. For example with nixpkgs derivations I would like to:
- sort all of the packages in
all-packages.nixalphabetically in groups
- enforce that in all python-modules that
checkInputsbe specified in the derivation in this specific order
- convert all http:// urls to https:// if they exist
- standardize all python package names to lowercase with dashes
All of these applications need an ast to represent the code (and preserve comments whitespace etc) thus they are highly tied to the concrete syntax trees in the nix formatters. I can envision that not everyone would like to write their transformations in rust, haskell, etc. I believe that it is important to have a text based IR (similar to llvm) that allows for tools to perform transformations that a nix formatter would not specifically think about. All this requires is that the formatter prints out an IR represention of the concrete syntax of the code and reads in the IR and perform the formatting.
If we achieve a standardized text based IR then we can use whatever language we like to transform the code.
Anyways wanted to post this here and hear other’s thoughts!