1{ lib, stdenv, fetchFromGitHub, rustPlatform, makeWrapper, perf, nix-update-script
2, Security
3}:
4
5rustPlatform.buildRustPackage rec {
6 pname = "cargo-flamegraph";
7 version = "0.5.1";
8
9 src = fetchFromGitHub {
10 owner = "flamegraph-rs";
11 repo = "flamegraph";
12 rev = "v${version}";
13 sha256 = "sha256-Q930PIGncUX2Wz3hA1OQu0TEPMfOu2jMpBPbaAVlUMU=";
14 };
15
16 cargoSha256 = "sha256-ENL1FeIn9HESyp1VhePr4q7BLCc0SS8NAuHKv1crJE8=";
17
18 nativeBuildInputs = lib.optionals stdenv.isLinux [ makeWrapper ];
19 buildInputs = lib.optionals stdenv.isDarwin [
20 Security
21 ];
22
23 postFixup = lib.optionalString stdenv.isLinux ''
24 wrapProgram $out/bin/cargo-flamegraph \
25 --set-default PERF ${perf}/bin/perf
26 wrapProgram $out/bin/flamegraph \
27 --set-default PERF ${perf}/bin/perf
28 '';
29
30 passthru.updateScript = nix-update-script {
31 attrPath = pname;
32 };
33
34 meta = with lib; {
35 description = "Easy flamegraphs for Rust projects and everything else, without Perl or pipes <3";
36 homepage = "https://github.com/ferrous-systems/flamegraph";
37 license = with licenses; [ asl20 /* or */ mit ];
38 maintainers = with maintainers; [ killercup ];
39 };
40}