-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
170 lines (145 loc) · 4.82 KB
/
flake.nix
File metadata and controls
170 lines (145 loc) · 4.82 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
{
description = "A Rust SDK for interacting with Arkiv.";
inputs = {
nixpkgs.url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz";
flake-utils.url = "github:numtide/flake-utils";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.rust-analyzer-src.follows = "";
};
crane.url = "github:ipetkov/crane";
arkiv-op-geth.url = "github:arkiv-network/arkiv-op-geth";
};
outputs =
{
self,
nixpkgs,
flake-utils,
fenix,
crane,
arkiv-op-geth,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
inherit (pkgs) lib;
pkgs = nixpkgs.legacyPackages.${system};
rustToolchain = fenix.packages.${system}.fromToolchainFile {
file = ./.rust-toolchain.toml;
sha256 = "sha256-Qxt8XAuaUR2OMdKbN4u8dBJOhSHxS+uS06Wl9+flVEk=";
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
src =
let
markdownFilter = path: _type: builtins.match ".*md$" path != null;
jsonFilter = path: _type: builtins.match ".*json" path != null;
sourceFilter = path: type:
(markdownFilter path type)
|| (jsonFilter path type)
|| (craneLib.filterCargoSources path type)
;
in
lib.cleanSourceWith {
src = ./.;
filter = sourceFilter;
name = "source";
};
# Run a cargo example from the examples directory.
runExample = { cargoArtifacts, example, ... }@args:
craneLib.mkCargoDerivation (args // {
inherit cargoArtifacts;
pnameSuffix = "-${example}";
nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ arkiv-op-geth.packages.${system}.default ];
buildPhaseCargoCommand = "cargo run --example ${example}";
});
commonArgs = {
inherit src;
strictDeps = true;
# TODO: Check dependencies for rustls, we can potentially
# remove the dependency on pkg-config and openssl
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [ openssl ];
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
arkiv-sdk = craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
doCheck = false; # The tests don't work in the nix sandbox
}
);
in
{
# Additional cargo checks can be found at https://github.com/ipetkov/crane.
#
# These derivations are inherited by the `devShell`.
checks = {
inherit arkiv-sdk;
cargo-clippy = craneLib.cargoClippy (
commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
}
);
cargo-fmt = craneLib.cargoFmt {
inherit src;
};
taplo-fmt = craneLib.taploFmt {
src = pkgs.lib.sources.sourceFilesBySuffices src [ ".toml" ];
};
cargo-doc = craneLib.cargoDoc (
commonArgs
// {
inherit cargoArtifacts;
cargoDocExtraArgs = "--no-deps --workspace";
# This can be commented out or tweaked as necessary, e.g. set to
# `--deny rustdoc::broken-intra-doc-links` to only enforce that lint
env.RUSTDOCFLAGS = "--deny warnings";
}
);
cargo-nextest = craneLib.cargoNextest (
commonArgs
// {
inherit cargoArtifacts;
partitions = 1;
partitionType = "count";
cargoNextestPartitionsExtraArgs = "--no-tests=pass";
}
);
transactions-example = runExample (commonArgs // {
inherit cargoArtifacts;
example = "transactions";
});
keystore-signer-example = runExample (commonArgs // {
inherit cargoArtifacts;
example = "keystore_signer";
});
subscriptions-example = runExample (commonArgs // {
inherit cargoArtifacts;
example = "subscriptions";
});
};
packages = {
inherit arkiv-sdk;
default = arkiv-sdk;
};
devShells.default = craneLib.devShell {
checks = self.checks.${system};
packages =
with pkgs;
[
pre-commit
nixfmt-rfc-style
mitmproxy
]
++ lib.optionals (!pkgs.stdenv.isDarwin) [
nil # currently requires compiling the world
];
};
formatter = pkgs.nixfmt-rfc-style;
}
);
}