at 23.11-beta 105 lines 3.4 kB view raw
1{ stdenv 2, lib 3, fetchurl 4, dpkg 5, writeShellScript 6, curl 7, jq 8, common-updater-scripts 9}: 10 11stdenv.mkDerivation rec { 12 pname = "blackfire"; 13 version = "2.23.0"; 14 15 src = passthru.sources.${stdenv.hostPlatform.system} or (throw "Unsupported platform for blackfire: ${stdenv.hostPlatform.system}"); 16 17 nativeBuildInputs = lib.optionals stdenv.isLinux [ 18 dpkg 19 ]; 20 21 dontUnpack = true; 22 23 installPhase = '' 24 runHook preInstall 25 26 if ${ lib.boolToString stdenv.isLinux } 27 then 28 dpkg-deb -x $src $out 29 mv $out/usr/* $out 30 rmdir $out/usr 31 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' "" 40 41 # Modernize socket path. 42 substituteInPlace "$out/etc/blackfire/agent" \ 43 --replace '/var/run' '/run' 44 else 45 mkdir $out 46 47 tar -zxvf $src 48 49 mv etc $out 50 mv usr/* $out 51 fi 52 53 runHook postInstall 54 ''; 55 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 = "g92AUmrfu+naLUo11u0fqJKPRiY2nSIUAqZY4D6ti0I="; 61 }; 62 "i686-linux" = fetchurl { 63 url = "https://packages.blackfire.io/debian/pool/any/main/b/blackfire/blackfire_${version}_i386.deb"; 64 sha256 = "l8KwAvD8tWiVNYCp9HikBDPSr+8iYhp5svdTkhitxy0="; 65 }; 66 "aarch64-linux" = fetchurl { 67 url = "https://packages.blackfire.io/debian/pool/any/main/b/blackfire/blackfire_${version}_arm64.deb"; 68 sha256 = "Ffg2kwg/jOMwEHujfb0x4tjc6PLPswVi3EWm+u/o5wc="; 69 }; 70 "aarch64-darwin" = fetchurl { 71 url = "https://packages.blackfire.io/blackfire/${version}/blackfire-darwin_arm64.pkg.tar.gz"; 72 sha256 = "yywxgvzK7BKzYsiElYLy8M80RKIp6ksNv0wq4QzRyfY="; 73 }; 74 "x86_64-darwin" = fetchurl { 75 url = "https://packages.blackfire.io/blackfire/${version}/blackfire-darwin_amd64.pkg.tar.gz"; 76 sha256 = "4o34UR411nokdvpSMhbdrL9D4r4ZqoS7pwDEj153GZg="; 77 }; 78 }; 79 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) 84 85 if [[ "${version}" = "$NEW_VERSION" ]]; then 86 echo "The new version same as the old version." 87 exit 0 88 fi 89 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 }; 96 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 }; 105}