A Nix library to configure and run treefmt, enabling multi-language code formatting with a single command.
treefmt-nix is a Nix library that configures and runs treefmt, a tool for formatting code across multiple programming languages with a single command. It allows developers to manage formatter dependencies and settings entirely within Nix, providing a reproducible and integrated formatting workflow. The project solves the problem of managing disparate formatter tools and configurations by centralizing them in Nix expressions.
Nix users and developers working in polyglot codebases who want a unified, declarative approach to code formatting. It is particularly useful for teams using Nix development environments or flakes.
Developers choose treefmt-nix because it deeply integrates with Nix, offering a declarative configuration, automatic formatter installation, and seamless compatibility with Nix development shells and CI/CD pipelines. Its extensive library of pre-configured formatters saves time and ensures consistency.
treefmt nix configuration
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Formatters, dependencies, and configurations are managed declaratively in Nix, eliminating separate TOML files and ensuring reproducible builds across environments.
Includes over 100 community-maintained formatter configurations for languages like Python, Rust, and Go, reducing setup time and ensuring consistency.
Automatically installs and configures formatters, integrating with Nix development shells and flakes for easy setup in polyglot projects.
Works with nix flake check to validate formatting in continuous integration, providing a built-in way to enforce code standards without extra tooling.
Requires a Nix environment to function, making it unsuitable for teams not already invested in Nix or in environments where Nix is difficult to deploy.
Setting up involves writing Nix expressions, which can be steep for developers unfamiliar with Nix, and overkill for simple formatting needs.
While many formatters are supported, adding new or niche formatters requires manual PRs or custom definitions, and updates may lag behind upstream changes.