File tree Expand file tree Collapse file tree 2 files changed +81
-0
lines changed
Expand file tree Collapse file tree 2 files changed +81
-0
lines changed Original file line number Diff line number Diff line change 300300 useNextest = false ;
301301 } ;
302302
303+ workspace-checks = self . packages . ${ system } . rust-workspace ;
304+
303305 # check that the requirements can be parsed
304306 requirements = pkgs . runCommand "check-requirement" { nativeBuildInputs = [ pkgs . strictdoc ] ; } ''
305307 shopt -s globstar
Original file line number Diff line number Diff line change 1+ {
2+ lib ,
3+ rustPlatform ,
4+ clippy ,
5+ } :
6+
7+ let
8+ cargoToml = builtins . fromTOML ( builtins . readFile ../Cargo.toml ) ;
9+ in
10+ rustPlatform . buildRustPackage rec {
11+ pname = "rust-workspace" ;
12+ version = cargoToml . package . version ;
13+
14+ src =
15+ let
16+ # original source to read from
17+ src = ./.. ;
18+
19+ # File suffices to include
20+ extensions = [
21+ "lock"
22+ "rs"
23+ "toml"
24+ "wast"
25+ ] ;
26+ # Files to explicitly include
27+ include = [ ] ;
28+ # Files to explicitly exclude
29+ exclude = [
30+ "flake.lock"
31+ "treefmt.toml"
32+ ] ;
33+
34+ filter = (
35+ path : type :
36+ let
37+ inherit ( builtins ) baseNameOf toString ;
38+ inherit ( lib . lists ) any ;
39+ inherit ( lib . strings ) hasSuffix removePrefix ;
40+ inherit ( lib . trivial ) id ;
41+
42+ # consumes a list of bools, returns true if any of them is true
43+ anyof = any id ;
44+
45+ basename = baseNameOf ( toString path ) ;
46+ relative = removePrefix ( toString src + "/" ) ( toString path ) ;
47+ in
48+ ( anyof [
49+ ( type == "directory" )
50+ ( any ( ext : hasSuffix ".${ ext } " basename ) extensions )
51+ ( any ( file : file == relative ) include )
52+ ] )
53+ && ! ( anyof [ ( any ( file : file == relative ) exclude ) ] )
54+ ) ;
55+ in
56+ lib . sources . cleanSourceWith { inherit src filter ; } ;
57+
58+ cargoLock . lockFile = src + "/Cargo.lock" ;
59+
60+ dontBuild = true ;
61+ doCheck = true ;
62+ checkPhase = ''
63+ RUSTDOCFLAGS="-Dwarnings" cargo doc --workspace --all-features --document-private-items
64+ RUSTFLAGS="-Dwarnings" ${ clippy } /bin/cargo-clippy --workspace --all-features
65+ '' ;
66+ installPhase = ''
67+ mkdir "$out"
68+ '' ;
69+
70+ meta = {
71+ description = "Checks for the Rust workspace" ;
72+ license = with lib . licenses ; [
73+ asl20
74+ # OR
75+ mit
76+ ] ;
77+ maintainers = [ ] ;
78+ } ;
79+ }
You can’t perform that action at this time.
0 commit comments