Skip to content
This repository was archived by the owner on Aug 18, 2026. It is now read-only.

Commit 63bc108

Browse files
feat: setup cargo workspace
1 parent 8d30990 commit 63bc108

8 files changed

Lines changed: 183 additions & 22 deletions

File tree

.clippy.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
allow-expect-in-tests = true
2+
allow-panic-in-tests = true
3+
allow-unwrap-in-tests = true

.rustfmt.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
edition = "2024"
2+
fn_params_layout = "Vertical"
3+
match_block_trailing_comma = true
4+
merge_derives = true
5+
newline_style = "Unix"
6+
remove_nested_parens = true
7+
reorder_imports = true
8+
reorder_modules = true
9+
style_edition = "2024"
10+
use_field_init_shorthand = true
11+
use_try_shorthand = true

.taplo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
exclude = [".direnv", "target"]
2+
include = ["**/*.toml", "*.toml"]
3+
4+
[formatting]
5+
reorder_arrays = true
6+
reorder_keys = true

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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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.package]
23+
edition = "2024"
24+
version = "0.0.0"

flake.lock

Lines changed: 61 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: 64 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010
url = "github:cachix/git-hooks.nix";
1111
inputs.nixpkgs.follows = "nixpkgs";
1212
};
13+
rust-overlay = {
14+
url = "github:oxalica/rust-overlay";
15+
inputs.nixpkgs.follows = "nixpkgs";
16+
};
17+
rust-flake = {
18+
url = "github:juspay/rust-flake";
19+
inputs.nixpkgs.follows = "nixpkgs";
20+
inputs.rust-overlay.follows = "rust-overlay";
21+
};
1322
};
1423

1524
outputs =
@@ -24,36 +33,69 @@
2433
imports = [
2534
inputs.treefmt-nix.flakeModule
2635
inputs.git-hooks.flakeModule
36+
inputs.rust-flake.flakeModules.default
37+
inputs.rust-flake.flakeModules.nixpkgs
2738
];
2839

29-
perSystem = { pkgs, config, ... }: {
30-
devShells.default = pkgs.mkShellNoCC {
31-
inputsFrom = [
32-
config.pre-commit.devShell
33-
];
40+
perSystem =
41+
{
42+
self',
43+
pkgs,
44+
config,
45+
lib,
46+
...
47+
}:
48+
{
49+
checks = lib.mapAttrs' (
50+
name: crate:
51+
let
52+
crane-lib = config.rust-project.crane-lib;
53+
args = crate.crane.args // {
54+
src = config.rust-project.src;
55+
pname = name;
56+
cargoExtraArgs = "-p ${name}";
57+
strictDeps = true;
58+
};
59+
cargoArtifacts = crane-lib.buildDepsOnly args;
60+
in
61+
lib.nameValuePair "${name}-test" (crane-lib.cargoTest (args // { inherit cargoArtifacts; }))
62+
) config.rust-project.crates;
3463

35-
packages = [ ];
36-
};
64+
devShells.default = pkgs.mkShellNoCC {
65+
inputsFrom = [
66+
config.pre-commit.devShell
67+
self'.devShells.rust
68+
];
3769

38-
pre-commit.settings = {
39-
hooks = {
40-
actionlint.enable = true;
41-
deadnix.enable = true;
42-
statix = {
43-
enable = true;
44-
settings.ignore = [
45-
".direnv/**"
46-
];
70+
packages = [ ];
71+
};
72+
73+
pre-commit.settings = {
74+
hooks = {
75+
actionlint.enable = true;
76+
deadnix.enable = true;
77+
statix = {
78+
enable = true;
79+
settings.ignore = [
80+
".direnv/**"
81+
];
82+
};
4783
};
4884
};
49-
};
5085

51-
treefmt = {
52-
projectRootFile = "flake.nix";
53-
programs = {
54-
nixfmt.enable = true;
86+
rust-project = {
87+
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
88+
};
89+
90+
treefmt = {
91+
projectRootFile = "flake.nix";
92+
programs = {
93+
nixfmt.enable = true;
94+
rustfmt.enable = true;
95+
rustfmt.package = config.rust-project.toolchain;
96+
taplo.enable = true;
97+
};
5598
};
5699
};
57-
};
58100
};
59101
}

rust-toolchain.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[toolchain]
2+
channel = "1.97.1"
3+
components = [
4+
"cargo",
5+
"clippy",
6+
"rust-analyzer",
7+
"rust-src",
8+
"rustc",
9+
"rustfmt",
10+
]
11+
profile = "minimal"

0 commit comments

Comments
 (0)