-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
102 lines (87 loc) · 2.71 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
99
100
101
102
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
neovim-nightly-overlay.inputs.nixpkgs.follows = "nixpkgs";
fenix.url = "github:nix-community/fenix";
fenix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs:
with inputs; let
forEachSupportedSystem = let
supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
in (
f:
nixpkgs.lib.genAttrs supportedSystems (
system:
f
(let
overlays = [fenix.overlays.default neovim-nightly-overlay.overlays.default];
in
import nixpkgs {inherit overlays system;})
)
);
in {
checks.pre-commit-check = forEachSupportedSystem (pkgs:
inputs.pre-commit-hooks.lib.${pkgs.system}.run {
src = ./.;
hooks = {
alejandra.enable = true;
rustfmt = {
enable = true;
packageOverrides.rustfmt = pkgs.fenix.complete.rustfmt;
};
clippy = {
enable = true;
packageOverrides.cargo = pkgs.fenix.complete.cargo;
packageOverrides.clippy = pkgs.fenix.complete.clippy;
settings.allFeatures = true;
settings.denyWarnings = true;
};
};
});
packages = forEachSupportedSystem (pkgs:
with pkgs; {
default = rustPlatform.buildRustPackage {
name = "compass";
src = lib.cleanSource ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
doCheck = false;
nativeBuildInputs = [
pkg-config
rustPlatform.bindgenHook
];
};
});
devShells = forEachSupportedSystem (pkgs:
with pkgs; {
default =
mkShell.override {
stdenv = stdenvAdapters.useMoldLinker clangStdenv;
}
{
inherit (self.checks.pre-commit-check.${pkgs.system}) shellHook;
packages = [
openssl
pkg-config
neovim
rust-analyzer-nightly
rustPlatform.bindgenHook
(fenix.complete.withComponents [
"cargo"
"clippy"
"rust-src"
"rust-std"
"rustc"
"rustfmt"
])
cargo-watch
cargo-edit
];
};
});
};
}