-
Notifications
You must be signed in to change notification settings - Fork 3
/
flake.nix
98 lines (83 loc) · 2.65 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
97
98
{
description = "The CloudMQTT Rust library";
inputs = {
nixpkgs.url = "nixpkgs/nixos-23.11";
flake-utils = {
url = "github:numtide/flake-utils";
};
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};
outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
rustTarget = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
unstableRustTarget = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override {
extensions = [ "rust-src" "miri" "rustfmt" ];
});
craneLib = (crane.mkLib pkgs).overrideToolchain rustTarget;
unstableCraneLib = (crane.mkLib pkgs).overrideToolchain unstableRustTarget;
tomlInfo = craneLib.crateNameFromCargoToml { cargoToml = ./Cargo.toml; };
inherit (tomlInfo) pname version;
src = ./.;
rustfmt' = pkgs.writeShellScriptBin "rustfmt" ''
exec "${unstableRustTarget}/bin/rustfmt" "$@"
'';
cargoArtifacts = craneLib.buildDepsOnly {
inherit src;
cargoExtraArgs = "--all-features --all";
};
cloudmqtt = craneLib.buildPackage {
inherit cargoArtifacts src version;
cargoExtraArgs = "--all-features --all";
};
in
rec {
checks = {
inherit cloudmqtt;
cloudmqtt-clippy = craneLib.cargoClippy {
inherit cargoArtifacts src;
cargoExtraArgs = "--all --all-features";
cargoClippyExtraArgs = "-- --deny warnings";
};
cloudmqtt-fmt = unstableCraneLib.cargoFmt {
inherit src;
};
};
packages.cloudmqtt = cloudmqtt;
packages.default = packages.cloudmqtt;
apps.cloudmqtt = flake-utils.lib.mkApp {
name = "cloudmqtt";
drv = cloudmqtt;
};
apps.default = apps.cloudmqtt;
devShells.default = devShells.cloudmqtt;
devShells.cloudmqtt = pkgs.mkShell {
buildInputs = [ ];
nativeBuildInputs = [
rustfmt'
rustTarget
pkgs.cargo-msrv
pkgs.cargo-deny
pkgs.cargo-expand
pkgs.cargo-bloat
pkgs.cargo-fuzz
pkgs.gitlint
];
};
}
);
}