From 7ec67295f4a42a100bfef221976936b0f477ff28 Mon Sep 17 00:00:00 2001 From: 514fpv Date: Sat, 27 Jan 2024 22:47:32 +0800 Subject: [PATCH] fix: overridable per-user BLHeliSuite32 state dir Separate BLHeliSuite32 state workaround from dist and add per-user state dir. --- home/util/home.nix | 2 +- package/blhelisuite32/default.nix | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/home/util/home.nix b/home/util/home.nix index 49a9266b..3f43c287 100644 --- a/home/util/home.nix +++ b/home/util/home.nix @@ -19,7 +19,7 @@ in { betaflight-configurator inav-configurator inav-blackbox-tools - blhelisuite32 + (blhelisuite32.override { workdir = "${config.home.homeDirectory}/.blhelisuite32"; }) expresslrs-configurator ]; diff --git a/package/blhelisuite32/default.nix b/package/blhelisuite32/default.nix index 18656550..d07b318b 100644 --- a/package/blhelisuite32/default.nix +++ b/package/blhelisuite32/default.nix @@ -4,23 +4,17 @@ , fetchzip , stdenvNoCC , makeDesktopItem -, buildFHSUserEnv }: let +, buildFHSUserEnv +, workdir ? "/tmp/blhelisuite32" }: 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_${suffix}.zip"; - hash = "sha256-lempCne+Sf/38WHfJHRdL6MspSpi+UhpZNFcsPgI0jw="; - - postFetch = '' - # BLHeliSuite32 tries to write next to its binary - ln -s ${workdir}/settings $out/Settings - ln -s ${workdir}/music $out/Music - ''; + hash = "sha256-y4S824s9Ipxb1M1IeD6Lo6k7hmm8CEmPflvhaqZz+84="; }; desktopItem = makeDesktopItem { @@ -56,6 +50,20 @@ 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 { inherit pname; targetPkgs = pkgs: (with pkgs; [ @@ -80,5 +88,5 @@ in buildFHSUserEnv { runScript = "sh -c '" + "mkdir -p ${workdir}/settings && " + "mkdir -p ${workdir}/music && " + - "exec ${dist}/${name}xl'"; + "exec ${linked}/${name}xl'"; }