Skip to content

Commit 783f196

Browse files
authored
Merge pull request #56 from u-quark/add-rust-tooling
Add some Rust tooling checks/hooks
2 parents 16d4ca0 + 211f0ed commit 783f196

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ eval "$shellHook"
9595

9696
- [elm-format](https://github.com/avh4/elm-format)
9797

98+
## Rust
99+
100+
- [rustfmt](https://github.com/rust-lang/rustfmt)
101+
- [clippy](https://github.com/rust-lang/rust-clippy)
102+
- cargo-check: Runs `cargo check`
103+
104+
*Warning*: running `clippy` after `cargo check` hides
105+
(https://github.com/rust-lang/rust-clippy/issues/4612) all clippy specific
106+
errors. Clippy subsumes `cargo check` so only one of these two checks should by
107+
used at the same time.
108+
98109
## Shell
99110

100111
- [shellcheck](https://github.com/koalaman/shellcheck)

modules/hooks.nix

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,29 @@ in
140140
types = [ "file" "yaml" ];
141141
entry = "${tools.yamllint}/bin/yamllint";
142142
};
143+
rustfmt =
144+
{
145+
name = "rustfmt";
146+
description = "Format Rust code.";
147+
entry = "${tools.rustfmt}/bin/cargo-fmt fmt -- --check --color always";
148+
files = "\\.rs$";
149+
pass_filenames = false;
150+
};
151+
clippy =
152+
{
153+
name = "clippy";
154+
description = "Lint Rust code.";
155+
entry = "${tools.clippy}/bin/cargo-clippy clippy";
156+
files = "\\.rs$";
157+
pass_filenames = false;
158+
};
159+
cargo-check =
160+
{
161+
name = "cargo-check";
162+
description = "Check the cargo package for errors";
163+
entry = "${tools.cargo}/bin/cargo check";
164+
files = "\\.rs$";
165+
pass_filenames = false;
166+
};
143167
};
144168
}

nix/tools.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717
, nix-linter
1818
, callPackage
1919
, pythonPackages
20+
, rustfmt
21+
, clippy
22+
, cargo
2023
}:
2124

2225
{
23-
inherit ansible-lint hlint shellcheck ormolu hindent cabal-fmt nixpkgs-fmt nixfmt nix-linter;
26+
inherit ansible-lint hlint shellcheck ormolu hindent cabal-fmt nixpkgs-fmt nixfmt nix-linter rustfmt clippy cargo;
2427
inherit (elmPackages) elm-format;
2528
inherit (haskellPackages) brittany hpack;
2629
inherit (pythonPackages) yamllint;

0 commit comments

Comments
 (0)