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-09-19 14:19:46 +00:00
|
|
|
inherit (stdenv.hostPlatform) system;
|
2022-04-27 09:35:20 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
version = "1.92.22";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
|
|
|
hashes = {
|
|
|
|
"x86_64-linux" = {
|
|
|
|
system = "amd64";
|
2023-07-15 17:15:38 +00:00
|
|
|
hash = {
|
2024-09-19 14:19:46 +00:00
|
|
|
"8.1" = "sha256-MWAKoshKC+hW8ldRLfYQIcMwpSHvW+hV9dRMvZ4rqcU=";
|
|
|
|
"8.2" = "sha256-xAdECbxuaV5PxG+X7+o2p5pOEG9lgRLuOTp46k5I4RM=";
|
|
|
|
"8.3" = "sha256-4vCLpSy4kJ4qwOSonSFvlevCfNMxjIU6AUswm0uG59o=";
|
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-09-19 14:19:46 +00:00
|
|
|
"8.1" = "sha256-fvXv3Yn3FXBO4EIgb/5LI3jJxV5HA2Q2JCNy14bA8eU=";
|
|
|
|
"8.2" = "sha256-0m2ze1e09IUGjTpxbyTOchQBBMa86cpiMrAImiXrAZ0=";
|
|
|
|
"8.3" = "sha256-nhVP4/Ls71MxPN6Ko1bDG8PSHkHQt+vC08EbP0WAL8g=";
|
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-09-19 14:19:46 +00:00
|
|
|
"8.1" = "sha256-pvzKVvtpBh+nwppqSqxSsR989mWzwyAHtwIdDjWx08o=";
|
|
|
|
"8.2" = "sha256-O6RhO/PY2C4GubYl/jcTzpWeiUKSGy8Np4/KrlMsE1Y=";
|
|
|
|
"8.3" = "sha256-3sfjwXq980oRV8u+IAamyYKDp2UMREFaynigz/dpyXE=";
|
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-09-19 14:19:46 +00:00
|
|
|
"8.1" = "sha256-peZmwxzQ2NCKkq5qSraIb4pnnJDwcRkCyGW8qeBSGRk=";
|
|
|
|
"8.2" = "sha256-MvF7S+VITEnsJSLz3xEy927zIR6TN+p3nRGQFjKqtu8=";
|
|
|
|
"8.3" = "sha256-sUlD8cPk7emJPtz4en6AcFxs/7NUjxUMkqf/Qs3INIA=";
|
2022-04-27 09:35:20 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
"x86_64-darwin" = {
|
|
|
|
system = "amd64";
|
2023-07-15 17:15:38 +00:00
|
|
|
hash = {
|
2024-09-19 14:19:46 +00:00
|
|
|
"8.1" = "sha256-kMftb/fC9uyMZyjP4jmtYLM+xEhFqP7umQ5FLvR9vAo=";
|
|
|
|
"8.2" = "sha256-W8LXYz8KzWlzdpyqmo7XQmkzuyfXO0BZSkiBIlfi18g=";
|
|
|
|
"8.3" = "sha256-a/Q7avEJr/we5GF2NxTZywpsal5AkAGxEABMPCgy2LM=";
|
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
|
|
|
|
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
|
2024-09-19 14:19:46 +00:00
|
|
|
|
|
|
|
assert lib.assertMsg (hashes ? ${system}.hash.${phpMajor}) "blackfire does not support PHP version ${phpMajor} on ${system}.";
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
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 {
|
2024-09-19 14:19:46 +00:00
|
|
|
inherit system phpMajor;
|
2020-10-11 12:50:04 +00:00
|
|
|
};
|
|
|
|
|
2024-09-26 11:04:55 +00:00
|
|
|
nativeBuildInputs = lib.optionals stdenv.hostPlatform.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
|
2024-06-20 14:57:18 +00:00
|
|
|
update-source-version "$UPDATE_NIX_ATTR_PATH.updateables.$source" "$NEW_VERSION" --ignore-same-version
|
2022-04-27 09:35:20 +00:00
|
|
|
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
|
2024-09-19 14:19:46 +00:00
|
|
|
createName = { phpMajor, system }:
|
|
|
|
"php${builtins.replaceStrings [ "." ] [ "" ] phpMajor}_${system}";
|
|
|
|
|
|
|
|
createUpdateable = sourceParams:
|
2023-07-15 17:15:38 +00:00
|
|
|
lib.nameValuePair
|
2024-09-19 14:19:46 +00:00
|
|
|
(createName sourceParams)
|
2023-07-15 17:15:38 +00:00
|
|
|
(finalAttrs.finalPackage.overrideAttrs (attrs: {
|
2024-09-19 14:19:46 +00:00
|
|
|
src = makeSource sourceParams;
|
2023-07-15 17:15:38 +00:00
|
|
|
}));
|
2022-04-27 09:35:20 +00:00
|
|
|
in
|
2024-09-19 14:19:46 +00:00
|
|
|
lib.concatMapAttrs (
|
|
|
|
system:
|
|
|
|
{ hash, ... }:
|
|
|
|
|
|
|
|
lib.mapAttrs' (phpMajor: _hash: createUpdateable { inherit phpMajor system; }) hash
|
|
|
|
) hashes;
|
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
|
|
|
})
|