2020-10-04 11:59:52 +01:00
|
|
|
|
{ stdenv
|
|
|
|
|
, lib
|
|
|
|
|
, fetchurl
|
|
|
|
|
, dpkg
|
|
|
|
|
, autoPatchelfHook
|
|
|
|
|
, php
|
|
|
|
|
, writeShellScript
|
|
|
|
|
, curl
|
|
|
|
|
, jq
|
|
|
|
|
, common-updater-scripts
|
|
|
|
|
}:
|
|
|
|
|
|
|
|
|
|
let
|
2022-04-28 20:53:26 +01:00
|
|
|
|
phpMajor = lib.versions.majorMinor php.version;
|
2020-10-04 11:59:52 +01:00
|
|
|
|
soFile = {
|
|
|
|
|
"7.4" = "blackfire-20190902";
|
2020-12-01 09:40:10 +00:00
|
|
|
|
"8.0" = "blackfire-20200930";
|
2021-12-08 16:07:08 +00:00
|
|
|
|
"8.1" = "blackfire-20210902";
|
2022-04-28 20:53:26 +01:00
|
|
|
|
}.${phpMajor} or (throw "Unsupported PHP version.");
|
|
|
|
|
|
|
|
|
|
version = "1.77.0";
|
|
|
|
|
|
|
|
|
|
hashes = {
|
|
|
|
|
"x86_64-linux" = {
|
|
|
|
|
system = "amd64";
|
|
|
|
|
sha256 = "oC4pANYT2XtF3ju+pT2TCb6iJSlNm6t+Xkawb88xWUo=";
|
|
|
|
|
};
|
|
|
|
|
"i686-linux" = {
|
|
|
|
|
system = "i386";
|
|
|
|
|
sha256 = "zdebak5RWuPqCJ3eReKjtDLnCXtjtVFnSqvqC4U0+RE=";
|
|
|
|
|
};
|
|
|
|
|
"aarch64-linux" = {
|
|
|
|
|
system = "arm64";
|
|
|
|
|
sha256 = "5J1JcD/ZFxV0FWaySv037x1xjmCdM/zHiBfmRuCidjs=";
|
|
|
|
|
};
|
|
|
|
|
"aarch64-darwin" = {
|
|
|
|
|
system = "arm64";
|
|
|
|
|
sha256 = {
|
|
|
|
|
"7.4" = {
|
|
|
|
|
normal = "vKOH+yPDyf8KxX0DoEnrp2HXYfDAxVD708MZrRGMEEk=";
|
|
|
|
|
zts = "cpeOtDRhPA35utai8G1Dosuqhf76hiqvwe+Em9cFhDo=";
|
|
|
|
|
};
|
|
|
|
|
"8.0" = {
|
|
|
|
|
normal = "v6PD1+Ghvtoq1wzAXwqi9elyC9/NwzX0EDdtQtCfeL4=";
|
|
|
|
|
zts = "Dqs0P8X7ScDJCPYKuqlumnLz4kB7cEOnVbDACQ02sko=";
|
|
|
|
|
};
|
|
|
|
|
"8.1" = {
|
|
|
|
|
normal = "mCZ1avC8FsqYdGYNepeqWgSK2kqVo1E0VjhofxdaSyk=";
|
|
|
|
|
zts = "zliaM2VbaDEgNBr5ETe1GdYNyTZy5te92LedZiolx/8=";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
"x86_64-darwin" = {
|
|
|
|
|
system = "amd64";
|
|
|
|
|
sha256 = {
|
|
|
|
|
"7.4" = {
|
|
|
|
|
normal = "nLsrpRnR9zo3d/a0+TFBlNcAebknpBQc101ysqPs+dU=";
|
|
|
|
|
zts = "o7R8zmhIOtiNDS8Se3Dog+cn9HyTHzS4jquXdzGQQOU=";
|
|
|
|
|
};
|
|
|
|
|
"8.0" = {
|
|
|
|
|
normal = "Pe2/GNDiS5DuSXCffO0jo5dRl0qkh1RgBVL3JzLwVkQ=";
|
|
|
|
|
zts = "zu7QgaKbBNQkby7bLv+NKLSIa79UXMONEf171EO+uNE=";
|
|
|
|
|
};
|
|
|
|
|
"8.1" = {
|
|
|
|
|
normal = "3SOlLeLCM4crWY6U+/zmtWmNYg2j0HC/3FWCmCi7lOo=";
|
|
|
|
|
zts = "GG8s+Pd0K6SEUzRV96Ba2mYfLgQMuGNzRoUtmz9m0NY=";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
makeSource =
|
|
|
|
|
{
|
|
|
|
|
system,
|
|
|
|
|
phpMajor,
|
|
|
|
|
ztsSupport,
|
|
|
|
|
}:
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
isLinux = builtins.match ".+-linux" system != null;
|
|
|
|
|
in
|
|
|
|
|
assert !isLinux -> (phpMajor != null && ztsSupport != null);
|
|
|
|
|
fetchurl {
|
|
|
|
|
url =
|
|
|
|
|
if isLinux
|
|
|
|
|
then "https://packages.blackfire.io/debian/pool/any/main/b/blackfire-php/blackfire-php_${version}_${hashes.${system}.system}.deb"
|
|
|
|
|
else "https://packages.blackfire.io/homebrew/blackfire-php_${version}-darwin_${hashes.${system}.system}-php${builtins.replaceStrings ["."] [""] phpMajor}${lib.optionalString ztsSupport "-zts"}.tar.gz";
|
|
|
|
|
sha256 =
|
|
|
|
|
if isLinux
|
|
|
|
|
then hashes.${system}.sha256
|
|
|
|
|
else hashes.${system}.sha256.${phpMajor}.${if ztsSupport then "zts" else "normal"};
|
|
|
|
|
};
|
|
|
|
|
self = stdenv.mkDerivation rec {
|
2020-10-04 11:59:52 +01:00
|
|
|
|
pname = "php-blackfire";
|
2022-04-28 20:53:26 +01:00
|
|
|
|
inherit version;
|
2020-10-04 11:59:52 +01:00
|
|
|
|
|
2022-04-28 20:53:26 +01:00
|
|
|
|
src = makeSource {
|
|
|
|
|
system = stdenv.hostPlatform.system;
|
|
|
|
|
inherit phpMajor;
|
|
|
|
|
inherit (php) ztsSupport;
|
2020-10-04 11:59:52 +01:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-28 20:53:26 +01:00
|
|
|
|
nativeBuildInputs = lib.optionals stdenv.isLinux [
|
2020-10-04 11:59:52 +01:00
|
|
|
|
dpkg
|
|
|
|
|
autoPatchelfHook
|
|
|
|
|
];
|
|
|
|
|
|
2022-04-28 20:53:26 +01:00
|
|
|
|
setSourceRoot = if stdenv.isDarwin then "sourceRoot=`pwd`" else null;
|
2020-10-04 11:59:52 +01:00
|
|
|
|
|
2022-04-28 20:53:26 +01:00
|
|
|
|
unpackPhase = if stdenv.isLinux then ''
|
|
|
|
|
runHook preUnpack
|
2020-10-04 11:59:52 +01:00
|
|
|
|
dpkg-deb -x $src pkg
|
|
|
|
|
sourceRoot=pkg
|
|
|
|
|
|
|
|
|
|
runHook postUnpack
|
2022-04-28 20:53:26 +01:00
|
|
|
|
'' else null;
|
2020-10-04 11:59:52 +01:00
|
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
|
runHook preInstall
|
|
|
|
|
|
2022-04-28 20:53:26 +01:00
|
|
|
|
if ${ lib.boolToString stdenv.isLinux }
|
|
|
|
|
then
|
|
|
|
|
install -D usr/lib/blackfire-php/*/${soFile}${lib.optionalString php.ztsSupport "-zts"}.so $out/lib/php/extensions/blackfire.so
|
|
|
|
|
else
|
|
|
|
|
install -D blackfire.so $out/lib/php/extensions/blackfire.so
|
|
|
|
|
fi
|
2020-10-04 11:59:52 +01:00
|
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
|
updateScript = writeShellScript "update-${pname}" ''
|
2022-04-28 20:53:26 +01:00
|
|
|
|
set -o errexit
|
2020-10-04 11:59:52 +01:00
|
|
|
|
export PATH="${lib.makeBinPath [ curl jq common-updater-scripts ]}"
|
2022-04-28 20:53:26 +01:00
|
|
|
|
NEW_VERSION=$(curl --silent https://blackfire.io/api/v1/releases | jq .probe.php --raw-output)
|
|
|
|
|
|
|
|
|
|
if [[ "${version}" = "$NEW_VERSION" ]]; then
|
|
|
|
|
echo "The new version same as the old version."
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
for source in ${lib.concatStringsSep " " (builtins.attrNames passthru.updateables)}; do
|
|
|
|
|
update-source-version "$UPDATE_NIX_ATTR_PATH.updateables.$source" "0" "${lib.fakeSha256}"
|
|
|
|
|
update-source-version "$UPDATE_NIX_ATTR_PATH.updateables.$source" "$NEW_VERSION"
|
|
|
|
|
done
|
2020-10-04 11:59:52 +01:00
|
|
|
|
'';
|
2022-04-28 20:53:26 +01:00
|
|
|
|
|
|
|
|
|
# All sources for updating by the update script.
|
|
|
|
|
updateables =
|
|
|
|
|
let
|
|
|
|
|
createName =
|
|
|
|
|
path:
|
|
|
|
|
|
|
|
|
|
builtins.replaceStrings [ "." ] [ "_" ] (lib.concatStringsSep "_" path);
|
|
|
|
|
|
|
|
|
|
createSourceParams =
|
|
|
|
|
path:
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
# The path will be either [«system» sha256], or [«system» sha256 «phpMajor» «zts»],
|
|
|
|
|
# Let’s skip the sha256.
|
|
|
|
|
rest = builtins.tail (builtins.tail path);
|
|
|
|
|
in {
|
|
|
|
|
system =
|
|
|
|
|
builtins.head path;
|
|
|
|
|
phpMajor =
|
|
|
|
|
if builtins.length rest == 0
|
|
|
|
|
then null
|
|
|
|
|
else builtins.head rest;
|
|
|
|
|
ztsSupport =
|
|
|
|
|
if builtins.length rest == 0
|
|
|
|
|
then null
|
|
|
|
|
else
|
|
|
|
|
builtins.head (builtins.tail rest) == "zts";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
createUpdateable =
|
|
|
|
|
path:
|
|
|
|
|
_value:
|
|
|
|
|
|
|
|
|
|
lib.nameValuePair
|
|
|
|
|
(createName path)
|
|
|
|
|
(self.overrideAttrs (attrs: {
|
|
|
|
|
src = makeSource (createSourceParams path);
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
hashesOnly =
|
|
|
|
|
# Filter out all attributes other than hashes.
|
|
|
|
|
lib.filterAttrsRecursive (name: _value: name != "system") hashes;
|
|
|
|
|
in
|
|
|
|
|
builtins.listToAttrs
|
|
|
|
|
# Collect all leaf attributes (containing hashes).
|
|
|
|
|
(lib.collect
|
|
|
|
|
(attrs: attrs ? name)
|
|
|
|
|
(lib.mapAttrsRecursive createUpdateable hashesOnly));
|
2020-10-04 11:59:52 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
|
description = "Blackfire Profiler PHP module";
|
|
|
|
|
homepage = "https://blackfire.io/";
|
|
|
|
|
license = licenses.unfree;
|
2022-04-28 20:53:26 +01:00
|
|
|
|
maintainers = with maintainers; [ jtojnar shyim ];
|
|
|
|
|
platforms = [ "x86_64-linux" "aarch64-linux" "i686-linux" "x86_64-darwin" "aarch64-darwin" ];
|
2020-10-04 11:59:52 +01:00
|
|
|
|
};
|
2022-04-28 20:53:26 +01:00
|
|
|
|
};
|
|
|
|
|
in
|
|
|
|
|
self
|