-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
95 lines (93 loc) · 3.08 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
{
inputs = {
utils.url = "github:numtide/flake-utils";
devshell.url = "github:numtide/devshell";
fenix.url = "github:nix-community/fenix";
fenix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, utils, devshell, fenix, ... }@inputs:
utils.lib.eachSystem [ "aarch64-linux" "i686-linux" "x86_64-linux" ]
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ devshell.overlays.default ];
};
rust-toolchain = with fenix.packages.${system};
combine [
stable.rustc
stable.cargo
stable.clippy
latest.rustfmt
targets.thumbv6m-none-eabi.stable.rust-std
];
in
rec {
devShells.default = (pkgs.devshell.mkShell {
imports = [ "${devshell}/extra/git/hooks.nix" ];
name = "apex-rs-vanilla-dev-shell";
packages = with pkgs; [
clang
rust-toolchain
rust-analyzer
cargo-outdated
cargo-udeps
cargo-watch
nixpkgs-fmt
];
devshell.startup.bindgen-hook.text =
"source ${pkgs.rustPlatform.bindgenHook}/nix-support/setup-hook && populateBindgenEnv";
git.hooks = {
enable = true;
pre-commit.text = "nix flake check";
};
commands = [
{ package = "git-cliff"; }
{ package = "treefmt"; }
{
name = "udeps";
command = ''
PATH=${fenix.packages.${system}.latest.rustc}/bin:$PATH
cargo udeps $@
'';
help = pkgs.cargo-udeps.meta.description;
}
{
name = "outdated";
command = "cargo-outdated outdated";
help = pkgs.cargo-outdated.meta.description;
}
{
name = "verify-no_std";
command = ''
cd $PRJ_ROOT
cargo build --target thumbv6m-none-eabi --no-default-features
'';
help =
"Verify that the library builds for no_std without std-features";
category = "test";
}
{
name = "verify-doc";
command = ''
cd $PRJ_ROOT
cargo doc
'';
help =
"Verify that the documentation builds without problems";
category = "test";
}
];
});
checks = {
nixpkgs-fmt = pkgs.runCommand "nixpkgs-fmt"
{
nativeBuildInputs = [ pkgs.nixpkgs-fmt ];
} "nixpkgs-fmt --check ${./.}; touch $out";
cargo-fmt = pkgs.runCommand "cargo-fmt"
{
nativeBuildInputs = [ rust-toolchain ];
} "cd ${./.}; cargo fmt --check; touch $out";
};
});
}