Update insync # auto-patchelf / rm lib issues - e.g. libGLX.so.0

{ stdenv
, lib
, fetchurl
, makeWrapper
, dpkg
, glibc
, glib
, libxcb
, libGL
, nss
, libthai
, wayland
, alsa-lib
, qtvirtualkeyboard
, qtwebchannel
, qtwebsockets
, qtlocation
, qtwebengine
, autoPatchelfHook
, wrapQtAppsHook
}:

stdenv.mkDerivation rec {
  pname = "insync";
  version = "3.7.12.50395";
  ubuntuVersionName="jammy";
  webArchiveUrl="https://web.archive.org/web/20221002065012/";

  src = fetchurl {
    url = "${webArchiveUrl}https://cdn.insynchq.com/builds/linux/${pname}_${version}-${ubuntuVersionName}_amd64.deb";
    sha256 = "sha256-i5XmKgwpsrwt4N3ChbgfWqrrKTsfBXDBjOZzebwKjZg=";
  };

  postPatch = ''
    substituteInPlace usr/bin/insync --replace /usr/lib/insync $out/usr/lib/insync
  '';

  buildInputs = [
    alsa-lib
    libGL
    libthai
    libxcb
    nss
    qtlocation
    qtvirtualkeyboard
    qtwebchannel
    qtwebengine
    qtwebsockets
    wayland
  ];

  nativeBuildInputs = [ autoPatchelfHook dpkg makeWrapper wrapQtAppsHook ];

  unpackPhase = ''
    dpkg-deb --fsys-tarfile $src | tar -x --no-same-permissions --no-same-owner
  '';

  installPhase = ''
    mkdir -p $out/bin $out/lib $out/share
    cp -R usr/* $out/
    #rm $out/lib/insync/libGLX.so.0
    #rm $out/lib/insync/libQt5*
    sed -i 's|/usr/lib/insync|/lib/insync|' "$out/bin/insync"
    wrapQtApp "$out/lib/insync/insync"
  '';

  dontConfigure = true;
  dontBuild = true;

  meta = with lib; {
    platforms = ["x86_64-linux"];
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
    license = licenses.unfree;
    maintainers = with maintainers; [ benley ];
    homepage = "https://www.insynchq.com";
    description = "Google Drive sync and backup with multiple account support";
    longDescription = ''
     Insync is a commercial application that syncs your Drive files to your
     computer.  It has more advanced features than Google's official client
     such as multiple account support, Google Doc conversion, symlink support,
     and built in sharing.

     There is a 15-day free trial, and it is a paid application after that.
    '';
  };
}

fails with

@nix { "action": "setPhase", "phase": "installPhase" }
installing
rm: cannot remove '/nix/store/cq19c13855il1pdqnz6sn21rkddb3h2w-insync-3.7.12.50395/lib/insync/libGLX.so.0': No such file or directory

and after commenting out the first rm line

setting RPATH to: /nix/store/634m9rf1xclq7vdcpgqfqaiahgwdjkfy-qtbase-5.15.5/lib:/nix/store/xvfl3d8irv3hj1admxnadr08f88v4w0w-libglvnd-1.5.0/lib:/nix/store/sjlkpdxa5j9gvx3alnmnpfbnhr8zdvhq-insync-3.7.12.50395/lib/insync
auto-patchelf: 1 dependencies could not be satisfied
error: auto-patchelf could not satisfy dependency libQt5SerialPort.so.5 wanted by /nix/store/sjlkpdxa5j9gvx3alnmnpfbnhr8zdvhq-insync-3.7.12.50395/lib/insync/PySide2/plugins/position/libqtposition_serialnmea.so
auto-patchelf failed to find all the required dependencies.
Add the missing dependencies to --libs or use `--ignore-missing="foo.so.1 bar.so etc.so"`.

builds (but looks not to work) when commenting out the rm lines in installPhase


What is a proper way of building/testing the changes

  • especially the install phase (and here auto-patchelf)

Have you… Actually tried adding that dependency? It’s qtserialport in nixpkgs land.

Maybe add an ls -l lib before the rm statements so you can see if the lib directory is even present.