2020-10-11 12:50:04 +00:00
|
|
|
|
{ stdenv
|
|
|
|
|
, lib
|
|
|
|
|
, fetchurl
|
|
|
|
|
, dpkg
|
|
|
|
|
, autoPatchelfHook
|
|
|
|
|
, php
|
|
|
|
|
, writeShellScript
|
|
|
|
|
, curl
|
|
|
|
|
, jq
|
|
|
|
|
, common-updater-scripts
|
|
|
|
|
}:
|
|
|
|
|
|
|
|
|
|
let
|
2022-04-27 09:35:20 +00:00
|
|
|
|
phpMajor = lib.versions.majorMinor php.version;
|
2020-10-11 12:50:04 +00:00
|
|
|
|
soFile = {
|
|
|
|
|
"7.4" = "blackfire-20190902";
|
2020-12-03 08:41:04 +00:00
|
|
|
|
"8.0" = "blackfire-20200930";
|
2021-12-19 01:06:50 +00:00
|
|
|
|
"8.1" = "blackfire-20210902";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
}.${phpMajor} or (throw "Unsupported PHP version.");
|
|
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
|
version = "1.84.0";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
|
|
|
|
|
hashes = {
|
|
|
|
|
"x86_64-linux" = {
|
|
|
|
|
system = "amd64";
|
2022-12-17 10:02:37 +00:00
|
|
|
|
sha256 = "4tAqe1ev2s4ZwzPptgXuVL4ZXF37ieGyonBxOFMUKTs=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
"i686-linux" = {
|
|
|
|
|
system = "i386";
|
2022-12-17 10:02:37 +00:00
|
|
|
|
sha256 = "OPvn1zcBJDfUu7m3evRayVZNuZJ/KLblm6u4P0z0CvU=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
"aarch64-linux" = {
|
|
|
|
|
system = "arm64";
|
2022-12-17 10:02:37 +00:00
|
|
|
|
sha256 = "5P6tVYshPsR4Xl8sCYFuNIRf8LvE6PxWpynP3ZzoP0s=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
"aarch64-darwin" = {
|
|
|
|
|
system = "arm64";
|
|
|
|
|
sha256 = {
|
|
|
|
|
"7.4" = {
|
2022-12-17 10:02:37 +00:00
|
|
|
|
normal = "wNv5LiCbkiyPQFH1jr4Aw4kjHnpqxPa427H4nzNkE8A=";
|
|
|
|
|
zts = "FmvzFtukFZPqOz6wkFEtXrb+H8A9bb6ZqeEN9jjtwOQ=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
"8.0" = {
|
2022-12-17 10:02:37 +00:00
|
|
|
|
normal = "tEGMtQf/K5x+dTEd067nhalezmWLKf1A4hM7HM1iwNE=";
|
|
|
|
|
zts = "ivbcoqM2U4Zh86+AAml8bHQEn1731A9XsCqW8ai6oKg=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
"8.1" = {
|
2022-12-17 10:02:37 +00:00
|
|
|
|
normal = "9GFqlGS2qZWSUoOyYb86RyFdUx2AkQlcq6N2cWHFQ2s=";
|
|
|
|
|
zts = "KnxJUxenPxPw0Mo6GdtyLpPN06/K0cSHk2cf7Akf3BE=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
"x86_64-darwin" = {
|
|
|
|
|
system = "amd64";
|
|
|
|
|
sha256 = {
|
|
|
|
|
"7.4" = {
|
2022-12-17 10:02:37 +00:00
|
|
|
|
normal = "s6aS3INNzOMIV0qW5ROrjX68obnixsOZ4ktnDb/3dGo=";
|
|
|
|
|
zts = "4OdHSLLMo9tSVQnaTYfzogeloYPvHxbHhQgACo2V7zA=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
"8.0" = {
|
2022-12-17 10:02:37 +00:00
|
|
|
|
normal = "JZ6ITbzW7nHmJEQv2KXKPjU9wkY7mH6+tFRJFhJw7ug=";
|
|
|
|
|
zts = "x/uP64Ec2tvUylmnWfxsqJMUNlVsFnrxK3CWHdXfgus=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
"8.1" = {
|
2022-12-17 10:02:37 +00:00
|
|
|
|
normal = "foK+vRwM6PHgToYiPVZIXde18jYJ3bV0Gz23bNS1UYg=";
|
|
|
|
|
zts = "LhaaUhOSnAPqHn7LqPgq2UOkS/MoY3CHcpGoFeh+hyo=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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-11 12:50:04 +00:00
|
|
|
|
pname = "php-blackfire";
|
2022-12-17 10:02:37 +00:00
|
|
|
|
extensionName = "blackfire";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
inherit version;
|
2020-10-11 12:50:04 +00:00
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
|
src = makeSource {
|
|
|
|
|
system = stdenv.hostPlatform.system;
|
|
|
|
|
inherit phpMajor;
|
|
|
|
|
inherit (php) ztsSupport;
|
2020-10-11 12:50:04 +00:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
|
nativeBuildInputs = lib.optionals stdenv.isLinux [
|
2020-10-11 12:50:04 +00:00
|
|
|
|
dpkg
|
|
|
|
|
autoPatchelfHook
|
|
|
|
|
];
|
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
|
setSourceRoot = if stdenv.isDarwin then "sourceRoot=`pwd`" else null;
|
2020-10-11 12:50:04 +00:00
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
|
unpackPhase = if stdenv.isLinux then ''
|
|
|
|
|
runHook preUnpack
|
2020-10-11 12:50:04 +00:00
|
|
|
|
dpkg-deb -x $src pkg
|
|
|
|
|
sourceRoot=pkg
|
|
|
|
|
|
|
|
|
|
runHook postUnpack
|
2022-04-27 09:35:20 +00:00
|
|
|
|
'' else null;
|
2020-10-11 12:50:04 +00:00
|
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
|
runHook preInstall
|
|
|
|
|
|
2022-04-27 09:35:20 +00: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-11 12:50:04 +00:00
|
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
|
updateScript = writeShellScript "update-${pname}" ''
|
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 --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-11 12:50:04 +00:00
|
|
|
|
'';
|
2022-04-27 09:35:20 +00: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-11 12:50:04 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
|
description = "Blackfire Profiler PHP module";
|
|
|
|
|
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-04-27 09:35:20 +00:00
|
|
|
|
platforms = [ "x86_64-linux" "aarch64-linux" "i686-linux" "x86_64-darwin" "aarch64-darwin" ];
|
2020-10-11 12:50:04 +00:00
|
|
|
|
};
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
in
|
|
|
|
|
self
|