Skip to content

Commit 814b094

Browse files
committed
Add formatting check to flake
1 parent d6cfd70 commit 814b094

1 file changed

Lines changed: 32 additions & 20 deletions

File tree

flake.nix

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,28 @@
1717
let
1818
inherit (nixpkgs) lib;
1919
eachSystem = f: lib.genAttrs lib.systems.flakeExposed (system: f nixpkgs.legacyPackages.${system});
20+
21+
src = lib.cleanSourceWith {
22+
filter = path: _type: !lib.hasSuffix ".nix" path;
23+
src = lib.cleanSource ./.;
24+
};
25+
26+
formattingOptions = {
27+
projectRootFile = "flake.lock";
28+
programs = {
29+
nixpkgs-fmt.enable = true;
30+
rustfmt.enable = true;
31+
taplo.enable = true;
32+
yamlfmt.enable = true;
33+
mdformat.enable = true;
34+
};
35+
};
2036
in
2137
{
2238
checks = eachSystem (pkgs: {
2339
azure-node-bindings = pkgs.rustPlatform.buildRustPackage {
40+
inherit src;
2441
name = "azure-node-bindings";
25-
src = lib.cleanSourceWith {
26-
filter = path: _type: !lib.hasSuffix ".nix" path;
27-
src = lib.cleanSource ./.;
28-
};
2942
cargoLock.lockFile = ./Cargo.lock;
3043
doCheck = true;
3144
nativeCheckInputs = with pkgs; [ cargo rustc clippy rustfmt ];
@@ -36,12 +49,8 @@
3649
};
3750

3851
docs = pkgs.rustPlatform.buildRustPackage {
39-
pname = "azure-node-bindings-docs";
40-
version = "0.1.0";
41-
src = lib.cleanSourceWith {
42-
filter = path: _type: !lib.hasSuffix ".nix" path;
43-
src = lib.cleanSource ./.;
44-
};
52+
inherit src;
53+
name = "azure-node-bindings-docs";
4554
cargoLock.lockFile = ./Cargo.lock;
4655
buildPhase = "cargo doc --no-deps";
4756
installPhase = ''
@@ -51,18 +60,30 @@
5160
'';
5261
doCheck = false;
5362
};
63+
64+
fmt =
65+
let
66+
treefmt =
67+
let
68+
treefmt = import inputs.treefmt;
69+
in
70+
treefmt.evalModule pkgs formattingOptions;
71+
in
72+
treefmt.config.build.check ./.;
5473
} // lib.optionalAttrs pkgs.stdenv.isLinux {
5574
nixos-azurite = import ./nixos/modules/azurite/test.nix { inherit pkgs self lib; };
5675
nixos-azurite-blob = import ./nixos/modules/azurite-blob/test.nix { inherit pkgs self lib; };
5776
nixos-azurite-queue = import ./nixos/modules/azurite-queue/test.nix { inherit pkgs self lib; };
5877
nixos-azurite-table = import ./nixos/modules/azurite-table/test.nix { inherit pkgs self lib; };
5978
});
79+
6080
nixosModules = {
6181
azurite = import ./nixos/modules/azurite;
6282
azurite-blob = import ./nixos/modules/azurite-blob;
6383
azurite-table = import ./nixos/modules/azurite-table;
6484
azurite-queue = import ./nixos/modules/azurite-queue;
6585
};
86+
6687
devShells = eachSystem (pkgs: {
6788
default = pkgs.mkShell {
6889
buildInputs = with pkgs; [
@@ -75,19 +96,10 @@
7596
];
7697
};
7798
});
99+
78100
formatter = eachSystem (pkgs:
79101
let
80102
treefmt = inputs.treefmt.lib;
81-
formattingOptions = {
82-
projectRootFile = "flake.lock";
83-
programs = {
84-
nixpkgs-fmt.enable = true;
85-
rustfmt.enable = true;
86-
taplo.enable = true;
87-
yamlfmt.enable = true;
88-
mdformat.enable = true;
89-
};
90-
};
91103
in
92104
treefmt.mkWrapper pkgs formattingOptions);
93105
};

0 commit comments

Comments
 (0)