Skip to content

Conversation

@jfly
Copy link
Collaborator

@jfly jfly commented Nov 13, 2025

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!

@github-actions
Copy link

github-actions bot commented Nov 13, 2025

Nixpkgs diff

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"
Copy link
Collaborator Author

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.

@nixos-discourse
Copy link

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

Copy link
Collaborator Author

@jfly jfly left a 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]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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]

@jfly jfly moved this to Blocked in Nix formatting Nov 25, 2025
@nixos-discourse
Copy link

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

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

Labels

None yet

Projects

Status: Blocked

Development

Successfully merging this pull request may close these issues.

2 participants