Skip to content

Improving flake formatting experienceΒ #273

Open
@GaetanLepage

Description

In order to have your flake formatted with nixfmt-rfc-style, you have two options:

  1. Setting formatter = pkgs.nixfmt-rfc-style;. This solution is concise (ignoring the fact that the name "nixfmt-rfc-style" is not really intuitive compared to simply "nixfmt").
    However, this is not expected to be supported for long as: Passing directories or non-Nix files (such as ".") is deprecated and will be unsupported soon, please use https://treefmt.com/ instead, e.g. via https://github.com/numtide/treefmt-nix.
  2. Using treefmt-nix. While it is for sure a great, very flexible and powerful tool, it is quite overkilled if you simply want to format a small nix-only code base. It's major con is having to add both several lines of code and an extra dependency, simply to achieve what the first solution is doing.

I think it should be great to support the existing formatter = pkgs.nixfmt[-rfc-style]; syntax as it gives a very efficient and user-friendly way to format a flake while keeping it lean code and input wise.

In the long term, I could see the benefit of further "officializing" the nixfmt formatter and having a format = true; flag to automatically format the flake. This would have to be thought more.

cc @infinisil

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status

      Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions