biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / development / tools / misc / blackfire / default.nix
blob51056d7301b2bf46cb67cab7dcfdad814ebce2b2
1 { stdenv
2 , lib
3 , fetchurl
4 , dpkg
5 , writeShellScript
6 , curl
7 , jq
8 , common-updater-scripts
9 }:
11 stdenv.mkDerivation rec {
12   pname = "blackfire";
13   version = "2.26.4";
15   src = passthru.sources.${stdenv.hostPlatform.system} or (throw "Unsupported platform for blackfire: ${stdenv.hostPlatform.system}");
17   nativeBuildInputs = lib.optionals stdenv.isLinux [
18     dpkg
19   ];
21   dontUnpack = true;
23   installPhase = ''
24     runHook preInstall
26     if ${ lib.boolToString stdenv.isLinux }
27     then
28       dpkg-deb -x $src $out
29       mv $out/usr/* $out
30       rmdir $out/usr
32       # Fix ExecStart path and replace deprecated directory creation method,
33       # use dynamic user.
34       substituteInPlace "$out/lib/systemd/system/blackfire-agent.service" \
35         --replace '/usr/' "$out/" \
36         --replace 'ExecStartPre=/bin/mkdir -p /var/run/blackfire' 'RuntimeDirectory=blackfire' \
37         --replace 'ExecStartPre=/bin/chown blackfire: /var/run/blackfire' "" \
38         --replace 'User=blackfire' 'DynamicUser=yes' \
39         --replace 'PermissionsStartOnly=true' ""
41       # Modernize socket path.
42       substituteInPlace "$out/etc/blackfire/agent" \
43         --replace '/var/run' '/run'
44     else
45       mkdir $out
47       tar -zxvf $src
49       mv etc $out
50       mv usr/* $out
51     fi
53     runHook postInstall
54   '';
56   passthru = {
57     sources = {
58       "x86_64-linux" = fetchurl {
59         url = "https://packages.blackfire.io/debian/pool/any/main/b/blackfire/blackfire_${version}_amd64.deb";
60         sha256 = "czFzZ+Z2CYw0ETzsmimAMNKrpiIVufyguOYuZJu2L8s=";
61       };
62       "i686-linux" = fetchurl {
63         url = "https://packages.blackfire.io/debian/pool/any/main/b/blackfire/blackfire_${version}_i386.deb";
64         sha256 = "I/7ZESjJjlRSvV41ldEtdymp7fwe0tCCFeS/oouOUi8=";
65       };
66       "aarch64-linux" = fetchurl {
67         url = "https://packages.blackfire.io/debian/pool/any/main/b/blackfire/blackfire_${version}_arm64.deb";
68         sha256 = "lJn9iRAPkLCpv+Vbk72a58DaNgNOTfyFiycyHosBiq4=";
69       };
70       "aarch64-darwin" = fetchurl {
71         url = "https://packages.blackfire.io/blackfire/${version}/blackfire-darwin_arm64.pkg.tar.gz";
72         sha256 = "puvM/QB8nJgJaw1eDMJTb9aDrIdrqO3WVdDYWeayTAs=";
73       };
74       "x86_64-darwin" = fetchurl {
75         url = "https://packages.blackfire.io/blackfire/${version}/blackfire-darwin_amd64.pkg.tar.gz";
76         sha256 = "srv99KyjxzEJNRA4hjoobSqzSab+Ox7g80tTun3G9KY=";
77       };
78     };
80     updateScript = writeShellScript "update-blackfire" ''
81       set -o errexit
82       export PATH="${lib.makeBinPath [ curl jq common-updater-scripts ]}"
83       NEW_VERSION=$(curl -s https://blackfire.io/api/v1/releases | jq .cli --raw-output)
85       if [[ "${version}" = "$NEW_VERSION" ]]; then
86           echo "The new version same as the old version."
87           exit 0
88       fi
90       for platform in ${lib.escapeShellArgs meta.platforms}; do
91         update-source-version "blackfire" "0" "${lib.fakeSha256}" --source-key="sources.$platform"
92         update-source-version "blackfire" "$NEW_VERSION" --source-key="sources.$platform"
93       done
94     '';
95   };
97   meta = with lib; {
98     description = "Blackfire Profiler agent and client";
99     homepage = "https://blackfire.io/";
100     sourceProvenance = with sourceTypes; [ binaryNativeCode ];
101     license = licenses.unfree;
102     maintainers = with maintainers; [ shyim ];
103     platforms = [ "x86_64-linux" "aarch64-linux" "i686-linux" "x86_64-darwin" "aarch64-darwin" ];
104   };