Skip to content

chore(flake): format through nixfmt-tree instead of nixfmt - #98

Merged
hakula139 merged 1 commit into
mainfrom
chore/nixfmt-tree
Aug 19, 2026
Merged

chore(flake): format through nixfmt-tree instead of nixfmt#98
hakula139 merged 1 commit into
mainfrom
chore/nixfmt-tree

Conversation

@hakula139

Copy link
Copy Markdown
Owner

Summary

  • formatter is pkgs.nixfmt-tree instead of pkgs.nixfmt, so nix fmt takes no argument.

Why

nixfmt 1.4.0 deprecates both forms this flake's formatter was actually invoked with. Bare nix fmt passes no path, so nixfmt reads stdin and now prints Bare invocation of nixfmt is deprecated. Use 'nixfmt -' for anonymous stdin. before failing on the empty input. nix fmt . prints Passing directories or non-Nix files (such as ".") is deprecated and will be unsupported soon, and points at pkgs.nixfmt-tree or treefmt-nix.

The recent nixpkgs bump is what moved this flake onto nixfmt 1.4.0, so the deprecation is live here now rather than hypothetical. Pinning nixfmt back would be the wrong direction: the replacement nixfmt names is a treefmt wrapper, and nixfmt-tree is exactly that, packaged in nixpkgs (2.5.0 at the pinned rev).

Behaviour

nix fmt now needs no argument and walks the tree, respecting .gitignore:

traversed 238 files
emitted 1 files for processing
formatted 1 files (0 changed)

0 changed is the part worth noting: nixfmt is still the formatter underneath, so nothing gets reformatted by this switch. nixfmt-tree is configured for Nix only, so no other file type is newly in scope.

Scope

CI is untouched, because no workflow invokes nix fmt. The pre-commit nixfmt hook is also unaffected, since git-hooks.nix invokes it per file with an explicit path, which is not one of the deprecated forms.

Verification

  • nix fmt exits 0 with the output above, and every .nix file is byte-identical afterwards. The only diff in this branch is the one line changed.
  • nix flake check --no-build: rc=0, all checks passed!, evaluating the formatter to nixfmt-tree-2.5.0.drv.

nixfmt 1.4.0 deprecates bare invocation and passing a directory, so both
`nix fmt` and `nix fmt .` now warn or fail. The replacement nixfmt points
at is a treefmt wrapper, which nixpkgs ships as nixfmt-tree. nixfmt is
still the formatter underneath, so nothing gets reformatted.
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@hakula139 hakula139 self-assigned this Aug 19, 2026
@hakula139 hakula139 added the chore Maintenance work: tooling, dependencies, and housekeeping label Aug 19, 2026
@hakula139
hakula139 merged commit a354d3a into main Aug 19, 2026
7 checks passed
@hakula139
hakula139 deleted the chore/nixfmt-tree branch August 19, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance work: tooling, dependencies, and housekeeping

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant