https://github.com/m15a/flakelight-treefmt
Integrate treefmt-nix into flakelight.
https://github.com/m15a/flakelight-treefmt
flakelight nix-flake treefmt
Last synced: 6 months ago
JSON representation
Integrate treefmt-nix into flakelight.
- Host: GitHub
- URL: https://github.com/m15a/flakelight-treefmt
- Owner: m15a
- License: bsd-3-clause
- Created: 2025-11-09T13:18:48.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-12-23T12:43:53.000Z (6 months ago)
- Last Synced: 2025-12-25T01:58:49.834Z (6 months ago)
- Topics: flakelight, nix-flake, treefmt
- Language: Nix
- Homepage:
- Size: 23.4 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# flakelight-treefmt
This module extends your [flakelight] project to replace the builtin
formatter with one powered by [treefmt-nix].
## Usage
A minimal example looks like this:
```nix
{
inputs.flakelight-treefmt.url = "github:m15a/flakelight-treefmt";
outputs =
{ self, flakelight-treefmt, ... }:
flakelight-treefmt ./. {
inputs.self = self;
treefmtConfig = {
programs.nixfmt.enable = true;
};
};
}
```
> [!IMPORTANT]
> You must inherit `inputs.self` so that treefmt-nix can locate and
> check the files within your project.
You can also use this module with other flakelight modules.
An example with [flakelight-rust] would be:
```nix
{
inputs = {
flakelight-rust.url = "github:accelbread/flakelight-rust";
flakelight-treefmt.url = "github:m15a/flakelight-treefmt";
flakelight-treefmt.inputs.flakelight.follows = "flakelight-rust/flakelight";
};
outputs =
{ self, flakelight-rust, flakelight-treefmt, ... }:
flakelight-rust ./. {
inputs.self = self;
imports = [ flakelight-treefmt.flakelightModules.default ];
treefmtConfig = { pkgs, ... }: {
programs.rustfmt.enable = true;
};
};
}
```
## Options
### `treefmtConfig`
Your configuration for treefmt-nix. It can be either an inline module
containing `programs.*` etc. (like the example above) or a path to a
configuration file (e.g., `./treefmt.nix`).
### `treefmtWrapperInDevShell`
Controls whether the `treefmt` command is added to `devShell.packages`.
The default value is `true`.
### `treefmtProgramsInDevShell`
Controls whether all formatters/linters configured via `treefmtConfig`
(e.g., `nixfmt`) are added to `devShell.packages`.
The default value is `true`.
## License
[The BSD 3-clause license](LICENSE).
[flakelight]: https://github.com/nix-community/flakelight
[flakelight-rust]: https://github.com/accelbread/flakelight-rust
[treefmt-nix]: https://github.com/numtide/treefmt-nix