numtide / blueprint

Nix without the glue code
40 stars 3 forks source link

formatter.nix & flake checks #31

Open phaer opened 1 month ago

phaer commented 1 month ago

Is your feature request related to a problem? Please describe.

I love simply adding a formatter nix to invoke treefmt-nix by just adding a treefmt-nix.mkWrapper call as e.g. in nixos-facter.

But I'd like to use the same treefmt-nix configuration as a flake check. As afaik there's no generic interface to tell a given formatter to enter "check mode", I believe we can't add such a feature to blueprint automatically.

Describe the solution you'd like

Not sure, hence this issue: I one thing could be to make the treefmt-nix wrapper expose passthru.check or so which would enable something like checks.format = perSystem.formatter.passthru.check in a quite generic way.

Describe alternatives you've considered

Maybe adapting formatter.nix to be able to return formatter and some checks? This would allow just using treefmt-nix.lib.evalModule and then treefmt.config.build.wrapper, treefmt.config.build.check, ... as needed.

Additional context

The former would of course affect treefmt-nix, happy to create a PR there, just wanted to collect feedback here as i ran into this with blueprint specifically