forked from CycloneDX/cyclonedx-rust-cargo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
108 lines (85 loc) · 2.99 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
{
description = "A framework for developing the Rust CycloneDX implementation";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};
outputs = { self, nixpkgs, flake-utils, crane, rust-overlay, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-analyzer" "rust-src" ];
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
xmlFilter = path: _type: builtins.match ".*xml$" path != null;
jsonFilter = path: _type: builtins.match ".*json$" path != null;
snapshotTestFilter = path: _type: builtins.match ".*snap" path != null;
stderrFilter = path: _type: builtins.match ".*stderr" path != null;
srcFilter = path: type:
(xmlFilter path type) || (jsonFilter path type) || (snapshotTestFilter path type) || (stderrFilter path type) || (craneLib.filterCargoSources path type);
src = pkgs.lib.cleanSourceWith {
src = craneLib.path ./.;
filter = srcFilter;
};
commonArgs = {
inherit src;
pname = "cyclonedx-rust-cargo";
version = "0.1.0";
buildInputs = with pkgs; [ openssl ];
nativeBuildInputs = with pkgs; [ pkg-config ];
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
cyclonedx-rust-cargo = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
});
in
rec {
checks = {
inherit cyclonedx-rust-cargo;
clippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
});
doc = craneLib.cargoDoc (commonArgs // {
inherit cargoArtifacts;
});
fmt = craneLib.cargoFmt (commonArgs // {
inherit src;
});
};
packages.cyclonedx-rust-cargo = cyclonedx-rust-cargo;
packages.default = packages.cyclonedx-rust-cargo;
apps.cargo-cyclonedx = flake-utils.lib.mkApp {
drv = packages.cyclonedx-rust-cargo;
name = "cargo-cyclonedx";
};
apps.default = apps.cargo-cyclonedx;
devShells.default = pkgs.mkShell {
inputsFrom = builtins.attrValues self.checks.${system};
packages = with pkgs; [
rustToolchain
cargo-edit
cargo-msrv
cargo-outdated
# GitHub tooling
gh
# Nix tooling
nixpkgs-fmt
];
};
});
}