-
Notifications
You must be signed in to change notification settings - Fork 4
/
flake.nix
96 lines (84 loc) · 2.29 KB
/
flake.nix
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
{
description = "my rust project";
inputs =
{
nixpkgs.url = "github:NixOS/nixpkgs/release-24.05";
flake-utils.url = "github:numtide/flake-utils";
fenix =
{
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ self
, nixpkgs
, flake-utils
, fenix
, crane
,
}:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ fenix.overlays.default ];
pkgs = import nixpkgs { inherit system overlays; };
rust-components = fenix.packages.${system}.fromToolchainFile
{
file = ./rust-toolchain.toml;
#sha256 = nixpkgs.lib.fakeSha256;
sha256 = "sha256-ks0nMEGGXKrHnfv4Fku+vhQ7gx76ruv6Ij4fKZR3l78=";
};
crane-lib = crane.lib.${system}.overrideToolchain rust-components;
rust-src = crane-lib.cleanCargoSource (crane-lib.path ./.);
crane-build-args = {
src = rust-src;
strictDeps = true;
buildInputs = [
# Add additional build inputs here
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.libiconv
];
};
root-cargo-artifacts = crane-lib.buildDepsOnly crane-build-args;
root-crate = crane-lib.buildPackage {
cargoArtifacts = root-cargo-artifacts;
src = rust-src;
cargoToml = ./Cargo.toml;
};
# TODO(tacogips) fix clippy warnings later
#crate-clippy = crane-lib.cargoClippy {
# cargoArtifacts = root-cargo-artifacts;
# src = rust-src;
# #cargoClippyExtraArgs = "-- --deny warnings";
#};
in
{
# --- checks ---
checks = {
inherit root-crate; #crate-clippy;
};
packages.default = root-crate;
apps.default = flake-utils.lib.mkApp {
drv = root-crate;
};
formatter = pkgs.nixpkgs-fmt;
# --- dev shell ---
devShells.default = crane-lib.devShell
{
packages = with pkgs;
[
nixpkgs-fmt
taplo-cli
cargo-make
rust-analyzer
cachix
];
shellHook = ''
'';
};
});
}