2020-10-11 12:50:04 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchurl
|
|
|
|
, dpkg
|
|
|
|
, writeShellScript
|
|
|
|
, curl
|
|
|
|
, jq
|
|
|
|
, common-updater-scripts
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2021-10-28 06:52:43 +00:00
|
|
|
pname = "blackfire";
|
2023-01-11 07:51:40 +00:00
|
|
|
version = "2.13.2";
|
2020-10-11 12:50:04 +00:00
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
src = passthru.sources.${stdenv.hostPlatform.system} or (throw "Unsupported platform for blackfire: ${stdenv.hostPlatform.system}");
|
2020-10-11 12:50:04 +00:00
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
nativeBuildInputs = lib.optionals stdenv.isLinux [
|
|
|
|
dpkg
|
|
|
|
];
|
2020-10-11 12:50:04 +00:00
|
|
|
|
|
|
|
dontUnpack = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
if ${ lib.boolToString stdenv.isLinux }
|
|
|
|
then
|
|
|
|
dpkg-deb -x $src $out
|
|
|
|
mv $out/usr/* $out
|
|
|
|
rmdir $out/usr
|
|
|
|
|
|
|
|
# Fix ExecStart path and replace deprecated directory creation method,
|
|
|
|
# use dynamic user.
|
|
|
|
substituteInPlace "$out/lib/systemd/system/blackfire-agent.service" \
|
|
|
|
--replace '/usr/' "$out/" \
|
|
|
|
--replace 'ExecStartPre=/bin/mkdir -p /var/run/blackfire' 'RuntimeDirectory=blackfire' \
|
|
|
|
--replace 'ExecStartPre=/bin/chown blackfire: /var/run/blackfire' "" \
|
|
|
|
--replace 'User=blackfire' 'DynamicUser=yes' \
|
|
|
|
--replace 'PermissionsStartOnly=true' ""
|
2020-10-11 12:50:04 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
# Modernize socket path.
|
|
|
|
substituteInPlace "$out/etc/blackfire/agent" \
|
|
|
|
--replace '/var/run' '/run'
|
|
|
|
else
|
|
|
|
mkdir $out
|
2021-10-28 06:52:43 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
tar -zxvf $src
|
|
|
|
|
|
|
|
mv etc $out
|
|
|
|
mv usr/* $out
|
|
|
|
fi
|
2021-10-28 06:52:43 +00:00
|
|
|
|
2020-10-11 12:50:04 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru = {
|
2022-08-21 13:32:41 +00:00
|
|
|
sources = {
|
|
|
|
"x86_64-linux" = fetchurl {
|
|
|
|
url = "https://packages.blackfire.io/debian/pool/any/main/b/blackfire/blackfire_${version}_amd64.deb";
|
2023-01-11 07:51:40 +00:00
|
|
|
sha256 = "1/O1n0nO+adY7KNVnz6xkESyODiLw61x68xE84EKW+I=";
|
2022-08-21 13:32:41 +00:00
|
|
|
};
|
|
|
|
"i686-linux" = fetchurl {
|
|
|
|
url = "https://packages.blackfire.io/debian/pool/any/main/b/blackfire/blackfire_${version}_i386.deb";
|
2023-01-11 07:51:40 +00:00
|
|
|
sha256 = "fy3i++HpGuKH9ijPY61O66PhFyORIpjkZV++75H5738=";
|
2022-08-21 13:32:41 +00:00
|
|
|
};
|
|
|
|
"aarch64-linux" = fetchurl {
|
|
|
|
url = "https://packages.blackfire.io/debian/pool/any/main/b/blackfire/blackfire_${version}_arm64.deb";
|
2023-01-11 07:51:40 +00:00
|
|
|
sha256 = "zO3KWbrudhCGpbdCUBRWQkK/snvDdUOxKF9ukZC+vno=";
|
2022-08-21 13:32:41 +00:00
|
|
|
};
|
|
|
|
"aarch64-darwin" = fetchurl {
|
|
|
|
url = "https://packages.blackfire.io/blackfire/${version}/blackfire-darwin_arm64.pkg.tar.gz";
|
2023-01-11 07:51:40 +00:00
|
|
|
sha256 = "Sqn5tFpvlF9LbUyC1i38BsyM9B+MOmykt+5COMhuO1A=";
|
2022-08-21 13:32:41 +00:00
|
|
|
};
|
|
|
|
"x86_64-darwin" = fetchurl {
|
|
|
|
url = "https://packages.blackfire.io/blackfire/${version}/blackfire-darwin_amd64.pkg.tar.gz";
|
2023-01-11 07:51:40 +00:00
|
|
|
sha256 = "9vrrBiz744s1W5FV7QO8QKL7pfK6OGPinnSOJSvMIOk=";
|
2022-08-21 13:32:41 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
updateScript = writeShellScript "update-blackfire" ''
|
2022-04-27 09:35:20 +00:00
|
|
|
set -o errexit
|
2020-10-11 12:50:04 +00:00
|
|
|
export PATH="${lib.makeBinPath [ curl jq common-updater-scripts ]}"
|
2022-04-27 09:35:20 +00:00
|
|
|
NEW_VERSION=$(curl -s https://blackfire.io/api/v1/releases | jq .cli --raw-output)
|
|
|
|
|
|
|
|
if [[ "${version}" = "$NEW_VERSION" ]]; then
|
|
|
|
echo "The new version same as the old version."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
for platform in ${lib.escapeShellArgs meta.platforms}; do
|
|
|
|
update-source-version "blackfire" "0" "${lib.fakeSha256}" --source-key="sources.$platform"
|
|
|
|
update-source-version "blackfire" "$NEW_VERSION" --source-key="sources.$platform"
|
2022-04-27 09:35:20 +00:00
|
|
|
done
|
2020-10-11 12:50:04 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Blackfire Profiler agent and client";
|
|
|
|
homepage = "https://blackfire.io/";
|
2022-06-26 10:26:21 +00:00
|
|
|
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
|
2020-10-11 12:50:04 +00:00
|
|
|
license = licenses.unfree;
|
2022-10-30 15:09:59 +00:00
|
|
|
maintainers = with maintainers; [ shyim ];
|
2022-10-21 18:38:19 +00:00
|
|
|
platforms = [ "x86_64-linux" "aarch64-linux" "i686-linux" "x86_64-darwin" "aarch64-darwin" ];
|
2020-10-11 12:50:04 +00:00
|
|
|
};
|
|
|
|
}
|