aboutsummaryrefslogtreecommitdiff
path: root/root/nix/_treefmt-base.nix
blob: 21d7ea396fd915995f5f7517b7b6147024d9774a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
  The base treefmt configuration that all projects should import
  from. This will include a consistent configuration for most, if not all,
  formatters/linters. This will NOT enable the formatters/linters except
  for a few that are used across all projects (nixfmt, typos etc.).
*/
{ lib, pkgs, ... }:
let
  rumdlConfig = (pkgs.formats.toml { }).generate "rumdl.toml" {
    global = {
      cache = false;
      extend-enable = [ "MD060" ];
    };

    MD013 = {
      reflow = true;
      reflow-mode = "normalize";
    };
  };

  wrappedRumdl = pkgs.symlinkJoin {
    name = "rumdl-wrapped";
    paths = [ pkgs.rumdl ];
    nativeBuildInputs = [ pkgs.makeBinaryWrapper ];
    postBuild = ''
      makeBinaryWrapper "${pkgs.rumdl}/bin/rumdl" "$out/bin/rumdl" \
        --add-flags "--config ${rumdlConfig}"
    '';
    meta.mainProgram = lib.getName pkgs.rumdl;
  };
in
{
  projectRootFile = "README.md";

  programs = {
    # keep-sorted start block=yes
    keep-sorted.enable = true;
    nixfmt.enable = true;
    rumdl-check = {
      enable = true;
      package = wrappedRumdl;
    };
    typos.enable = true;
    # keep-sorted end
  };
}