nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 rustPlatform,
5 fetchFromGitHub,
6 ruby,
7 which,
8 nix-update-script,
9}:
10
11rustPlatform.buildRustPackage (finalAttrs: {
12 pname = "rbspy";
13 version = "0.40.0";
14
15 src = fetchFromGitHub {
16 owner = "rbspy";
17 repo = "rbspy";
18 tag = "v${finalAttrs.version}";
19 hash = "sha256-4VNiz+b8fxJ0uEVn8PZJPIvqB2dK/mx74RnRGRCxeR8=";
20 };
21
22 cargoHash = "sha256-bmKG0/9XWIT2rMEejmp4DCMj5JZe2k4AdHSmsOeXmak=";
23
24 doCheck = true;
25
26 # The current implementation of rbspy fails to detect the version of ruby
27 # from nixpkgs during tests.
28 preCheck = ''
29 substituteInPlace src/core/process.rs \
30 --replace-fail "/usr/bin/which" "${lib.getExe which}"
31 substituteInPlace src/sampler/mod.rs \
32 --replace-fail "/usr/bin/which" "${lib.getExe which}"
33 substituteInPlace src/core/ruby_spy.rs \
34 --replace-fail "/usr/bin/ruby" "${lib.getExe ruby}"
35 '';
36
37 checkFlags = [
38 "--skip=test_get_trace"
39 "--skip=test_get_trace_when_process_has_exited"
40 "--skip=test_sample_single_process"
41 "--skip=test_sample_single_process_with_time_limit"
42 "--skip=test_sample_subprocesses"
43 ];
44
45 nativeBuildInputs = lib.optional stdenv.hostPlatform.isDarwin rustPlatform.bindgenHook;
46
47 nativeCheckInputs = [
48 ruby
49 which
50 ];
51
52 passthru.updateScript = nix-update-script { };
53
54 meta = {
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${finalAttrs.version}";
59 license = lib.licenses.mit;
60 maintainers = with lib.maintainers; [ viraptor ];
61 platforms = lib.platforms.linux ++ lib.platforms.darwin;
62 };
63})