-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
96 lines (81 loc) · 2.59 KB
/
flake.nix
File metadata and controls
96 lines (81 loc) · 2.59 KB
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 = "A very basic flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
};
outputs = { self, nixpkgs, rust-overlay, flake-utils, pre-commit-hooks }:
let
extensions = [ "rust-src" ];
targets = [ "x86_64-unknown-linux-gnu" "thumbv7em-none-eabihf" ];
overlays = [
rust-overlay.overlays.default
];
in
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system overlays; };
rust = pkgs.rust-bin.stable.latest.default.override { inherit extensions targets; };
minBuildInputs = with pkgs; [
rust
stdenv.cc
stdenv.cc.cc.lib
# git
protobuf
];
in
{
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
tools = {
clippy = rust;
rustfmt = rust;
cargo = rust;
};
hooks = {
clippy.enable = true;
cargo-tests = {
enable = true;
name = "test";
description = "Test Rust code.";
entry = "${rust}/bin/cargo test --color always";
files = "\\.rs$";
pass_filenames = false;
};
rustfmt.enable = true;
nixpkgs-fmt.enable = true;
deadnix.enable = true;
statix.enable = true;
# rustfmt.enable = true;
};
};
};
packages = {
inherit rust;
};
apps = {
doc_server = {
type = "app";
program = "${pkgs.writeShellScript "doc_auto_build" ''
PATH=${with pkgs; lib.makeBinPath [nodePackages.browser-sync]}
browser-sync start --s target/doc --directory -w
''}";
};
};
devShell = pkgs.mkShell {
buildInputs = minBuildInputs;
shellHook = ''
${self.checks.${system}.pre-commit-check.shellHook}
'';
# depsBuildBuild = with pkgs; [ qemu ];
# LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib";
# CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER = "${pkgs.stdenv.cc.targetPrefix}cc";
# CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER = "qemu-aarch64";
};
formatter = pkgs.nixpkgs-fmt;
}
);
}