9 , common-updater-scripts
12 assert lib.assertMsg (!php.ztsSupport) "blackfire only supports non zts versions of PHP";
15 phpMajor = lib.versions.majorMinor php.version;
23 "8.1" = "sha256-QpvnhIvjhm5tqOP72T2yVxV92M3ty/iDICaWsOVFpNg=";
24 "8.2" = "sha256-NhNbhOGRlhGvTcG4uZwTASWqLp7PQnfDW48GzROxkII=";
25 "8.3" = "sha256-Gn3M0ANj05QoAZB6W3HWj4zNCDya7lqa+OTv57fnEQ8=";
31 "8.1" = "sha256-zhCjSPTO/RGcc+qvkYlEeV+9ulIXpA0dCMRlSWwj8ys=";
32 "8.2" = "sha256-J+zdMC4q+MHmwADivqdEfSq8h/KeD5TAanCJKZLuEog=";
33 "8.3" = "sha256-GGNje7mg1uaLN3zrDXG/igLW9+nhxvPp7nIYW6aJBa4=";
39 "8.1" = "sha256-C2ie8tp3F0sr+edYbUBVw0b1YJtnjyneC8/+x6LWENg=";
40 "8.2" = "sha256-Ku1pulSErVMvBtiNvLgRw2NpE/bEOkjZ5TY7F/PYJto=";
41 "8.3" = "sha256-/U/qf7Aqxssvcnc06+K5JeG96Ab09zRvUYcwhSAW4b8=";
47 "8.1" = "sha256-OdqG7G3TzuCVzBA0Xf+It05S6XaVlEd+ugM+gk70OiE=";
48 "8.2" = "sha256-/nCBQzimhcCrzNuwSVybHBmZZJImm75jKGqh2oXyyZA=";
49 "8.3" = "sha256-C2SxPYYXewU6PekQ3m1MBiPMPS5tE53gda2Qo7rZ1YQ=";
55 "8.1" = "sha256-W3reCFcN/bM3hrUeekJLG5qntH/Wvfb+JVly5+g2YEY=";
56 "8.2" = "sha256-d2YSmyV0mq7KBqoD4Bwdh3izh6hcKTBf6kP+q3QVnfI=";
57 "8.3" = "sha256-JiCw8Lew2laxOyb+2aSDqlZz2MafFwYwV46dqceEcBk=";
62 makeSource = { system, phpMajor }:
64 isLinux = builtins.match ".+-linux" system != null;
66 assert !isLinux -> (phpMajor != null);
68 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";
69 hash = hashes.${system}.hash.${phpMajor};
72 stdenv.mkDerivation (finalAttrs: {
73 pname = "php-blackfire";
74 extensionName = "blackfire";
78 system = stdenv.hostPlatform.system;
82 nativeBuildInputs = lib.optionals stdenv.isLinux [
93 install -D ${finalAttrs.src} $out/lib/php/extensions/blackfire.so
99 updateScript = writeShellScript "update-${finalAttrs.pname}" ''
101 export PATH="${lib.makeBinPath [ curl jq common-updater-scripts ]}"
102 NEW_VERSION=$(curl --silent https://blackfire.io/api/v1/releases | jq .probe.php --raw-output)
104 if [[ "${version}" = "$NEW_VERSION" ]]; then
105 echo "The new version same as the old version."
109 for source in ${lib.concatStringsSep " " (builtins.attrNames finalAttrs.passthru.updateables)}; do
110 update-source-version "$UPDATE_NIX_ATTR_PATH.updateables.$source" "0" "sha256-${lib.fakeSha256}"
111 update-source-version "$UPDATE_NIX_ATTR_PATH.updateables.$source" "$NEW_VERSION"
115 # All sources for updating by the update script.
119 builtins.replaceStrings [ "." ] [ "_" ] (lib.concatStringsSep "_" path);
121 createSourceParams = path:
123 # The path will be either [«system» sha256], or [«system» sha256 «phpMajor» «zts»],
124 # Let’s skip the sha256.
125 rest = builtins.tail (builtins.tail path);
131 if builtins.length rest == 0
133 else builtins.head rest;
136 createUpdateable = path: _value:
139 (finalAttrs.finalPackage.overrideAttrs (attrs: {
140 src = makeSource (createSourceParams path);
143 # Filter out all attributes other than hashes.
144 hashesOnly = lib.filterAttrsRecursive (name: _value: name != "system") hashes;
147 # Collect all leaf attributes (containing hashes).
149 (attrs: attrs ? name)
150 (lib.mapAttrsRecursive createUpdateable hashesOnly));
154 description = "Blackfire Profiler PHP module";
155 homepage = "https://blackfire.io/";
156 license = lib.licenses.unfree;
157 maintainers = with lib.maintainers; [ shyim ];
158 platforms = [ "x86_64-linux" "aarch64-linux" "i686-linux" "x86_64-darwin" "aarch64-darwin" ];
159 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];