-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
144 lines (124 loc) · 4.72 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
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
{
description = "cctl-rs";
nixConfig = {
extra-substituters = [
"https://crane.cachix.org"
"https://nix-community.cachix.org"
];
extra-trusted-public-keys = [
"crane.cachix.org-1:8Scfpmn9w+hGdXH/Q9tTLiYAE/2dnJYRJP7kl80GuRk="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
fenix.url = "github:nix-community/fenix";
fenix.inputs.nixpkgs.follows = "nixpkgs";
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
advisory-db.url = "github:rustsec/advisory-db";
advisory-db.flake = false;
# with casper-node 2.0.0-rc4 https://github.com/casper-network/cctl/pull/44/commits/058de6887c691dac0b20284fba1f78bcd39187ef
cctl.url = "github:cspr-rad/cctl/use-client-feat-2.0";
csprpkgs.follows = "cctl/csprpkgs";
};
outputs = inputs@{ flake-parts, treefmt-nix, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
imports = [
treefmt-nix.flakeModule
./nixos
./dummy-contract
];
perSystem = { self', inputs', pkgs, lib, ... }:
let
rustToolchain = inputs'.fenix.packages.stable.toolchain;
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustToolchain;
cctl = inputs'.cctl.packages.cctl;
cctlAttrs = {
pname = "cctl-rs";
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./Cargo.toml
./Cargo.lock
./bin
./src
./tests
./test-resources
];
};
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = with pkgs; [
openssl.dev
] ++ lib.optionals stdenv.isDarwin [
libiconv
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
];
# the coverage report will run the tests
doCheck = false;
checkInputs = [
cctl
];
};
in
{
devShells.default = pkgs.mkShell {
inputsFrom = [ self'.packages.cctld ];
packages = [ cctl ];
};
packages = {
cctl-rs-deps = craneLib.buildDepsOnly cctlAttrs;
cctl-rs-docs = craneLib.cargoDoc (cctlAttrs // {
cargoArtifacts = self'.packages.cctl-rs-deps;
});
cctld = craneLib.buildPackage (cctlAttrs // {
pname = "cctld";
cargoArtifacts = self'.packages.cctl-rs-deps;
nativeBuildInputs = cctlAttrs.nativeBuildInputs ++ [
pkgs.makeWrapper
];
postInstall = ''
wrapProgram $out/bin/cctld \
--set PATH ${pkgs.lib.makeBinPath [ cctl ]}
'';
meta.mainProgram = "cctld";
});
default = self'.packages.cctld;
cctl-docker-image = pkgs.callPackage ./docker-image.nix { inherit (self'.packages) cctld; };
};
checks = {
lint = craneLib.cargoClippy (cctlAttrs // {
pname = "cctl-rs-lint";
cargoArtifacts = self'.packages.cctl-rs-deps;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
coverage-report = craneLib.cargoTarpaulin (cctlAttrs // {
pname = "cctl-rs-coverage-report";
cargoArtifacts = self'.packages.cctl-rs-deps;
# Default values from https://crane.dev/API.html?highlight=tarpau#cranelibcargotarpaulin
# --avoid-cfg-tarpaulin fixes nom/bitvec issue https://github.com/xd009642/tarpaulin/issues/756#issuecomment-838769320
cargoTarpaulinExtraArgs = "--skip-clean --out xml --output-dir $out --avoid-cfg-tarpaulin";
# cargoTarpaulin runs the tests in the buildPhase
buildInputs = cctlAttrs.buildInputs ++ [
cctl
];
});
};
treefmt = {
projectRootFile = ".git/config";
programs.nixpkgs-fmt.enable = true;
programs.rustfmt.enable = true;
programs.rustfmt.package = craneLib.rustfmt;
settings.formatter = { };
};
};
flake = {
herculesCI.ciSystems = [ "x86_64-linux" ];
};
};
}