2023-02-09 11:40:11 +00:00
|
|
|
{ lib, stdenv, pkgsBuildBuild, rustPlatform, fetchFromGitHub, pkg-config, libunwind, python3, runCommand, darwin }:
|
2020-12-25 13:55:36 +00:00
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "py-spy";
|
2023-02-02 18:25:31 +00:00
|
|
|
version = "0.3.14";
|
2020-12-25 13:55:36 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "benfred";
|
|
|
|
repo = "py-spy";
|
|
|
|
rev = "v${version}";
|
2023-02-02 18:25:31 +00:00
|
|
|
sha256 = "sha256-NciyzKiDKIMeuHhTjzmHIc3dYW4AniuCNjZugm4hMss=";
|
2020-12-25 13:55:36 +00:00
|
|
|
};
|
|
|
|
|
2023-02-09 11:40:11 +00:00
|
|
|
nativeBuildInputs = [ rustPlatform.bindgenHook ];
|
|
|
|
|
|
|
|
buildInputs = lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [
|
|
|
|
# Pull a header that contains a definition of proc_pid_rusage().
|
|
|
|
(runCommand "${pname}_headers" { } ''
|
|
|
|
install -Dm444 ${lib.getDev darwin.apple_sdk.sdk}/include/libproc.h $out/include/libproc.h
|
|
|
|
'')
|
|
|
|
];
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = "-L${libunwind}/lib";
|
2020-12-25 13:55:36 +00:00
|
|
|
|
|
|
|
# error: linker `arm-linux-gnueabihf-gcc` not found
|
2021-02-05 17:12:51 +00:00
|
|
|
preConfigure = lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
|
2020-12-25 13:55:36 +00:00
|
|
|
export RUSTFLAGS="-Clinker=$CC"
|
|
|
|
'';
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [ python3 ];
|
2020-12-25 13:55:36 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
cargoSha256 = "sha256-nm+44YWSJOOg9a9d8b3APXW50ThV3iA2C/QsJMttscE=";
|
2020-12-25 13:55:36 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-12-25 13:55:36 +00:00
|
|
|
description = "Sampling profiler for Python programs";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = [ maintainers.lnl7 ];
|
|
|
|
};
|
|
|
|
}
|