Skip to content

Commit c2f5510

Browse files
feat: setup cargo workspace
1 parent 0ca99f1 commit c2f5510

4 files changed

Lines changed: 99 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[workspace]
2+
members = []
3+
resolver = "3"
4+
5+
[workspace.dependencies]
6+
7+
[workspace.lints.clippy]
8+
all = "deny"
9+
expect_used = "deny"
10+
nursery = "deny"
11+
panic = "deny"
12+
pedantic = "deny"
13+
todo = "deny"
14+
unimplemented = "deny"
15+
unwrap_used = "deny"
16+
17+
[workspace.lints.rust]
18+
future_incompatible = "deny"
19+
unsafe_code = "deny"
20+
unused = "deny"
21+
22+
[workspace.metadata.crane]
23+
name = "labs"
24+
25+
[workspace.package]
26+
edition = "2024"
27+
version = "0.0.0"

flake.lock

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
git-hooks.inputs.nixpkgs.follows = "nixpkgs";
88
treefmt-nix.url = "github:numtide/treefmt-nix";
99
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
10+
rust-overlay.url = "github:oxalica/rust-overlay";
11+
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
12+
crane.url = "github:ipetkov/crane";
1013
};
1114

1215
outputs =
@@ -26,17 +29,42 @@
2629
system,
2730
...
2831
}:
32+
let
33+
rustToolchain = pkgs.rust-bin.stable.latest.default;
34+
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustToolchain;
35+
src = pkgs.lib.cleanSourceWith { src = ./.; };
36+
commonArgs = {
37+
inherit src;
38+
strictDeps = true;
39+
};
40+
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
41+
in
2942
{
3043
_module.args.pkgs = import inputs.nixpkgs {
3144
inherit system;
45+
overlays = [ inputs.rust-overlay.overlays.default ];
3246
};
3347

34-
checks = { };
48+
checks = {
49+
clippy = craneLib.cargoClippy {
50+
inherit
51+
src
52+
cargoArtifacts
53+
;
54+
cargoClippyExtraArgs = "--all-targets --all-features -- --deny warnings";
55+
};
56+
test = craneLib.cargoTest {
57+
inherit
58+
src
59+
cargoArtifacts
60+
;
61+
};
62+
};
3563

3664
devShells.default = pkgs.mkShellNoCC {
3765
inputsFrom = [ config.pre-commit.devShell ];
3866

39-
packages = [ ];
67+
packages = [ rustToolchain ];
4068
};
4169

4270
packages = { };
@@ -56,6 +84,8 @@
5684
projectRootFile = "flake.nix";
5785
programs = {
5886
nixfmt.enable = true;
87+
rustfmt.enable = true;
88+
rustfmt.package = rustToolchain;
5989
yamlfmt.enable = true;
6090
};
6191
};

0 commit comments

Comments
 (0)