Platonic-Systems / treefmt-flake

A `flake-parts` module to work with treefmt. No longer maintained; you should instead use https://github.com/numtide/treefmt-nix#flake-parts
MIT License
4 stars 1 forks source link

Nixify `treefmt.toml` #1

Open srid opened 2 years ago

srid commented 2 years ago

We want to nixify treefmt.toml, and have it directly use the nix packages, in addition to having treefmt in nix shell run with the nixified configuration.

We can use https://github.com/numtide/treefmt/pull/169 but the main blocker is the lack of PRJ_ROOT (see comments).

srid commented 2 years ago

This is now possible using "github:srid/treefmt/withConfig-stable"

          treefmt.buildInputs = [
            (inputs'.treefmt.legacyPackages.default.withConfig {
              projectRootFile = "flake.nix";
              settings = {
                formatter = {
                  nix = {
                    command = lib.getExe pkgs.nixpkgs-fmt;
                    includes = [ "*.nix" ];
                  };
                  purescript = {
                    command = lib.getExe pkgs.nodePackages.purs-tidy;
                    options = [ "format-in-place" ];
                    # Note that given how purs-tidy is designed (takes glob, rather than explicit
                    # list of files), these patters inevitably slow down purs-tidy (thus treefmt)
                    # during the initial run.
                    includes = [
                      "src/**/*.purs"
                      "core/**/*.purs"
                      "lib/**/*.purs"
                      "src/**/*.purs"
                      "domain/**/*.purs"
                      "infrastructure/**/*.purs"
                      "ui-guide/**/*.purs"
                      "test/**/*.purs"
                    ];
                  };
                };
              };
            })
          ];

May as well retire this repo right away by moving it to upstream repo after https://github.com/numtide/treefmt/pull/169 gets merged to master.