nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchurl,
5 autoPatchelfHook,
6 php,
7 writeShellScript,
8 curl,
9 jq,
10 common-updater-scripts,
11}:
12
13assert lib.assertMsg (!php.ztsSupport) "blackfire only supports non zts versions of PHP";
14
15let
16 phpMajor = lib.versions.majorMinor php.version;
17 inherit (stdenv.hostPlatform) system;
18
19 version = "1.92.51";
20
21 hashes = {
22 "x86_64-linux" = {
23 system = "amd64";
24 hash = {
25 "8.1" = "sha256-HxVqkPupo3LrKfbQGOqoxpGJjFN17Jlkdya4BjBsBVw=";
26 "8.2" = "sha256-ssbMa4Wa27nwhJZ16FT+qrB4LH/HztOtCx+MI+i16Pg=";
27 "8.3" = "sha256-p9SXxHQGmsjtSeRFt9vYS5XK6nouT7qbqmlWbEpb2Hk=";
28 "8.4" = "sha256-ArI/SNjPIbjwEBMHvKCdSOkth8qqBWT6W0RnoWyWA+o=";
29 "8.5" = "sha256-5e4f9iEn5QPZY6Z+05O7QxTwaW+cjmP6nB5fkpValoM=";
30 };
31 };
32 "i686-linux" = {
33 system = "i386";
34 hash = {
35 "8.1" = "sha256-mTw8v5DaP7D5qb3XwRZvx8XH4bTiuu2xzzo82KsrrZU=";
36 "8.2" = "sha256-Vtb0DVfPBC0JtK1XOPQ8KmA0Jq0pBBA3jkDaCV7icGg=";
37 "8.3" = "sha256-vnL8gfA6ejMcpnfKXalSOvl7vixwQLJBC3DTO4Dafow=";
38 "8.4" = "sha256-x9/BcZPJib0hal6M2vUVk1cLmN1gc3k6hypViTqForo=";
39 "8.5" = "sha256-aVmQ8vHS/oQeb44RyV5hggOt+VXLqP7wKDxgfpbopQQ=";
40 };
41 };
42 "aarch64-linux" = {
43 system = "arm64";
44 hash = {
45 "8.1" = "sha256-S41qr5wU2dsK0IBsR/mTALguPQU+SKYVTLP7DwGQo40=";
46 "8.2" = "sha256-eQkvDRxwQNXlkZ9XzcSRfkKjp/CTZGaFwolXq6TZWaE=";
47 "8.3" = "sha256-GBjjx0cSJjYCOdDiArUPA4iqOcgpk3y9o0wi6b6UJgM=";
48 "8.4" = "sha256-s4zcHogsOy1GjTAGJuO6i7S6dp/lmRVzbjJk3/t8Zn4=";
49 "8.5" = "sha256-/lFwv6p9izXj7X+pqZe9clcp+wSYtzIPnwqeE/HFqNk=";
50 };
51 };
52 "aarch64-darwin" = {
53 system = "arm64";
54 hash = {
55 "8.1" = "sha256-+ko465G24UELdMmEg4ZqOA9p0/0DSs3p+On6Gg2IVMM=";
56 "8.2" = "sha256-TERILY6E1vnl+L6t+oel+1H3HTHWTTeEb1rVXtriJ8w=";
57 "8.3" = "sha256-R5Ue3erVCe1gOPk1SuDRXGA05WPm1IisHCnbXfmjFcw=";
58 "8.4" = "sha256-qqbmZa4qd7Ck87GylHeHP9m3K47DAEiTxlKdtXEnzVo=";
59 "8.5" = "sha256-3d9glqfXCMXwtLZm8fuj9DVzCIczynX7MRxnbMC7/NE=";
60 };
61 };
62 "x86_64-darwin" = {
63 system = "amd64";
64 hash = {
65 "8.1" = "sha256-XvV6x8LKjR4j081PIdKpYCVl+ayXOmPsXf+gsMeFOro=";
66 "8.2" = "sha256-qxFWj1HpWokwzsFTiRhi4vw67H8yLwu1xbhja+fAxqY=";
67 "8.3" = "sha256-ffrwc48MZzX0MJHbaDmWQpday1LicOxhR2+fwylItD0=";
68 "8.4" = "sha256-P8j8gc8lZRbuVd1UmSpYmle88h50vhJfNxTZp3v9/Sg=";
69 "8.5" = "sha256-zy24hLCTajY+BVdkJCiXoy8abhQ82Ntw7Wuqn6zJKOQ=";
70 };
71 };
72 };
73
74 makeSource =
75 { system, phpMajor }:
76 let
77 isLinux = builtins.match ".+-linux" system != null;
78 in
79 fetchurl {
80 url = "https://packages.blackfire.io/binaries/blackfire-php/${version}/blackfire-php-${
81 if isLinux then "linux" else "darwin"
82 }_${hashes.${system}.system}-php-${builtins.replaceStrings [ "." ] [ "" ] phpMajor}.so";
83 hash = hashes.${system}.hash.${phpMajor};
84 };
85in
86
87assert lib.assertMsg (
88 hashes ? ${system}.hash.${phpMajor}
89) "blackfire does not support PHP version ${phpMajor} on ${system}.";
90
91stdenv.mkDerivation (finalAttrs: {
92 pname = "php-blackfire";
93 extensionName = "blackfire";
94 inherit version;
95
96 src = makeSource {
97 inherit system phpMajor;
98 };
99
100 nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [
101 autoPatchelfHook
102 ];
103
104 sourceRoot = ".";
105
106 dontUnpack = true;
107
108 installPhase = ''
109 runHook preInstall
110
111 install -D ${finalAttrs.src} $out/lib/php/extensions/blackfire.so
112
113 runHook postInstall
114 '';
115
116 passthru = {
117 updateScript = writeShellScript "update-${finalAttrs.pname}" ''
118 set -o errexit
119 export PATH="${
120 lib.makeBinPath [
121 curl
122 jq
123 common-updater-scripts
124 ]
125 }"
126 NEW_VERSION=$(curl --silent https://blackfire.io/api/v1/releases | jq .probe.php --raw-output)
127
128 if [[ "${version}" = "$NEW_VERSION" ]]; then
129 echo "The new version same as the old version."
130 exit 0
131 fi
132
133 for source in ${lib.concatStringsSep " " (builtins.attrNames finalAttrs.passthru.updateables)}; do
134 update-source-version "$UPDATE_NIX_ATTR_PATH.updateables.$source" "$NEW_VERSION" --ignore-same-version
135 done
136 '';
137
138 # All sources for updating by the update script.
139 updateables =
140 let
141 createName =
142 { phpMajor, system }: "php${builtins.replaceStrings [ "." ] [ "" ] phpMajor}_${system}";
143
144 createUpdateable =
145 sourceParams:
146 lib.nameValuePair (createName sourceParams) (
147 finalAttrs.finalPackage.overrideAttrs (attrs: {
148 src = makeSource sourceParams;
149 })
150 );
151 in
152 lib.concatMapAttrs (
153 system:
154 { hash, ... }:
155
156 lib.mapAttrs' (phpMajor: _hash: createUpdateable { inherit phpMajor system; }) hash
157 ) hashes;
158 };
159
160 meta = {
161 description = "Blackfire Profiler PHP module";
162 homepage = "https://blackfire.io/";
163 license = lib.licenses.unfree;
164 maintainers = [ ];
165 platforms = [
166 "x86_64-linux"
167 "aarch64-linux"
168 "i686-linux"
169 "x86_64-darwin"
170 "aarch64-darwin"
171 ];
172 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
173 };
174})