fix: overridable per-user BLHeliSuite32 state dir

Separate BLHeliSuite32 state workaround from dist and add per-user state
dir.
This commit is contained in:
514fpv 2024-01-27 22:47:32 +08:00
parent 978bc19f68
commit 7ec67295f4
Signed by: koishi
SSH key fingerprint: SHA256:axz0uIzzY+5W19i7QOUuiw5LSqhKfCBKPf3L4xFRxLw
2 changed files with 19 additions and 11 deletions

View file

@ -19,7 +19,7 @@ in {
betaflight-configurator betaflight-configurator
inav-configurator inav-configurator
inav-blackbox-tools inav-blackbox-tools
blhelisuite32 (blhelisuite32.override { workdir = "${config.home.homeDirectory}/.blhelisuite32"; })
expresslrs-configurator expresslrs-configurator
]; ];

View file

@ -4,23 +4,17 @@
, fetchzip , fetchzip
, stdenvNoCC , stdenvNoCC
, makeDesktopItem , makeDesktopItem
, buildFHSUserEnv }: let , buildFHSUserEnv
, workdir ? "/tmp/blhelisuite32" }: let
name = "BLHeliSuite32"; name = "BLHeliSuite32";
pname = "blhelisuite32"; pname = "blhelisuite32";
workdir = "/tmp/${pname}";
version = "32.10"; version = "32.10";
suffix = "1044"; suffix = "1044";
dist = fetchzip { dist = fetchzip {
name = "${pname}-dist"; name = "${pname}-dist";
url = "https://github.com/bitdump/BLHeli/releases/download/Rev${version}/${name}xLinux64_${suffix}.zip"; url = "https://github.com/bitdump/BLHeli/releases/download/Rev${version}/${name}xLinux64_${suffix}.zip";
hash = "sha256-lempCne+Sf/38WHfJHRdL6MspSpi+UhpZNFcsPgI0jw="; hash = "sha256-y4S824s9Ipxb1M1IeD6Lo6k7hmm8CEmPflvhaqZz+84=";
postFetch = ''
# BLHeliSuite32 tries to write next to its binary
ln -s ${workdir}/settings $out/Settings
ln -s ${workdir}/music $out/Music
'';
}; };
desktopItem = makeDesktopItem { desktopItem = makeDesktopItem {
@ -56,6 +50,20 @@
cp -r ${name}*.png "$out" cp -r ${name}*.png "$out"
''; '';
}; };
linked = stdenvNoCC.mkDerivation {
inherit pname version;
phases = [ "unpackPhase" "patchPhase" "installPhase" ];
src = dist;
installPhase = ''
cp -r . "$out"
# BLHeliSuite32 tries to write next to its binary
ln -s ${workdir}/settings $out/Settings
ln -s ${workdir}/music $out/Music
'';
};
in buildFHSUserEnv { in buildFHSUserEnv {
inherit pname; inherit pname;
targetPkgs = pkgs: (with pkgs; [ targetPkgs = pkgs: (with pkgs; [
@ -80,5 +88,5 @@ in buildFHSUserEnv {
runScript = "sh -c '" + runScript = "sh -c '" +
"mkdir -p ${workdir}/settings && " + "mkdir -p ${workdir}/settings && " +
"mkdir -p ${workdir}/music && " + "mkdir -p ${workdir}/music && " +
"exec ${dist}/${name}xl'"; "exec ${linked}/${name}xl'";
} }