numtide / treefmt-nix

treefmt nix configuration
https://numtide.github.io/treefmt/
MIT License
213 stars 62 forks source link

feat: make treefmt settings a freeform type #178

Closed brianmcgee closed 2 months ago

brianmcgee commented 2 months ago

Allows for experimenting with new config options in treefmt without having to update treefmt-nix, whilst at the same time retaining types for stable config options.

Will allow passing pipeline related options for 2.0.0-rc1 for example.

brianmcgee commented 2 months ago

@roberth nix flake check is failing with The module documentation must not depend on pkgs attributes such as _type.

I don't know how to resolve it whilst retaining the freeform type. Any ideas?

roberth commented 2 months ago

It's just that the pkgs stub used in the check is incomplete. You could either reuse the logic from https://github.com/hercules-ci/flake.parts-website (non-trivial if you want to work around https://github.com/NixOS/nix/issues/6124) or apply a patch like this:

patch ```diff commit 057d2c454f86f937b7f26c6a1c767607766addd7 (HEAD -> feat/freeform-formatter-options) Author: Robert Hensing Date: Tue May 14 21:50:34 2024 +0200 checks.module-docs: Improve pkgs stub diff --git a/checks/default.nix b/checks/default.nix index d24c917..5c7ec4a 100644 --- a/checks/default.nix +++ b/checks/default.nix @@ -66,7 +66,10 @@ let (k: _: throw "The module documentation must not depend on pkgs attributes such as ${lib.strings.escapeNixIdentifier k}") pkgs // { + _type = "pkgs"; inherit lib; + # Formats is ok and supported upstream too. + inherit (pkgs) formats; }; self = { ```