-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathflake.nix
More file actions
92 lines (87 loc) · 2.58 KB
/
flake.nix
File metadata and controls
92 lines (87 loc) · 2.58 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
{
description = "Flake for bencher";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
rust-overlay,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system: let
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {
inherit system overlays;
};
rustToolchain = pkgs.rust-bin.stable.latest.minimal.override {
extensions = [
"rust-src"
"clippy"
"rust-analyzer"
];
};
# Build inputs for the Rust project
buildInputs = with pkgs; [
rustToolchain
rust-bin.nightly.latest.rustfmt # Get nightly formatter.
clang
mold
pkg-config
fontconfig
binutils
];
rust_tools = with pkgs; [
cargo-nextest
];
nix_tools = with pkgs; [
alejandra # Nix code formatter
deadnix # Nix dead code checker
statix # Nix static code checker.
];
mkPackage = pname:
pkgs.rustPlatform.buildRustPackage {
name = pname;
src = ./.;
cargoBuildFlags = ["--bin" "${pname}"];
cargoLock.lockFile = ./Cargo.lock;
doCheck = false;
inherit buildInputs;
nativeBuildInputs = buildInputs;
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath buildInputs}";
};
in {
# Build package with `nix build` or more specifically for example `nix run .#bencher`
packages = rec {
default = bencher;
bencher = mkPackage "bencher";
api = mkPackage "api";
};
# Enter reproducible development shell with `nix develop`
devShells = {
default = pkgs.mkShell {
buildInputs = buildInputs ++ rust_tools ++ nix_tools;
};
# A more lightweight dev shell with only packages relevant for CI in it.
ci = pkgs.mkShell {
buildInputs = nix_tools;
};
};
# Run an app with `nix run` or more specifically e.g.: `nix run .#bencher`
apps = rec {
default = bencher;
# nix run .#bencher
bencher = flake-utils.lib.mkApp {
drv = self.packages.${system}.bencher;
};
# nix run .#api
api = flake-utils.lib.mkApp {
drv = self.packages.${system}.api;
};
};
}
);
}