Skip to content

Conversation

@shimeoki
Copy link

nixfmt 1.0.0 added an --indent=INT option to configure indentation width. this PR adds this option to nixfmt-rfc-style settings to avoid using args = [ "--indent=X" ].

aside from that, i didn't like how options were handled previously, so i refactored it a bit. if this is too much (because the solution is a bit hacky and it's still not DRY), only the first commit with the feature itself without any refactoring is available - i can do a force push to it.

also, the indent option description should probably be "Indentation width.". noticed that only while writing the PR description.

@sandydoo sandydoo added the enhancement New feature or request label Sep 17, 2025
@sandydoo
Copy link
Member

nixpkgs 25.11 is going to ship nixfmt 1.0, making nixfmt-rfc-style obsolete. I've updated the nixfmt hook on master to prepare for this.

If we want to ship this option, it needs to be added to hooks.nixfmt as well. There also needs to be a version check when using the option to keep it backwards compatible with 25.05.

Don't worry to much about making it pretty or trying to dedupe the code. This will be taken care of in the module transition.
For the arguments, you can use mkCmdArgs to avoid writing a custom one-off helper.

shimeoki and others added 5 commits October 29, 2025 20:48
because otherwise there is no way to enable it, as i understand, and
adding options to it is pointless
- use original description from the cli
- use 'with types' for readability
add new options for the nixfmt hook as well
also check version for indent in nixfmt and nixfmt-rfc-style hooks
@shimeoki
Copy link
Author

sorry for the late reply.

  • added the indent option for the nixfmt as well
  • changed the descriptions for the options in nixfmt and nixfmt-rfc-style to match the cli help
  • used mkCmdArgs

for both nixfmt and nixfmt-rfc-style i did a check for below 1.0.0 to throw an error if indent is used.

also, i am not very sure about this, but i removed the visible = false for the nixfmt hook. i think the visibility was off because it was deprecated, but i suppose it's not the case anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants