2020-10-11 12:50:04 +00:00
|
|
|
|
{ stdenv
|
|
|
|
|
, lib
|
|
|
|
|
, fetchurl
|
|
|
|
|
, autoPatchelfHook
|
|
|
|
|
, php
|
|
|
|
|
, writeShellScript
|
|
|
|
|
, curl
|
|
|
|
|
, jq
|
|
|
|
|
, common-updater-scripts
|
|
|
|
|
}:
|
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
|
assert lib.assertMsg (!php.ztsSupport) "blackfire only supports non zts versions of PHP";
|
|
|
|
|
|
2020-10-11 12:50:04 +00:00
|
|
|
|
let
|
2022-04-27 09:35:20 +00:00
|
|
|
|
phpMajor = lib.versions.majorMinor php.version;
|
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
|
version = "1.92.15";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
|
|
|
|
|
hashes = {
|
|
|
|
|
"x86_64-linux" = {
|
|
|
|
|
system = "amd64";
|
2023-07-15 17:15:38 +00:00
|
|
|
|
hash = {
|
2024-05-15 15:35:15 +00:00
|
|
|
|
"8.1" = "sha256-CTh3HdTZS5tjnSN5JUX55aioFSqs3FQfy7S5ofXlyBs=";
|
|
|
|
|
"8.2" = "sha256-q/Zwpvm+pT6JdkC2nX7fEf+eDmWmtLniL+5Cys8kdNI=";
|
|
|
|
|
"8.3" = "sha256-8MGY3Spa4cWqUL4S/qHKPJql5DRhtvmYEE3oBLNNm3M=";
|
2023-01-20 10:41:00 +00:00
|
|
|
|
};
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
"i686-linux" = {
|
|
|
|
|
system = "i386";
|
2023-07-15 17:15:38 +00:00
|
|
|
|
hash = {
|
2024-05-15 15:35:15 +00:00
|
|
|
|
"8.1" = "sha256-mOiBQLXiPYMgHpcPTguEm0hffm+DZnv6MCbFbmRoEdE=";
|
|
|
|
|
"8.2" = "sha256-3xPG33DSxnQ9a9rbTov5ILi3hPWsruNZJS1NXttxfxQ=";
|
|
|
|
|
"8.3" = "sha256-4Nk+8ZIZ83/oeygDdhHI0mRRCvOEMmdWJoteDVkYuT4=";
|
2023-01-20 10:41:00 +00:00
|
|
|
|
};
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
"aarch64-linux" = {
|
|
|
|
|
system = "arm64";
|
2023-07-15 17:15:38 +00:00
|
|
|
|
hash = {
|
2024-05-15 15:35:15 +00:00
|
|
|
|
"8.1" = "sha256-5XUk2v65ceHqnfatLq9E1+J5QRgCDpKxR4ZFpCAsfdI=";
|
|
|
|
|
"8.2" = "sha256-Lr8wBAXYHXwPokwQMni5tsNncor9ZRjNwtL/5hodUq8=";
|
|
|
|
|
"8.3" = "sha256-KZLPFaa5NPksfhA99S8qV3FngJTDonhG+MMPkCwxUys=";
|
2023-01-20 10:41:00 +00:00
|
|
|
|
};
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
"aarch64-darwin" = {
|
|
|
|
|
system = "arm64";
|
2023-07-15 17:15:38 +00:00
|
|
|
|
hash = {
|
2024-05-15 15:35:15 +00:00
|
|
|
|
"8.1" = "sha256-G5wrH9M+b69BLKRI4n9FydGDV/q7Ch7u+Zvol2+ptwI=";
|
|
|
|
|
"8.2" = "sha256-zgcYT2oWCa2kc4wLx94nxRjg0sebjdGxuPJNbiBZ/Is=";
|
|
|
|
|
"8.3" = "sha256-l1zNH47lNpHj7qRgqoxJisn7dU2VzSGFt0v8/9VpYiI=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
"x86_64-darwin" = {
|
|
|
|
|
system = "amd64";
|
2023-07-15 17:15:38 +00:00
|
|
|
|
hash = {
|
2024-05-15 15:35:15 +00:00
|
|
|
|
"8.1" = "sha256-mmmzmR4yzwmXAl6YoSOKSivF7uixGZYaFQVIqWd0Ud4=";
|
|
|
|
|
"8.2" = "sha256-1jnw3BADm38C1Hi4lBs5B+kJl1karTljVHxHGEfZmtw=";
|
|
|
|
|
"8.3" = "sha256-7a2JyeLP4HwyaYsb7zAio2HrUPbBVpVEOUjWKCilkFY=";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
|
makeSource = { system, phpMajor }:
|
2022-04-27 09:35:20 +00:00
|
|
|
|
let
|
|
|
|
|
isLinux = builtins.match ".+-linux" system != null;
|
|
|
|
|
in
|
2023-01-20 10:41:00 +00:00
|
|
|
|
assert !isLinux -> (phpMajor != null);
|
2022-04-27 09:35:20 +00:00
|
|
|
|
fetchurl {
|
2023-07-15 17:15:38 +00:00
|
|
|
|
url = "https://packages.blackfire.io/binaries/blackfire-php/${version}/blackfire-php-${if isLinux then "linux" else "darwin"}_${hashes.${system}.system}-php-${builtins.replaceStrings [ "." ] [ "" ] phpMajor}.so";
|
|
|
|
|
hash = hashes.${system}.hash.${phpMajor};
|
2022-04-27 09:35:20 +00:00
|
|
|
|
};
|
2023-07-15 17:15:38 +00:00
|
|
|
|
in
|
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
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;
|
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
|
|
|
|
autoPatchelfHook
|
|
|
|
|
];
|
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
|
sourceRoot = ".";
|
2020-10-11 12:50:04 +00:00
|
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
|
dontUnpack = true;
|
2020-10-11 12:50:04 +00:00
|
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
|
runHook preInstall
|
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
|
install -D ${finalAttrs.src} $out/lib/php/extensions/blackfire.so
|
2020-10-11 12:50:04 +00:00
|
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
passthru = {
|
2023-07-15 17:15:38 +00:00
|
|
|
|
updateScript = writeShellScript "update-${finalAttrs.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
|
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
|
for source in ${lib.concatStringsSep " " (builtins.attrNames finalAttrs.passthru.updateables)}; do
|
|
|
|
|
update-source-version "$UPDATE_NIX_ATTR_PATH.updateables.$source" "0" "sha256-${lib.fakeSha256}"
|
2022-04-27 09:35:20 +00:00
|
|
|
|
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
|
2023-07-15 17:15:38 +00:00
|
|
|
|
createName = path:
|
2022-04-27 09:35:20 +00:00
|
|
|
|
builtins.replaceStrings [ "." ] [ "_" ] (lib.concatStringsSep "_" path);
|
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
|
createSourceParams = path:
|
2022-04-27 09:35:20 +00:00
|
|
|
|
let
|
|
|
|
|
# The path will be either [«system» sha256], or [«system» sha256 «phpMajor» «zts»],
|
|
|
|
|
# Let’s skip the sha256.
|
|
|
|
|
rest = builtins.tail (builtins.tail path);
|
2023-07-15 17:15:38 +00:00
|
|
|
|
in
|
|
|
|
|
{
|
2022-04-27 09:35:20 +00:00
|
|
|
|
system =
|
|
|
|
|
builtins.head path;
|
|
|
|
|
phpMajor =
|
|
|
|
|
if builtins.length rest == 0
|
|
|
|
|
then null
|
|
|
|
|
else builtins.head rest;
|
|
|
|
|
};
|
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
|
createUpdateable = path: _value:
|
|
|
|
|
lib.nameValuePair
|
|
|
|
|
(createName path)
|
|
|
|
|
(finalAttrs.finalPackage.overrideAttrs (attrs: {
|
|
|
|
|
src = makeSource (createSourceParams path);
|
|
|
|
|
}));
|
2022-04-27 09:35:20 +00:00
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
|
# Filter out all attributes other than hashes.
|
|
|
|
|
hashesOnly = lib.filterAttrsRecursive (name: _value: name != "system") hashes;
|
2022-04-27 09:35:20 +00:00
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
|
meta = {
|
2020-10-11 12:50:04 +00:00
|
|
|
|
description = "Blackfire Profiler PHP module";
|
|
|
|
|
homepage = "https://blackfire.io/";
|
2023-07-15 17:15:38 +00:00
|
|
|
|
license = lib.licenses.unfree;
|
|
|
|
|
maintainers = with lib.maintainers; [ shyim ];
|
2022-04-27 09:35:20 +00:00
|
|
|
|
platforms = [ "x86_64-linux" "aarch64-linux" "i686-linux" "x86_64-darwin" "aarch64-darwin" ];
|
2023-07-15 17:15:38 +00:00
|
|
|
|
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
2020-10-11 12:50:04 +00:00
|
|
|
|
};
|
2023-07-15 17:15:38 +00:00
|
|
|
|
})
|