Skip to content
This repository has been archived by the owner on Dec 24, 2022. It is now read-only.

Latest commit

 

History

History
42 lines (33 loc) · 1.31 KB

README.md

File metadata and controls

42 lines (33 loc) · 1.31 KB

treefmt-flake

A flake-parts module to work with treefmt.

Status

This flake module would be be more useful after #1 - because, then the flakeModule will encapsulate more than just a check.

Usage

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.