39 lines
854 B
Markdown
39 lines
854 B
Markdown
# Formatter and Checks
|
|
|
|
This note covers `16-formatter-and-checks/`, which exposes `formatter.<system>` and a small `checks.<system>.*` derivation that uses the same formatter.
|
|
|
|
---
|
|
|
|
## 1. Why These Outputs Matter
|
|
|
|
Two flake outputs are especially practical in day-to-day use:
|
|
|
|
- `formatter.<system>`, which powers `nix fmt`, and
|
|
- `checks.<system>.*`, which powers `nix flake check`.
|
|
|
|
This example keeps both outputs small so the wiring is obvious.
|
|
|
|
---
|
|
|
|
## 2. The Important Connection
|
|
|
|
The flake points `formatter.<system>` at `pkgs.nixfmt`, then reuses that same formatter in a check:
|
|
|
|
```nix
|
|
formatter.${system} = pkgs.nixfmt;
|
|
```
|
|
|
|
That shows the main idea: a formatter output is just another derivation, so checks can use it too.
|
|
|
|
---
|
|
|
|
## 3. Commands to Try
|
|
|
|
```bash
|
|
cd 16-formatter-and-checks
|
|
|
|
nix fmt sample.nix
|
|
nix flake show
|
|
nix flake check
|
|
```
|