-
-
Notifications
You must be signed in to change notification settings - Fork 63
Implement treefmt's stdin spec #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| toTargets Nixfmt{files = [], filename} = pure [stdioTarget filename] | ||
| toTargets Nixfmt{files = ["-"], filename} = pure [stdioTarget filename] | ||
| toTargets Nixfmt{files = [], stdin_filepath = Just filepath} = pure [stdioTarget filepath] | ||
| toTargets Nixfmt{files = _ : _, stdin_filepath = Just _} = error "Cannot specify both positional files and --stdin-filepath" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems wrong to me. Should I instead change the return type of toTargets? Pointers appreciated.
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/formatting-team-meeting-2025-11-11/72019/4 |
This completes #305
jfly
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed in today's team meeting. Let's preserve the old behavior (with deprecation warnings), and then sit and wait for treefmt to finalize the stdin spec.
| toTargets :: Nixfmt -> IO [Target] | ||
| toTargets Nixfmt{files = [], filename} = pure [stdioTarget filename] | ||
| toTargets Nixfmt{files = ["-"], filename} = pure [stdioTarget filename] | ||
| toTargets Nixfmt{files = [], stdin_filepath = Just filepath} = pure [stdioTarget filepath] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| toTargets Nixfmt{files = [], stdin_filepath = Just filepath} = pure [stdioTarget filepath] | |
| toTargets Nixfmt{files = [], stdin_filepath = Just filepath} = do | |
| -- add a warning. https://github.com/NixOS/nixfmt/blob/b672593734d64eefb675b1f1de26f8a73fe00c40/main/Main.hs#L130 | |
| pure [stdioTarget filepath] |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/formatting-team-meeting-2025-11-25/72427/1 |
Full disclosure: the treefmt stdin spec is not yet finalized (see numtide/treefmt#586). However, nothing prevents us from implementing the version of it that I hope will be approved.
This completes #305.
I have very little haskell knowledge. I'm sure there are issues with this implementation. Be kind, I'm excited to learn more!