1{
2 stdenvNoCC,
3 lib,
4 fetchurl,
5 autoPatchelfHook,
6 php,
7 writeShellApplication,
8 curl,
9 gnugrep,
10 common-updater-scripts,
11}:
12
13let
14 soFile =
15 {
16 "8.0" = "tideways-php-8.0.so";
17 "8.1" = "tideways-php-8.1.so";
18 "8.2" = "tideways-php-8.2.so";
19 "8.3" = "tideways-php-8.3.so";
20 }
21 .${lib.versions.majorMinor php.version} or (throw "Unsupported PHP version.");
22in
23stdenvNoCC.mkDerivation (finalAttrs: {
24 pname = "tideways-php";
25 extensionName = "tideways";
26 version = "5.20.0";
27
28 src =
29 finalAttrs.passthru.sources.${stdenvNoCC.hostPlatform.system}
30 or (throw "Unsupported platform for tideways-php: ${stdenvNoCC.hostPlatform.system}");
31
32 nativeBuildInputs = lib.optionals stdenvNoCC.hostPlatform.isLinux [
33 autoPatchelfHook
34 ];
35
36 installPhase = ''
37 runHook preInstall
38 install -D ${soFile} $out/lib/php/extensions/tideways.so
39 runHook postInstall
40 '';
41
42 passthru = {
43 sources = {
44 "x86_64-linux" = fetchurl {
45 url = "https://s3-eu-west-1.amazonaws.com/tideways/extension/${finalAttrs.version}/tideways-php-${finalAttrs.version}-x86_64.tar.gz";
46 hash = "sha256-uAmsmz+4tsCGw4jlzyZbUNjuzBU/HcIDWrHCC+0t4Xw=";
47 };
48 "aarch64-linux" = fetchurl {
49 url = "https://s3-eu-west-1.amazonaws.com/tideways/extension/${finalAttrs.version}/tideways-php-${finalAttrs.version}-arm64.tar.gz";
50 hash = "sha256-gPhr32G6h/U1uR/aaeIWpOaDV9HF8EbQF7p1kJ5SDis=";
51 };
52 "aarch64-darwin" = fetchurl {
53 url = "https://s3-eu-west-1.amazonaws.com/tideways/extension/${finalAttrs.version}/tideways-php-${finalAttrs.version}-macos-arm.tar.gz";
54 hash = "sha256-VfgX1SNYKoFR290gRoRXfD5CoLhDPkK+3+4o13P1kiM=";
55 };
56 };
57
58 updateScript = "${
59 writeShellApplication {
60 name = "update-tideways-probe";
61 runtimeInputs = [
62 curl
63 gnugrep
64 common-updater-scripts
65 ];
66 text = ''
67 NEW_VERSION=$(curl --fail -L https://tideways.com/profiler/downloads | grep -E 'https://tideways.s3.amazonaws.com/extension/[0-9]+\.[0-9]+\.[0-9]+/tideways-php-[0-9]+\.[0-9]+\.[0-9]+-x86_64.tar.gz' | grep -oP 'extension/\K[0-9]+\.[0-9]+\.[0-9]+')
68
69 if [[ "${finalAttrs.version}" = "$NEW_VERSION" ]]; then
70 echo "The new version same as the old version."
71 exit 0
72 fi
73
74 for platform in ${lib.escapeShellArgs finalAttrs.meta.platforms}; do
75 update-source-version "php82Extensions.tideways" "$NEW_VERSION" --ignore-same-version --source-key="sources.$platform"
76 done
77 '';
78 }
79 }/bin/update-tideways-probe";
80 };
81
82 meta = with lib; {
83 description = "Tideways PHP Probe";
84 homepage = "https://tideways.com/";
85 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
86 license = licenses.unfree;
87 maintainers = with maintainers; [ shyim ];
88 platforms = lib.attrNames finalAttrs.passthru.sources;
89 };
90})