nixfmt icon indicating copy to clipboard operation
nixfmt copied to clipboard

Add a section to the README about formatting philosophy

Open jfly opened this issue 7 months ago • 4 comments

There's this General section buried in our repo here: https://github.com/NixOS/nixfmt/blob/master/standard.md#general, let's promote some of it to the README.

jfly avatar May 13 '25 19:05 jfly

There's this General section buried in our repo here: https://github.com/NixOS/nixfmt/blob/master/standard.md#general, let's promote some of it to the README.

What about merely linking to the standard.md file in the README.md instead of partially duplicating content?

This could be done as a single concise sentence somewhere towards the beginning of the README.md.

trueNAHO avatar Dec 16 '25 21:12 trueNAHO

That sounds good to me, @trueNAHO. Want to send in a PR?

jfly avatar Dec 17 '25 15:12 jfly

Linking to the standard is great, but I don't think that alone should close this issue.

The initial intent was to make clear in the README that Nixfmt doesn't try to be a purely deterministic formatter, where a given nix expression is always formatted the same way regardless of how it was originally formatted. Instead, Nixfmt takes the user's intentions into account, especially when it comes to whitespace.

We do have some hints at that philosophy in the standard, but we wanted a summary of the philosophy to be one of the first things people see when reading about Nixfmt in the README.

(Sorry I've let this sit idle)

MattSturgeon avatar Dec 17 '25 21:12 MattSturgeon

Linking to the standard is great, but I don't think that alone should close this issue.

The initial intent was to make clear in the README that Nixfmt doesn't try to be a purely deterministic formatter, where a given nix expression is always formatted the same way regardless of how it was originally formatted. Instead, Nixfmt takes the user's intentions into account, especially when it comes to whitespace.

We do have some hints at that philosophy in the standard, but we wanted a summary of the philosophy to be one of the first things people see when reading about Nixfmt in the README.

Without adding a dedicated section just for this one point, this could be concisely added to the proposed sentence from https://github.com/NixOS/nixfmt/pull/361:

diff --git a/README.md b/README.md
index 787c75f..bfc6c23 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
 # Nixfmt

 Nixfmt is the official formatter for Nix language code.
-The standard Nix format is defined in [standard.md](./standard.md).
+The standard Nix format incorporates artistic formatting and is defined in [standard.md](./standard.md).
 It is maintained by the [Nix formatting team](https://nixos.org/community/teams/formatting/).
 This document is the user documentation, see [CONTRIBUTING.md](./CONTRIBUTING.md) for contributor documentation.

IMHO, if you just want to add this one point to the synopsis, then adding a dedicated section would be worse than adding a concise sentence. Unless you want to add a lot of lengthy explanations, the sentence can be neatly extended as follows:

The standard Nix format incorporates artistic formatting, <POINT_2>, <POINT_3>, <POINT_n>, and is defined in standard.md.

trueNAHO avatar Dec 18 '25 22:12 trueNAHO