Skip to content

Commit 8757285

Browse files
authored
Merge pull request #200 from nix-community/feat/formatting-check
feat: add treefmt check
2 parents ca9efb7 + 60fd0b2 commit 8757285

File tree

2 files changed

+45
-38
lines changed

2 files changed

+45
-38
lines changed

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import (
99
"os"
1010
"strings"
1111

12-
"github.com/numtide/nixos-facter/pkg/udev"
1312
"github.com/numtide/nixos-facter/pkg/build"
1413
"github.com/numtide/nixos-facter/pkg/facter"
1514
"github.com/numtide/nixos-facter/pkg/hwinfo"
15+
"github.com/numtide/nixos-facter/pkg/udev"
1616
)
1717

1818
var (

nix/formatter.nix

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,57 @@
11
{
22
pkgs,
3+
flake,
34
inputs,
45
...
5-
}:
6-
inputs.treefmt-nix.lib.mkWrapper pkgs {
7-
projectRootFile = ".git/config";
6+
}: let
7+
mod = inputs.treefmt-nix.lib.evalModule pkgs {
8+
projectRootFile = ".git/config";
89

9-
programs =
10-
{
11-
alejandra.enable = true;
12-
deadnix.enable = true;
13-
gofumpt.enable = true;
14-
prettier.enable = true;
15-
statix.enable = true;
16-
}
17-
// pkgs.lib.optionalAttrs (pkgs.system != "riscv64-linux") {
18-
shellcheck.enable = true;
19-
};
10+
programs =
11+
{
12+
alejandra.enable = true;
13+
deadnix.enable = true;
14+
gofumpt.enable = true;
15+
prettier.enable = true;
16+
statix.enable = true;
17+
}
18+
// pkgs.lib.optionalAttrs (pkgs.system != "riscv64-linux") {
19+
shellcheck.enable = true;
20+
};
2021

21-
settings = {
22-
global.excludes = [
23-
"LICENSE"
24-
# unsupported extensions
25-
"*.{gif,png,svg,tape,mts,lock,mod,sum,toml,env,envrc,gitignore}"
26-
];
22+
settings = {
23+
global.excludes = [
24+
"LICENSE"
25+
# unsupported extensions
26+
"*.{gif,png,svg,tape,mts,lock,mod,sum,toml,env,envrc,gitignore}"
27+
];
2728

28-
formatter = {
29-
deadnix = {
30-
priority = 1;
31-
};
29+
formatter = {
30+
deadnix = {
31+
priority = 1;
32+
};
3233

33-
statix = {
34-
priority = 2;
35-
};
34+
statix = {
35+
priority = 2;
36+
};
3637

37-
alejandra = {
38-
priority = 3;
39-
};
38+
alejandra = {
39+
priority = 3;
40+
};
4041

41-
prettier = {
42-
options = [
43-
"--tab-width"
44-
"4"
45-
];
46-
includes = ["*.{css,html,js,json,jsx,md,mdx,scss,ts,yaml}"];
42+
prettier = {
43+
options = [
44+
"--tab-width"
45+
"4"
46+
];
47+
includes = ["*.{css,html,js,json,jsx,md,mdx,scss,ts,yaml}"];
48+
};
4749
};
4850
};
4951
};
50-
}
52+
in
53+
mod.config.build.wrapper
54+
// {
55+
# check formatting as part of `nix flake check`
56+
passthru.tests.check = mod.config.build.check flake;
57+
}

0 commit comments

Comments
 (0)