Skip to content

Automatic code formatting for nixos/nix #3697

@bburdette

Description

@bburdette

It would be great if there was a recommended formatting tool and config file for the nix project. Working on the last nix-errors PR I spent a few days trying to find a tool that would match the existing formatting, but I wasn't able to get anything to work perfectly. That PR was already huge, so a bunch of noise from reformatting would not have helped matters.

I tried astyle, uncrustify, and clang-format. Uncrustify was probably closest - its has a ton of configuration options. Astyle was also decent, arguably because it mostly leaves the code alone compared to the others. clang-format was in third place for me, but perhaps it could have been made to work by spending more time on it. I didn't save my config attempts with that one.

Here's where I left off with uncrustify:
uncrustify.cfg.txt

And here's a diff with the default uncrustify settings:
uncrustify.diff.txt

Unfortunately I don't appear to have saved my astyle settings, but its way less involved than the above. I'd like to hear if anyone has had more luck than me with formatting!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions