blob: a413f575e14daa98dd1d6d5233b34ba3f7fca2d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
crane.url = "github:ipetkov/crane";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
crane,
fenix,
treefmt-nix,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
lib = pkgs.lib;
rustToolchain = fenix.packages.${system}.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-lEeYHNJjEVlYS+kLomkfpFWNEJQFhgSjuISZwMdWmb8=" ;
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
src = (craneLib.cleanCargoSource ./.);
commonArgs = {
inherit src;
strictDeps = true;
cargoToml = ./Cargo.toml;
nativeBuildInputs = [
pkgs.pkg-config
];
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
simple-pow = craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
}
);
tree-fmt-eval = treefmt-nix.lib.evalModule pkgs (
{ ... }:
{
# Used to find the project root
projectRootFile = "flake.nix";
programs.nixfmt.enable = true;
programs.deadnix.enable = true;
programs.rustfmt = {
enable = true;
package = rustToolchain;
};
}
);
in
{
checks = {
inherit simple-pow;
str-clippy = craneLib.cargoClippy (
commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
}
);
formatting = tree-fmt-eval.config.build.check self;
};
formatter = tree-fmt-eval.config.build.wrapper;
apps.default = flake-utils.lib.mkApp {
drv = simple-pow;
};
devShells.default = craneLib.devShell {
checks = self.checks.${system};
packages = with pkgs; [
cargo-watch
python3
wgsl-analyzer
];
env = {
"LD_LIBRARY_PATH" = lib.makeLibraryPath (with pkgs; [ stdenv.cc.cc.lib
vulkan-loader
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
libxkbcommon
]);
};
};
}
);
}
|