-
Notifications
You must be signed in to change notification settings - Fork 94
/
flake.nix
66 lines (58 loc) · 2.14 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
fenix.url = "github:nix-community/fenix";
fenix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{ nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "aarch64-linux" "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
perSystem = { config, pkgs, system, inputs', self', ... }:
let
toolchain = with inputs.fenix.packages.${system};
combine [
latest.rustc
latest.cargo
latest.clippy
latest.rust-analysis
latest.rust-src
latest.rustfmt
];
craneLib = inputs.crane.lib.${system}.overrideToolchain toolchain;
common-build-args = {
src = craneLib.cleanCargoSource (craneLib.path ./.);
};
deps-only = craneLib.buildDepsOnly ({ } // common-build-args);
packages = {
default = packages.gitu;
gitu = craneLib.buildPackage (common-build-args // {
doCheck = false;
buildInputs = with pkgs;
[ openssl pkg-config ] ++ pkgs.lib.optionals stdenv.isDarwin [
libiconv
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.AppKit
];
});
};
checks = {
clippy = craneLib.cargoClippy ({
cargoArtifacts = deps-only;
cargoClippyExtraArgs = "--all-features -- --deny warnings";
} // common-build-args);
rust-fmt = craneLib.cargoFmt
({ inherit (common-build-args) src; } // common-build-args);
rust-tests = craneLib.cargoNextest ({
cargoArtifacts = deps-only;
partitions = 1;
partitionType = "count";
} // common-build-args);
};
in rec {
inherit packages checks;
};
};
}