Qt tray icon for insync

#1

I am packaging the insync application for nix. Insync is a commercial application that syncs gdrive and more. The current derivation in the nixstore is a command line only tool without the gui.

It was a pain, but I got the app up and running. The only thing missing is the system tray icon from which the gui can be opened. Here is the derivation:

{ stdenv
, lib
, fetchurl
, makeWrapper 
, dpkg
, glibc
, glib
, libglvnd
, libXcomposite
, libXcursor
, libXi
, libXrandr
, libXtst 
, libxcb
, nss
, qt5
, xdg_utils
, zlib
}:

let rpath = lib.makeLibraryPath [
    glibc
    glib
    libXcomposite
    libXi
    libXrandr
    libXtst
    libglvnd
    #nss
    xdg_utils
    zlib
    qt5.qtbase 
    qt5.qtlocation
    qt5.qtdeclarative  
    qt5.qtwebengine 
    qt5.qtserialport
    qt5.qtwebchannel
];

in stdenv.mkDerivation rec {
  name = "insync";
  version = "1.5.5.37367";
  src =
    if stdenv.hostPlatform.system == "x86_64-linux" then
      fetchurl {
        url = "http://s.insynchq.com/builds/${name}_${version}-artful_amd64.deb";
        sha256 = "1pd2ad3ky0xapcm1ijq1vhv36am62bfb9mrrvbny9x7sanf7ji3w";
      }
    else
      throw "${name} is not supported on ${stdenv.hostPlatform.system}";


  buildInputs = [ dpkg makeWrapper ];

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

  installPhase = ''
    mkdir -p $out/usr
    cp -R usr/ $out/
    ln -s $out/usr/share $out/share
    chmod a-x $out/usr/lib/insync/library.zip # do not match in the next loop

    for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do
      patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true
      patchelf --set-rpath ${rpath}:$out/usr/lib/insync/ $file || true
    done

    makeWrapper $out/usr/lib/insync/insync $out/bin/insync --set LC_TIME C
  '';

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

  dontConfigure = true;
  dontBuild = true;

  meta = with stdenv.lib; {
    platforms = ["x86_64-linux"];
    license = stdenv.lib.licenses.unfree;
    maintainers = with maintainers; [  ];
    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.
    '';
  };
}

nix-env -f . -iA insync correctly installs the binary. I you run insync start --no-daemon you see the debug output:

which: no kreadconfig in (/nix/store/synwhm4a5hd8xwna5fc5hfldksaz3942-insync/usr/lib/insync:/home/mschneider/bin:/run/wrappers/bin:/home/mschneider/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/etc/profiles/per-user/mschneider/bin)
QSystemTrayIcon::setVisible: No Icon set
INFO 2019-03-20 18:24:35,766 [main__insync:main:105] insync version: 1.5.5.37367
INFO 2019-03-20 18:24:35,767 [main__insync:main:106] client created <ideskmain.client.Client object at 0x7f21f5157390>
INFO 2019-03-20 18:24:35,768 [unix_socket_server_portable:start:49] unix socket server thread start
INFO 2019-03-20 18:24:35,768 [main__insync:main:114] starting client
INFO 2019-03-20 18:24:35,771 [fswatch:_start:532] LinuxFSWatcher._start
INFO 2019-03-20 18:24:35,771 [fswatch:_pull_loop:267] Inotify loop enter
INFO 2019-03-20 18:24:35,848 [gdsyncer:sync_account:153] Syncing XXX
js: Deprecation warning: use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info.
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
INFO 2019-03-20 18:24:36,148 [fswatch:watch:550] watch origin: XXX
Exception in thread GeventITCSpawner:
Traceback (most recent call last):
File “threading.py”, line 801, in __bootstrap_inner
File “threading.py”, line 754, in run
File “isyncd/linux/platform_impl.py”, line 138, in set_insync_folder_icon
File “isyncd/linux/platform_impl.py”, line 44, in set_custom_icon
File “isyncd/linux/platform_impl.py”, line 72, in clear_custom_icon
AttributeError: ‘module’ object has no attribute ‘file_new_for_path’

Running insync show in a second terminal opens the gui, which would normally open if you click on the system tray icon.
The second (minor) problem is, that the app in the dock has no icon.

Is there anyone who can help me with this?

#2

Do you have a theme installed?

#3

No. I used a plain configuration.nix with gnome3 enabled.

#4

Gnome3.enable seems to install a icon theme, but I’m not sure if it is automatically also used for QT apps.

Your app doesn’t seem to be able to find one. (I.e. the line with ‘no icon set’)

programs.qt5ct.enable and the qt5ct package seem to be an option for setting themes when you don’t use KDE, but I haven’t tried it.

I mainly had similar issues when running GTK Apps on machines without Gnome installed. There installing a theme helped, as that is automatically loaded without explicit configuration.

Maybe there are also theme or icon packages explicitly for KDE but I’m on mobile and can’t search for aliases.