-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtreefmt.nix
More file actions
78 lines (67 loc) · 1.83 KB
/
treefmt.nix
File metadata and controls
78 lines (67 loc) · 1.83 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# <https://github.com/numtide/treefmt-nix>
# Used by ./shell.nix and ./default.nix.
# Rather than using `treefmt-nix.mkWrapper pkgs { ... }`, this has to be
# written such that the config can be used by both the checks called to
# in ./default.nix and the `mkWrapper` call in ./shell.nix.
{
sources ? import ./npins,
nixpkgs ? sources.nixpkgs,
pkgs ? import nixpkgs { },
lib ? pkgs.lib,
treefmt-nix ? sources.treefmt-nix,
...
}:
(import treefmt-nix).evalModule pkgs {
projectRootFile = "npins/sources.json";
# See <https://github.com/numtide/treefmt-nix/tree/main/programs>
programs = {
# Format shell scripts
shellcheck = {
enable = true;
excludes = [ "\.envrc" ];
};
shfmt = {
enable = true;
indent_size = 4;
};
# black.enable = true;
clang-format = {
enable = true;
};
deadnix = {
enable = true;
no-lambda-arg = true;
no-lambda-pattern-names = true;
excludes = [ "npins/*" ];
};
# Allow keeping certain lines sorted
# <https://github.com/google/keep-sorted>
keep-sorted.enable = true;
nixfmt.enable = true;
# oxipng.enable = true;
# perltidy.enable = true;
# Ensure formatting of CSS, HTML, and so on
prettier.enable = true;
# statix.enable = true;
# typos.enable = true;
};
settings.formatter = {
clang-format.options =
let
freebsdConfig = pkgs.fetchurl {
url = "https://raw.githubusercontent.com/freebsd/freebsd-src/8494be1b5af7fe4f765532f802ac0a145e061d73/.clang-format";
hash = "sha256-hRWc+LVlMCiHGr/ihboNa/fR2CKT+Q6I8S8ksdBOpQw=";
};
in
[
"-style=file:${toString freebsdConfig}"
];
shellcheck.options = [
"--external-sources"
];
shfmt.options = [
"--binary-next-line"
"--case-indent"
];
};
}