-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathflake.nix
More file actions
112 lines (93 loc) · 3.08 KB
/
Copy pathflake.nix
File metadata and controls
112 lines (93 loc) · 3.08 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
{
description = "Zaino — indexer and proxy server for the Zcash protocol";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
flake-utils.url = "github:numtide/flake-utils";
crane.url = "github:ipetkov/crane";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
### Build with Nix
# nix build .#zainod — build the binary (output at `./result/bin/zainod`)
# nix flake check — run fmt, clippy, doc, and the test suite
# nix develop — enter a dev shell with the pinned Rust toolchain and build deps
# TODO: nixConfig (extra-substituters + extra-trusted-public-keys)
# set once build-cache is setup
outputs = { self, nixpkgs, flake-utils, crane, fenix }:
let
mkCraneLib = pkgs:
(crane.mkLib pkgs).overrideToolchain (p:
fenix.packages.${p.stdenv.buildPlatform.system}.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-gh/xTkxKHL4eiRXzWv8KP7vfjSk61Iq48x47BEDFgfk=";
});
overlay = final: _prev: {
zainod = final.callPackage ./nix/package.nix {
craneLib = mkCraneLib final;
};
};
in
{
overlays.default = overlay;
}
// flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ overlay ];
};
craneLib = mkCraneLib pkgs;
# self.rev is set on clean trees; self.dirtyRev (with a "-dirty" suffix) on dirty trees.
zainod = pkgs.zainod.override {
gitCommit = self.rev or self.dirtyRev;
};
# Single source of truth for src + build env lives in nix/package.nix
# and is re-exposed through the derivation's passthru for downstream
# checks. Avoids duplicating the source filter or env settings here.
inherit (zainod.passthru) commonArgs cargoArtifacts;
in
{
packages = {
inherit zainod;
default = zainod;
};
apps.default = {
type = "app";
program = "${zainod}/bin/zainod";
meta = {
inherit (zainod.meta) description;
};
};
devShells.default = craneLib.devShell {
packages = with pkgs; [
protobuf
pkg-config
cmake
rustPlatform.bindgenHook
cargo-nextest
cargo-deny
cargo-make
rust-analyzer
];
inherit (commonArgs) env;
};
checks = {
clippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- -D warnings";
});
fmt = craneLib.cargoFmt {
inherit (commonArgs) src pname version;
};
nextest = craneLib.cargoNextest (commonArgs // {
inherit cargoArtifacts;
});
doc = craneLib.cargoDoc (commonArgs // {
inherit cargoArtifacts;
});
};
formatter = pkgs.nixfmt-rfc-style;
});
}