Skip to content

Commit 0e4ac99

Browse files
committed
Add runTests option to Rust
1 parent 0b61e5e commit 0e4ac99

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

flake-lang/rust/description.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Creates a flake for a Rust project.
3131
- `extraCargoArgs`(optional): Extra cargo arguments
3232
- `extraEnvVars`(optional): Extra environment variables
3333
- `generateDocs`(default=true): Generate Rustdoc
34+
- `runTests`(default=true): Run testsuite using cargo-nextest
35+
- `runClippy(default=true): Run clippy linter
3436

3537
**Returns:**
3638

flake-lang/rust/flake-rust.nix

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ inputCrane: pkgs:
4747
extraEnvVars ? null
4848
# Generate Rustdoc
4949
, generateDocs ? true
50+
# Run testsuite using cargo-nextest
51+
, runTests ? true
52+
# Run clippy linter
53+
, runClippy ? true
5054
}:
5155

5256
let
@@ -195,7 +199,7 @@ in
195199
'';
196200
};
197201

198-
packages = (pkgs.lib.optionalAttrs generateDocs {
202+
packages = (optionalAttrs generateDocs {
199203
"${crateName}-rust-doc" = craneLib.cargoDoc (commonArgs // {
200204
inherit cargoArtifacts;
201205
doCheck = false;
@@ -215,14 +219,16 @@ in
215219
"${crateName}-rust-build-env" = buildEnv;
216220
};
217221

218-
checks = {
219-
"${crateName}-rust-test" = craneLib.cargoNextest (commonArgs // {
220-
inherit cargoArtifacts cargoNextestExtraArgs;
221-
nativeBuildInputs = commonArgs.nativeBuildInputs ++ testTools;
222+
checks =
223+
(optionalAttrs runTests {
224+
"${crateName}-rust-test" = craneLib.cargoNextest (commonArgs // {
225+
inherit cargoArtifacts cargoNextestExtraArgs;
226+
nativeBuildInputs = commonArgs.nativeBuildInputs ++ testTools;
227+
});
228+
}) // (optionalAttrs runClippy {
229+
230+
"${crateName}-rust-clippy" = craneLib.cargoClippy (commonArgs // {
231+
inherit cargoArtifacts;
232+
});
222233
});
223-
224-
"${crateName}-rust-clippy" = craneLib.cargoClippy (commonArgs // {
225-
inherit cargoArtifacts;
226-
});
227-
};
228234
}

0 commit comments

Comments
 (0)