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