A flake-parts
module to work with treefmt.
This flake module would be be more useful after #1 - because, then the flakeModule will encapsulate more than just a check
.
See this PR for a complete example.
outputs = { self, flake-parts, nixpkgs, treefmt-flake, ... }:
flake-parts.lib.mkFlake { inherit self; } {
imports = [
treefmt-flake.flakeModule
];
perSystem = { lib, config, pkgs, system, ... }:
{
# Provided by treefmt-flake.flakeModule
treefmt.formatters = {
inherit (pkgs)
nixpkgs-fmt;
inherit (pkgs.nodePackages)
purs-tidy;
};
devShells = {
default = pkgs.mkShell {
buildInputs = (with pkgs; [
...
] ++ config.treefmt.buildInputs);
};
};
};
};
This adds a .#checks.<system>.treefmt
flake output that checks that the project tree is already autoformatted.
It also adds a .#apps.<system>.format
output that can can be used to format your project using nix run .#format
.