numtide / treefmt-nix

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

Simplify integration with flakes/access to inputs in "treefmt.nix" #132

Closed SebTM closed 3 months ago

SebTM commented 10 months ago

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

It would be nice / easier / cleaner if the integration would not require to define custom-functions. It was a hassle to adjust the treefmtEval function to pass-through inputs to be able to use a package from input, maybe this can be adjusted that all arguments like on imports/modules can be used automatically:

      treefmtEval = eachSystem (pkgs:
        treefmt-nix.lib.evalModule pkgs (import ./treefmt.nix {
          inherit nixfmt;
          system = pkgs.system;
        }));

Describe the solution you'd like

Maybe they can be provided by treefmt-nix.lib. instead?

Describe alternatives you've considered see above

Additional context

zimbatm commented 3 months ago

Oops, this somehow skipped my attention. You can use overlays, or extend the _module.args with more variables.

      treefmtEval = eachSystem (pkgs:
        treefmt-nix.lib.evalModule pkgs {
          imports = [ ./treefmt.nix ];
          _module.args.inputs = inputs;
        });

Then in the treefmt.nix:

{ inputs, ... }:
{
  // ...
}
SebTM commented 3 months ago

Hey, no worries - did far more nix since then and explored different options 😃