Packaging a self-updating binary

Hi!
I am trying to package HelixPlan (free download at Helix Plan Client | Perforce ) for NixOS. I first tried to copy the p4v package available in nixpkgs, adding the couple extra dependencies that HelixPlan needs. This allowed it to run, however as soon as I try to connect to a server, it tells me the version is wrong and downloads the correct one to ~/.HelixPlan/Versions/some-unique-hash/HelixPlan, which I believe it then tries and fails to run (as it is missing the patches made to the original ELF).
How should I instead attempt to package this? I tried an FHSenv but did not have any luck, though it is likely I just set it up wrong.

Here is my working package for running the client (which breaks when it tries to auto-update):
default.nix:

{
  fetchzip,
  lib,
  qt6Packages,
}: let
  mkDerivation = qt6Packages.callPackage ./linux.nix {};
in
  mkDerivation rec {
    pname = "helixplan";
    version = "2024.1016";

    src = fetchzip {
      # NOTE: remove the 2.6 for newer versions
      url = "https://cache.hansoft.com/Helix%20Plan%20${version}%20Linux2.6%20x64.zip";
      sha256 = "sha256-jKRcFlu3rKUgImgNRNsBOdjMaRZsaSGvgWIKqV5KOv8=";
    };

    meta = {
      description = "Perforce Helix Plan";
      homepage = "https://www.perforce.com";
      sourceProvenance = with lib.sourceTypes; [binaryNativeCode];
      license = lib.licenses.unfreeRedistributable;
    };
  }

linux.nix:

{
  stdenv,
  autoPatchelfHook,
  cups,
  dbus,
  fontconfig,
  gccForLibs,
  libX11,
  libXcomposite,
  libXcursor,
  libXdamage,
  libXext,
  libXi,
  libXrandr,
  libXrender,
  libXtst,
  libinput,
  libxcb,
  libxkbcommon,
  nss,
  qtbase,
  qtmultimedia,
  qtsvg,
  qttools,
  qtwebengine,
  qtwebview,
  xcbutilimage,
  xcbutilkeysyms,
  xcbutilrenderutil,
  xcbutilwm,
}: {
  pname,
  version,
  src,
  meta,
}: let
  unwrapped = stdenv.mkDerivation {
    pname = "${pname}-unwrapped";
    inherit version src meta;

    nativeBuildInputs = [autoPatchelfHook];
    buildInputs = [
      cups
      dbus
      fontconfig
      gccForLibs
      libX11
      libXcomposite
      libXcursor
      libXdamage
      libXext
      libXi
      libXrandr
      libXrender
      libXtst
      libinput
      libxcb
      libxkbcommon
      nss
      qtbase
      qtmultimedia
      qtsvg
      qttools
      qtwebengine
      qtwebview
      xcbutilimage
      xcbutilkeysyms
      xcbutilrenderutil
      xcbutilwm
    ];

    dontBuild = true;

    # Don't wrap the Qt apps; upstream has its own wrapper scripts.
    dontWrapQtApps = true;

    installPhase = ''
      mkdir -p $out/bin
      cp -r HelixPlan $out/bin
    '';

    preFixup = ''
      patchelf --clear-symbol-version close $out/bin/HelixPlan
    '';
  };
in
  stdenv.mkDerivation {
    inherit pname version;

    # Build a "clean" version of the package so that we don't add extra ".bin" or
    # configuration files to users' PATHs. We can't easily put the unwrapped
    # package files in libexec (where they belong, probably) because the upstream
    # wrapper scripts have the bin directory hardcoded.
    buildCommand = ''
      mkdir -p $out/bin
      ln -s ${unwrapped}/bin/HelixPlan $out/bin
    '';
    preferLocalBuild = true;

    inherit (unwrapped) meta passthru;
  }

An update:
Currently the only way I have found to run this software is via Distrobox and just using Arch. The ideal way would be to package this and allow it to self-download its desired binary (which is a required functionality). I guess it would have to run in a container like FHSenv. How should I approach this?