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-09-22 12:36:57 +00:00
|
|
|
|
version = "1.78.1";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
|
|
|
|
|
hashes = {
|
|
|
|
|
"x86_64-linux" = {
|
|
|
|
|
system = "amd64";
|
2022-09-22 12:36:57 +00:00
|
|
|
|
sha256 = "Q9VuZewJ/KX2ZL77d3YLsE80B0y3RYg/hE2H14s9An4=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
"i686-linux" = {
|
|
|
|
|
system = "i386";
|
2022-09-22 12:36:57 +00:00
|
|
|
|
sha256 = "YBt6OAeUsQZUyf7P6jIvknq2K0fGWl0xmJkEXFBlTyE=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
"aarch64-linux" = {
|
|
|
|
|
system = "arm64";
|
2022-09-22 12:36:57 +00:00
|
|
|
|
sha256 = "NTM3xdu+60EBz7pbRyTvhrvvZWVn4tl+LgnkHG1IpYM=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
"aarch64-darwin" = {
|
|
|
|
|
system = "arm64";
|
|
|
|
|
sha256 = {
|
|
|
|
|
"7.4" = {
|
2022-09-22 12:36:57 +00:00
|
|
|
|
normal = "4raEYMELZjWfC82348l94G9MTHX2jnF+ZvF4AAxN9JA=";
|
|
|
|
|
zts = "HWrcLRZeyFtfJId42iHDN2ci0kTfRoXC/pEv2tObNT8=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
"8.0" = {
|
2022-09-22 12:36:57 +00:00
|
|
|
|
normal = "kRTULbqlaK3bXRC8WQ1npeZHqWnuobN7eO20oYD5OIE=";
|
|
|
|
|
zts = "vWmSXueMIdi+hwmmhCQcltywphLjsNQoCW7eN2KDRvc=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
"8.1" = {
|
2022-09-22 12:36:57 +00:00
|
|
|
|
normal = "JSM/HC2ZYaSBl+cSUtaKQBYPziKk013mwyW9S4DoXFA=";
|
|
|
|
|
zts = "9OMm9rEs0o+daxhZdSps4NWQJegLU09zd3SLclGDOns=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
"x86_64-darwin" = {
|
|
|
|
|
system = "amd64";
|
|
|
|
|
sha256 = {
|
|
|
|
|
"7.4" = {
|
2022-09-22 12:36:57 +00:00
|
|
|
|
normal = "rWaf0Vjkrj78q+64Zy7gJ94Lfwd8waMaOWqoPqRJLRw=";
|
|
|
|
|
zts = "zU4cPAWc4k1OEho0fZKutcJ06LstSZhA4U18zx9nfi0=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
"8.0" = {
|
2022-09-22 12:36:57 +00:00
|
|
|
|
normal = "huGvDPaAmfy8YM6Bg3Y0Ys6JhfIdddOXl1DnnRQsvoE=";
|
|
|
|
|
zts = "V4QWMdMhbjQtb2M7g+oHvqy+Mv0Y9j9MwyqeuMZfYkg=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
"8.1" = {
|
2022-09-22 12:36:57 +00:00
|
|
|
|
normal = "pnxegrKPe8WoYAcrnBJanoYT1rg8nO8kQ7SJXQJfymg=";
|
|
|
|
|
zts = "m0grZ4Xl6Sm5ZPvmS6mcJGcQOA2ECPJKvzmccqPlyBE=";
|
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-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-04-27 09:35:20 +00:00
|
|
|
|
maintainers = with maintainers; [ jtojnar shyim ];
|
|
|
|
|
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
|