1{ lib
2, stdenv
3, rustPlatform
4, fetchFromGitHub
5, ruby
6, which
7, nix-update-script
8}:
9
10rustPlatform.buildRustPackage rec {
11 pname = "rbspy";
12 version = "0.23.0";
13
14 src = fetchFromGitHub {
15 owner = "rbspy";
16 repo = "rbspy";
17 rev = "refs/tags/v${version}";
18 hash = "sha256-qZXv7+gPA24U1gB++3Aq/H+JDmAwB4vBIb/WdXjSMqc=";
19 };
20
21 cargoHash = "sha256-LcVxe2KpW8XOa9yoKROo1QHyu76/OUgq7Wf4bcs1+QQ=";
22
23 # error: linker `aarch64-linux-gnu-gcc` not found
24 postPatch = ''
25 rm .cargo/config
26 '';
27
28 doCheck = true;
29
30 # The current implementation of rbspy fails to detect the version of ruby
31 # from nixpkgs during tests.
32 preCheck = ''
33 substituteInPlace src/core/process.rs \
34 --replace /usr/bin/which '${which}/bin/which'
35 substituteInPlace src/sampler/mod.rs \
36 --replace /usr/bin/which '${which}/bin/which'
37 '';
38
39 checkFlags = [
40 "--skip=test_get_trace"
41 "--skip=test_get_trace_when_process_has_exited"
42 "--skip=test_sample_single_process"
43 "--skip=test_sample_single_process_with_time_limit"
44 "--skip=test_sample_subprocesses"
45 ];
46
47 nativeBuildInputs = [
48 ruby
49 which
50 ] ++ lib.optional stdenv.isDarwin rustPlatform.bindgenHook;
51
52 passthru.updateScript = nix-update-script { };
53
54 meta = with lib; {
55 homepage = "https://rbspy.github.io/";
56 description = "Sampling CPU Profiler for Ruby";
57 mainProgram = "rbspy";
58 changelog = "https://github.com/rbspy/rbspy/releases/tag/v${version}";
59 license = licenses.mit;
60 maintainers = with maintainers; [ viraptor ];
61 platforms = platforms.linux ++ platforms.darwin;
62 };
63}