From 84e78712006f8479deaf384540db69907514393b Mon Sep 17 00:00:00 2001 From: 514fpv Date: Mon, 15 Jan 2024 18:57:35 +0800 Subject: [PATCH] fix: add BLHeliSuite32 desktop item and icon Extracted from the MacOS app distribution. --- home/util/package/blheli32.nix | 54 +++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/home/util/package/blheli32.nix b/home/util/package/blheli32.nix index e93274ab..18656550 100644 --- a/home/util/package/blheli32.nix +++ b/home/util/package/blheli32.nix @@ -1,14 +1,19 @@ { lib +, libicns +, p7zip , fetchzip +, stdenvNoCC +, makeDesktopItem , buildFHSUserEnv }: let name = "BLHeliSuite32"; pname = "blhelisuite32"; workdir = "/tmp/${pname}"; version = "32.10"; + suffix = "1044"; dist = fetchzip { name = "${pname}-dist"; - url = "https://github.com/bitdump/BLHeli/releases/download/Rev${version}/${name}xLinux64_1044.zip"; + url = "https://github.com/bitdump/BLHeli/releases/download/Rev${version}/${name}xLinux64_${suffix}.zip"; hash = "sha256-lempCne+Sf/38WHfJHRdL6MspSpi+UhpZNFcsPgI0jw="; postFetch = '' @@ -17,6 +22,40 @@ ln -s ${workdir}/music $out/Music ''; }; + + desktopItem = makeDesktopItem { + name = pname; + exec = pname; + icon = pname; + comment = "This Application may flash and configure BLHeli_32 based ESCs"; + desktopName = name; + genericName = "BLHeli for brushless ESC firmware"; + }; + + icons = stdenvNoCC.mkDerivation { + pname = "${pname}-icons"; + inherit version; + src = fetchzip { + name = "${pname}-macos"; + url = "https://github.com/bitdump/BLHeli/releases/download/Rev${version}/${name}xm_MacOS64_${suffix}.zip"; + hash = "sha256-StRnrVI8p51vNsTMO1LtaZvENbG7XZ1V/mKHe4pO7kU="; + }; + + nativeBuildInputs = [ libicns p7zip ]; + + configurePhase = '' + 7z x *.dmg + ''; + + buildPhase = '' + icns2png -x ${name}xm_MacOS64_${suffix}/${name}xm.app/Contents/Resources/${name}xm.icns + ''; + + installPhase = '' + mkdir -p "$out" + cp -r ${name}*.png "$out" + ''; + }; in buildFHSUserEnv { inherit pname; targetPkgs = pkgs: (with pkgs; [ @@ -24,6 +63,19 @@ in buildFHSUserEnv { libgcc gtk3 zlib systemdLibs ]); + extraInstallCommands = let + mkIconScale = scale: + "install -m 444 -D ${icons}/${name}xm_${scale}x${scale}x32.png $out/share/icons/hicolor/${scale}x${scale}/apps/${pname}.png"; + in '' + ${mkIconScale "16"} + ${mkIconScale "32"} + ${mkIconScale "64"} + ${mkIconScale "128"} + ${mkIconScale "256"} + ${mkIconScale "512"} + ${mkIconScale "1024"} + cp -r ${desktopItem}/share/applications $out/share/ + ''; runScript = "sh -c '" + "mkdir -p ${workdir}/settings && " +