From 5cfcb62e178cdf4b25aba15bc3ddee0627f37c6b Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 16 Aug 2022 11:38:56 +0200 Subject: [PATCH] blackfire.updateScript: fix on different systems Running `update-source-version` with `--system` flag passes it to `nix-build -A $attr.src`, which requires that an appropriate builders are set on the system. It previously worked for me because I had aarch64-linux builder configured but broke down once Darwin support was added to the package. --- .../tools/misc/blackfire/default.nix | 67 +++++++++---------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/pkgs/development/tools/misc/blackfire/default.nix b/pkgs/development/tools/misc/blackfire/default.nix index 107076963b77..535b758ef4f2 100644 --- a/pkgs/development/tools/misc/blackfire/default.nix +++ b/pkgs/development/tools/misc/blackfire/default.nix @@ -8,39 +8,15 @@ , common-updater-scripts }: -let - version = "2.8.1"; - - sources = { - "x86_64-linux" = fetchurl { - url = "https://packages.blackfire.io/debian/pool/any/main/b/blackfire/blackfire_${version}_amd64.deb"; - sha256 = "znaM00jM6yrpb+bGTxzJUxViCUzv4G+CYK2EB5dxhfY="; - }; - "i686-linux" = fetchurl { - url = "https://packages.blackfire.io/debian/pool/any/main/b/blackfire/blackfire_${version}_i386.deb"; - sha256 = "QIY4qGm333H5MWhe3CIfEieqTEk8st5A7SJHkwGnnxw="; - }; - "aarch64-linux" = fetchurl { - url = "https://packages.blackfire.io/debian/pool/any/main/b/blackfire/blackfire_${version}_arm64.deb"; - sha256 = "eZbKoKYC2tt4Rxn5OJr7iA1aJlYFC0tpRmbLq7qSrIU="; - }; - "aarch64-darwin" = fetchurl { - url = "https://packages.blackfire.io/blackfire/${version}/blackfire-darwin_arm64.pkg.tar.gz"; - sha256 = "tn2vF3v7KfF7CfWqyydL5Iyh5tP9Tez87PJH+URgSIw="; - }; - "x86_64-darwin" = fetchurl { - url = "https://packages.blackfire.io/blackfire/${version}/blackfire-darwin_amd64.pkg.tar.gz"; - sha256 = "CRFlnqpX4j2CMGzS+UvXwNty2mHpONOjym6UJPE2Yg4="; - }; - }; -in stdenv.mkDerivation rec { pname = "blackfire"; - inherit version; + version = "2.8.1"; - src = sources.${stdenv.hostPlatform.system}; + src = passthru.sources.${stdenv.hostPlatform.system} or (throw "Unsupported platform for blackfire: ${stdenv.hostPlatform.system}"); - nativeBuildInputs = lib.optionals stdenv.isLinux [ dpkg ]; + nativeBuildInputs = lib.optionals stdenv.isLinux [ + dpkg + ]; dontUnpack = true; @@ -78,7 +54,30 @@ stdenv.mkDerivation rec { ''; passthru = { - updateScript = writeShellScript "update-${pname}" '' + sources = { + "x86_64-linux" = fetchurl { + url = "https://packages.blackfire.io/debian/pool/any/main/b/blackfire/blackfire_${version}_amd64.deb"; + sha256 = "znaM00jM6yrpb+bGTxzJUxViCUzv4G+CYK2EB5dxhfY="; + }; + "i686-linux" = fetchurl { + url = "https://packages.blackfire.io/debian/pool/any/main/b/blackfire/blackfire_${version}_i386.deb"; + sha256 = "QIY4qGm333H5MWhe3CIfEieqTEk8st5A7SJHkwGnnxw="; + }; + "aarch64-linux" = fetchurl { + url = "https://packages.blackfire.io/debian/pool/any/main/b/blackfire/blackfire_${version}_arm64.deb"; + sha256 = "eZbKoKYC2tt4Rxn5OJr7iA1aJlYFC0tpRmbLq7qSrIU="; + }; + "aarch64-darwin" = fetchurl { + url = "https://packages.blackfire.io/blackfire/${version}/blackfire-darwin_arm64.pkg.tar.gz"; + sha256 = "tn2vF3v7KfF7CfWqyydL5Iyh5tP9Tez87PJH+URgSIw="; + }; + "x86_64-darwin" = fetchurl { + url = "https://packages.blackfire.io/blackfire/${version}/blackfire-darwin_amd64.pkg.tar.gz"; + sha256 = "CRFlnqpX4j2CMGzS+UvXwNty2mHpONOjym6UJPE2Yg4="; + }; + }; + + updateScript = writeShellScript "update-blackfire" '' set -o errexit export PATH="${lib.makeBinPath [ curl jq common-updater-scripts ]}" NEW_VERSION=$(curl -s https://blackfire.io/api/v1/releases | jq .cli --raw-output) @@ -88,9 +87,9 @@ stdenv.mkDerivation rec { exit 0 fi - for platform in ${lib.concatStringsSep " " meta.platforms}; do - update-source-version "blackfire" "0" "${lib.fakeSha256}" "--system=$platform" - update-source-version "blackfire" "$NEW_VERSION" "--system=$platform" --ignore-same-hash + for platform in ${lib.escapeShellArgs meta.platforms}; do + update-source-version "blackfire" "0" "${lib.fakeSha256}" --source-key="sources.$platform" + update-source-version "blackfire" "$NEW_VERSION" --source-key="sources.$platform" done ''; }; @@ -101,6 +100,6 @@ stdenv.mkDerivation rec { sourceProvenance = with sourceTypes; [ binaryNativeCode ]; license = licenses.unfree; maintainers = with maintainers; [ jtojnar shyim ]; - platforms = [ "x86_64-linux" "aarch64-linux" "i686-linux" "x86_64-darwin" "aarch64-darwin" ]; + platforms = [ "x86_64-linux" "aarch64-linux" "i686-linux" "x86_64-darwin" ]; }; }