Issue running / packaging an AppImage

Hello,

I’m trying to run (and package for nixpkgs) the kDrive AppImage but I’m running into issues.

I ran the AppImage with appimage-run but the app just fails with a non-helpful error message:

kDrive server initialization error: Unable to open parameters database.

So, I went straight ahead to packaging it instead, without further success (and the same error).

I looked at the AppImage content which is extracted in a .cache directory in my home after trying to run it with appimage-run. Did some ldd on the binaries to get the list of dependencies and came up with the following package « derivation » (I don’t think it’s a derivation per se, but whatever):

{ appimageTools, fetchurl, lib, stdenv }:

let
  pname = "kDrive";
  version = "3.5.5.20231213";

  srcs = {
    x86_64-linux = fetchurl {
      url = "https://download.storage.infomaniak.com/drive/desktopclient/kDrive-${version}-amd64.AppImage";
      sha256 = "sha256-DWnh2f5ZKq+znmgpxn84LG9sZl3FdDOxgJq+/06S4Xo=";
    };

    aarch64-linux = fetchurl {
      url = "https://download.storage.infomaniak.com/drive/desktopclient/kDrive-${version}-arm64.AppImage";
      #sha256 = ""; # TODO
    };

    x86_64-darwin = fetchurl {
      url = "https://download.storage.infomaniak.com/drive/desktopclient/kDrive-${version}.pkg";
      #sha256 = ""; # TODO
    };
  };

  src = srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");

  meta = with lib; {
    description = "kDrive desktop synchronization client.";
    homepage = "https://www.infomaniak.com/kdrive";
    license = licenses.unlicense;
    platforms = builtins.attrNames srcs;
    maintainers = [ maintainers.nicolas-goudry ];
    mainProgram = "kDrive";
  };

  contents = appimageTools.extractType2 { inherit pname version src; };

  linux = appimageTools.wrapType2 {
    inherit pname version src meta;

    #multiArch = false;

    extraPkgs = pkgs: (appimageTools.defaultFhsEnvArgs.multiPkgs pkgs) ++ (with pkgs; [
      alsa-lib
      brotli
      curl
      cyrus_sasl
      dbus
      e2fsprogs
      expat
      gmp
      freetype
      fontconfig
      gcc-unwrapped
      glib
      glibc
      gnutls
      heimdal
      icu66
      keyutils
      libffi
      libgcrypt
      libgpg-error
      libidn2
      libjpeg
      libkrb5
      libpng
      libpsl
      libsecret
      libselinux
      libssh
      libtasn1
      libunistring
      libxcrypt-legacy
      libxkbcommon
      libxml2
      log4cplus
      lz4
      nettle
      nghttp2
      nspr
      nss
      openldap
      openssl
      p11-kit
      pcre2
      poco
      qt6.full
      rtmpdump
      sentry-native
      sqlite
      systemd
      util-linux
      xorg.libxcb
      xorg.libxkbfile
      xorg.libxshmfence
      xorg.libX11
      xorg.libXcomposite
      xorg.libXdamage
      xorg.libXext
      xorg.libXfixes
      xorg.libXrandr
      xorg.libXrender
      xorg.libXtst
      xxHash
      xz
      zlib
    ]);

    extraInstallCommands = ''
      mv $out/bin/${pname}-${version} $out/bin/${pname}
      install -m 444 -D ${contents}/kDrive_client.desktop -t $out/share/applications
      cp -r ${contents}/usr/share/icons $out/share
    '';
  };

  darwin = stdenv.mkDerivation {
    inherit pname version src meta;

    dontBuild = true;

    unpackPhase = ''
      7z x $src
      bsdtar -xf Payload~
    '';

    installPhase = ''
      runHook preInstall

      mkdir -p $out/bin
      install -Dm755 usr/local/bin/kdrive -t $out/bin

      runHook postInstall
    '';
  };
in
if stdenv.isDarwin
then darwin
else linux

(don’t mind the darwin part, it’s not relevant here and probably not working as-is, but I plan to add it later)

I tried to use strace to find out what’s going on but I can’t find anything wrong (yet).

Does anybody have ideas, suggestions, pointers?

Thanks!

Did you ever figure this out? I’m trying to package kDrive as a Flatpak and I’m getting the same error,

Sadly no, I reached out to the support and they told me this (translated from french):

As of today, kDrive doesn’t support this operating system.

The problem seems to be that the application can’t access its parameters database. It should be located (or created by the app) here: /home/<user name>/.config/kDrive. Maybe this directory (.config) doesn’t exist on NixOS.

I looked into my .config and I can see the kDrive directory with its parameters database file in there. I tried to mess with the file permissions, without any success though.

I’m kind of glad to know that it doesn’t work for you either, but also sad at the same time. Let me know if you find anything, I’d be interested! In the meantime, I’m using the web UI, which is better than nothing.

FYI for situations like these strace will be helpful :wink:

EDIT: I just read you already tried it.
Can you post the strace output? It might be the process is forking so you need to use strace -f

1 Like

Output is about 30K lines… Here you go!

Ran it like this:

strace -f /nix/store/bpbnp35jf5pp43qhvwpgpyckxhl7jyy5-kDrive-3.5.7.20240124/bin/kDrive &> kdrive-strace.txt

I’m not very comfortable with strace yet, but searching for the database file name (.prms.db) in the output didn’t yield any results :frowning:

BTW, the Nix code is available here.

Based on that output. It definitely finds the params.db and even opens it. The program seems to close the db and starts giving up after this line

openat(AT_FDCWD, “/nix/store/csxi5kjm1wknx9yh58f50s898g5shz0b-kDrive-3.5.7.20240124-extracted/sync-exclude.lst”, O_RDONLY) = -1 ENOENT (No such file or directory)

1 Like

Oh right I wasn’t searching for the correct file name…

I’ll follow up with the support with those findings, hoping they can help further!

I noticed that there are a lot of errors (No such file or directory) related to fonts, is this « normal »?

Thanks for your help BTW !

That’s normal for any graphical X11/Wayland program startup. (It’s fontconfig crawling your fonts and configs)

1 Like

Some lines from my strace (with the Flatpak):

[pid  1158] newfstatat(AT_FDCWD, "/home/user/.config", {st_mode=S_IFDIR|0700, st_size=2182, ...}, 0) = 0
[pid  1158] newfstatat(AT_FDCWD, "/home/user/.config/kDrive", {st_mode=S_IFDIR|0755, st_size=254, ...}, 0) = 0
[pid  1158] newfstatat(AT_FDCWD, "/home/user/.config/kDrive", {st_mode=S_IFDIR|0755, st_size=254, ...}, AT_SYMLINK_NOFOLLOW) = 0
[pid  1158] newfstatat(AT_FDCWD, "/home/user/.config/kDrive/.parms.db", {st_mode=S_IFREG|0644, st_size=61440, ...}, AT_SYMLINK_NOFOLLOW) = 0
[pid  1158] newfstatat(AT_FDCWD, "/home/user/.config/kDrive/.parms.db", {st_mode=S_IFREG|0644, st_size=61440, ...}, AT_SYMLINK_NOFOLLOW) = 0
[pid  1158] newfstatat(AT_FDCWD, "/home/user/.var/app/com.infomaniak.kdrive/config/kDrive/kDrive.cfg", 0x7fffbc1f3da0, AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
[pid  1158] lseek(21, 0, SEEK_CUR)      = 240
[pid  1158] lseek(21, 0, SEEK_CUR)      = 240
[pid  1158] write(21, "2024-02-02 17:13:00:355 [I] (140"..., 123) = 123
[pid  1158] lseek(21, 0, SEEK_CUR)      = 363
[pid  1158] lseek(21, 0, SEEK_CUR)      = 363
[pid  1158] lseek(21, 0, SEEK_CUR)      = 363
[pid  1158] lseek(21, 0, SEEK_CUR)      = 363
[pid  1158] write(21, "2024-02-02 17:13:00:355 [I] (140"..., 158) = 158
[pid  1158] lseek(21, 0, SEEK_CUR)      = 521
[pid  1158] lseek(21, 0, SEEK_CUR)      = 521
[pid  1158] lstat("/home/user/.config/kDrive/.parms.db", {st_mode=S_IFREG|0644, st_size=61440, ...}) = 0
[pid  1158] getpid()                    = 3
[pid  1158] getpid()                    = 3
[pid  1158] openat(AT_FDCWD, "/home/user/.config/kDrive/.parms.db", O_RDWR|O_CREAT|O_NOFOLLOW|O_CLOEXEC, 0644) = 22
[pid  1158] fstat(22, {st_mode=S_IFREG|0644, st_size=61440, ...}) = 0
[pid  1158] fstat(22, {st_mode=S_IFREG|0644, st_size=61440, ...}) = 0
[pid  1158] stat("/home/user/.config/kDrive/.parms.db", {st_mode=S_IFREG|0644, st_size=61440, ...}) = 0
[pid  1158] pread64(22, "SQLite format 3\0\20\0\2\2\0@  \0\0\0\4\0\0\0\17"..., 100, 0) = 100
[pid  1158] fcntl(22, F_SETLK, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=1}) = 0
[pid  1158] fcntl(22, F_SETLK, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = 0
[pid  1158] fcntl(22, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=1}) = 0
[pid  1158] stat("/home/user/.config/kDrive/.parms.db-journal", 0x7fffbc1f2280) = -1 ENOENT (No such file or directory)
[pid  1158] stat("/home/user/.config/kDrive/.parms.db-wal", {st_mode=S_IFREG|0644, st_size=20632, ...}) = 0
[pid  1158] fstat(22, {st_mode=S_IFREG|0644, st_size=61440, ...}) = 0
[pid  1158] getpid()                    = 3
[pid  1158] stat("/home/user/.config/kDrive/.parms.db", {st_mode=S_IFREG|0644, st_size=61440, ...}) = 0
[pid  1158] openat(AT_FDCWD, "/home/user/.config/kDrive/.parms.db-wal", O_RDWR|O_CREAT|O_NOFOLLOW|O_CLOEXEC, 0644) = 23
[pid  1158] fstat(23, {st_mode=S_IFREG|0644, st_size=20632, ...}) = 0
[pid  1158] geteuid()                   = 1000
[pid  1158] fstat(22, {st_mode=S_IFREG|0644, st_size=61440, ...}) = 0
[pid  1158] openat(AT_FDCWD, "/home/user/.config/kDrive/.parms.db-shm", O_RDWR|O_CREAT|O_NOFOLLOW|O_CLOEXEC, 0644) = 24
[pid  1158] fstat(24, {st_mode=S_IFREG|0644, st_size=32768, ...}) = 0
[pid  1158] geteuid()                   = 1000
[pid  1158] fcntl(24, F_GETLK, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=128, l_len=1, l_pid=0}) = 0
[pid  1158] fcntl(24, F_SETLK, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=128, l_len=1}) = 0
[pid  1158] fstat(24, {st_mode=S_IFREG|0644, st_size=32768, ...}) = 0
[pid  1158] mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_SHARED, 24, 0) = 0x7ffa89a12000
[pid  1158] fcntl(24, F_SETLK, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=124, l_len=1}) = 0
[pid  1158] pread64(22, "SQLite format 3\0\20\0\2\2\0@  \0\0\0\4\0\0\0\17"..., 4096, 0) = 4096
[pid  1158] fcntl(24, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=124, l_len=1}) = 0
[pid  1158] fcntl(24, F_SETLK, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=124, l_len=1}) = 0
[pid  1158] pread64(22, "\0\0\0\0\0\0\0\2\0\0\0\r\0\0\0\16\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 57344) = 4096
[pid  1158] pread64(22, "\r\0\0\0\0\20\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 45056) = 4096
[pid  1158] pread64(23, "\r\0\0\0\1\17\340\0\17\340\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 12416) = 4096
[pid  1158] pread64(22, "\r\0\0\0\1\17\212\0\17\212\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 8192) = 4096
[pid  1158] pread64(22, "\n\0\0\0\1\r!\0\r!\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 12288) = 4096
[pid  1158] pread64(22, "\n\0\0\0\1\17\371\0\17\371\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 16384) = 4096
[pid  1158] pread64(22, "\n\0\0\0\1\17\370\0\17\370\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 20480) = 4096
[pid  1158] pread64(22, "\n\0\0\0\1\17\340\0\17\340\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 24576) = 4096
[pid  1158] pread64(23, "\n\0\0\0\1\17j\0\17j\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 16536) = 4096
[pid  1158] pread64(22, "\r\0\0\0\37\r\367\0\17\367\17\355\17\342\17\325\17\310\17\273\17\256\17\237\17\217\17y\17j\17Y"..., 4096, 32768) = 4096
[pid  1158] pread64(22, "\n\0\0\0\37\0166\0\0166\17A\16R\17\323\17 \17\310\17\275\17\242\17\216\17\201\17\351\16f"..., 4096, 36864) = 4096
[pid  1158] pread64(22, "\r\r\v\0\10\v\275\0\r\354\17\227\179\16\315\16E\r\207\f@\v\275\rh\v{\v{\2\26"..., 4096, 40960) = 4096
[pid  1158] fcntl(24, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=124, l_len=1}) = 0
[pid  1158] newfstatat(AT_FDCWD, "/home/user/.config/kDrive/.parms.db", {st_mode=S_IFREG|0644, st_size=61440, ...}, AT_SYMLINK_NOFOLLOW) = 0
...
[pid  1158] stat("/home/user/.config/kDrive/.parms.db", {st_mode=S_IFREG|0644, st_size=61440, ...}) = 0
[pid  1158] fcntl(22, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=1}) = 0
[pid  1158] fcntl(22, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EAGAIN (Resource temporarily unavailable)
[pid  1158] munmap(0x7ffa89a12000, 32768) = 0
[pid  1158] close(24)                   = 0
[pid  1158] close(23)                   = 0
[pid  1158] fcntl(22, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=2}) = 0
[pid  1158] fcntl(22, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
[pid  1158] fstat(22, {st_mode=S_IFREG|0644, st_size=61440, ...}) = 0
[pid  1158] stat("/home/user/.config/kDrive/.parms.db", {st_mode=S_IFREG|0644, st_size=61440, ...}) = 0
[pid  1158] close(22)                   = 0
[pid  1158] getpid()                    = 3
[pid  1158] getuid()                    = 1000
[pid  1158] readlink("/tmp", 0x7fffbc1f3a70, 1023) = -1 EINVAL (Invalid argument)
... (much later)
[pid  1158] write(2, "kDrive server initialization err"..., 36kDrive server initialization error: ) = 36
[pid  1158] write(2, "Unable to open parameters databa"..., 35Unable to open parameters database.) = 35

I have no idea what any of this means though

@Rigor1934 I think you need to link to the full log, just based on that I can’t see something that’s going wrong for sure

I uploaded it here as it’s too big for pastebin: Dropbox - kdrive-strace.txt - Simplify your life

I got a reply from Infomaniak support regarding the issue. They told me to look at the logs, which happen to be located in /tmp/kDrive-logdir.

Here are the logs I got:

2024-02-03 09:47:41:242 [I] (140627928124288) log.cpp:126 - Logger initialization done
2024-02-03 09:47:41:242 [I] (140627928124288) appserver.cpp:2848 - kDrive locale:[en_US] version:[3.5.7master (build 20240124)] os:[NixOS 24.05 (Uakari)]
2024-02-03 09:47:41:243 [I] (140627928124288) appserver.cpp:166 - New DB exists : /home/nicolas/.config/kDrive/.parms.db => 1
2024-02-03 09:47:41:243 [I] (140627928124288) appserver.cpp:167 - Old config exists : /home/nicolas/.config/kDrive/kDrive.cfg => 1
2024-02-03 09:47:41:244 [D] (140627928124288) db.cpp:562 - sqlite3 version=3.31.1
2024-02-03 09:47:41:244 [D] (140627928124288) db.cpp:578 - sqlite3 locking_mode=normal
2024-02-03 09:47:41:244 [D] (140627928124288) db.cpp:595 - sqlite3 journal_mode=wal
2024-02-03 09:47:41:244 [D] (140627928124288) db.cpp:615 - sqlite3 synchronous=NORMAL
2024-02-03 09:47:41:244 [D] (140627928124288) db.cpp:630 - sqlite3 case_sensitivity=ON
2024-02-03 09:47:41:244 [D] (140627928124288) db.cpp:645 - sqlite3 foreign_keys=ON
2024-02-03 09:47:41:244 [D] (140627928124288) db.cpp:348 - Check DB version
2024-02-03 09:47:41:244 [I] (140627928124288) db.cpp:441 - Prepare DB
2024-02-03 09:47:41:244 [W] (140627928124288) parmsdb.cpp:611 - Cannot open exclusion templates file /nix/store/csxi5kjm1wknx9yh58f50s898g5shz0b-kDrive-3.5.7.20240124-extracted/sync-exclude.lst
2024-02-03 09:47:41:244 [W] (140627928124288) parmsdb.cpp:1275 - Error in updateExclusionTemplates
2024-02-03 09:47:41:244 [W] (140627928124288) parmsdb.cpp:1224 - Error in initParameters
2024-02-03 09:47:41:244 [W] (140627928124288) db.cpp:443 - Error in Db::prepare
2024-02-03 09:47:41:244 [E] (140627928124288) db.cpp:649 - Database initialisation error
2024-02-03 09:47:41:244 [D] (140627928124288) db.cpp:241 - Closing DB /home/nicolas/.config/kDrive/.parms.db
2024-02-03 09:47:41:244 [D] (140627928124288) db.cpp:472 - No database Transaction to commit
2024-02-03 09:47:47:447 [I] (139966027303808) log.cpp:126 - Logger initialization done
2024-02-03 09:47:47:447 [I] (139966027303808) appserver.cpp:2848 - kDrive locale:[en_US] version:[3.5.7master (build 20240124)] os:[NixOS 24.05 (Uakari)]
2024-02-03 09:47:47:447 [I] (139966027303808) appserver.cpp:166 - New DB exists : /home/nicolas/.config/kDrive/.parms.db => 1
2024-02-03 09:47:47:447 [I] (139966027303808) appserver.cpp:167 - Old config exists : /home/nicolas/.config/kDrive/kDrive.cfg => 1
2024-02-03 09:47:47:447 [D] (139966027303808) db.cpp:562 - sqlite3 version=3.31.1
2024-02-03 09:47:47:447 [D] (139966027303808) db.cpp:578 - sqlite3 locking_mode=normal
2024-02-03 09:47:47:447 [D] (139966027303808) db.cpp:595 - sqlite3 journal_mode=wal
2024-02-03 09:47:47:447 [D] (139966027303808) db.cpp:615 - sqlite3 synchronous=NORMAL
2024-02-03 09:47:47:447 [D] (139966027303808) db.cpp:630 - sqlite3 case_sensitivity=ON
2024-02-03 09:47:47:447 [D] (139966027303808) db.cpp:645 - sqlite3 foreign_keys=ON
2024-02-03 09:47:47:447 [D] (139966027303808) db.cpp:348 - Check DB version
2024-02-03 09:47:47:447 [I] (139966027303808) db.cpp:441 - Prepare DB
2024-02-03 09:47:47:448 [W] (139966027303808) parmsdb.cpp:611 - Cannot open exclusion templates file /nix/store/csxi5kjm1wknx9yh58f50s898g5shz0b-kDrive-3.5.7.20240124-extracted/sync-exclude.lst
2024-02-03 09:47:47:448 [W] (139966027303808) parmsdb.cpp:1275 - Error in updateExclusionTemplates
2024-02-03 09:47:47:448 [W] (139966027303808) parmsdb.cpp:1224 - Error in initParameters
2024-02-03 09:47:47:448 [W] (139966027303808) db.cpp:443 - Error in Db::prepare
2024-02-03 09:47:47:448 [E] (139966027303808) db.cpp:649 - Database initialisation error
2024-02-03 09:47:47:448 [D] (139966027303808) db.cpp:241 - Closing DB /home/nicolas/.config/kDrive/.parms.db
2024-02-03 09:47:47:448 [D] (139966027303808) db.cpp:472 - No database Transaction to commit

It seems that the application is expecting a file sync-exclude.lst to be located in the extracted appimage directory. However this file is not in the directory:

/nix/store/csxi5kjm1wknx9yh58f50s898g5shz0b-kDrive-3.5.7.20240124-extracted
├── AppRun
├── apprun-hooks
├── AppRun.wrapped -> usr/bin/kDrive
├── kDrive_client.desktop -> usr/share/applications/kDrive_client.desktop
├── kDrive_desktop_sync_client-x86_64.AppImage
├── kdrive-win.png -> usr/share/icons/hicolor/1024x1024/apps/kdrive-win.png
└── usr

I’ll take a more thorough look at this tomorrow, but I believe I should find a way to maybe create this file from a derivation hook or something. If anyone here has an idea of how to do that, I’ll gladly take it!

1 Like

I can’t find a way to create this file as the extracted appimage content directory is read-only…

I found that the file exists in the extracted directory, but not at its root:

$ find /nix/store/csxi5kjm1wknx9yh58f50s898g5shz0b-kDrive-3.5.7.20240124-extracted/ -name sync-exclude.lst
/nix/store/csxi5kjm1wknx9yh58f50s898g5shz0b-kDrive-3.5.7.20240124-extracted/usr/bin/sync-exclude.lst

I tried to install it but I get the same Permission denied error:

extraInstallCommands = ''
  mv $out/bin/${pname}-${version} $out/bin/${pname}
  install -m 444 -D ${contents}/kDrive_client.desktop -t $out/share/applications
  install -m 444 -D ${contents}/usr/bin/sync-exclude.lst -t ${contents}
  cp -r ${contents}/usr/share/icons $out/share
'';

I read a bit about appimages, and afaict they are just programs packaged with all their dependencies. Therefore I wondered if I couldn’t extract the AppImage and then write a « classic » derivation. I tried that (see the derivation here), but I have an issue with a dependency:

kDrive: error while loading shared libraries: liblog4cplusU.so.9: cannot open shared object file: No such file or directory

Running

nix shell 'nixpkgs#nix-index' -c nix-locate liblog4cplusU.so.9

doesn’t yield any results. However, running

nix shell 'nixpkgs#nix-index' -c nix-locate liblog4cplusU.so

gives the following:

log4cplus.out    0 s /nix/store/0iwi1blhvpahw84dl06kgqbz7v55ga8k-log4cplus-2.1.0/lib/liblog4cplusU.so

I’m a bit lost as to what I should do now… And since I’m not even sure that using mkDerivation rather than using wrapType2 will work in the end, I’m wondering if I should continue in this direction or not.

Anyway, I sent the logs to Infomaniak support but I doubt that they could help me further since they made it clear that NixOS is not a supported OS.

For putting the file in extracted app image and re-bundling it, should be possible. If you get permissions errors, it might be that you just have to chmod and chown the directory accordingly (or use fakeroot).

For making derivation from the extracted appimage, you have to bundle the libs that are not included in nixpkgs. Note that this makes the kdrive only work in certain architectures. That particular dependency doesn’t seem to be fully custom but is this: GitHub - log4cplus/log4cplus: log4cplus is a simple to use C++ logging API providing thread-safe, flexible, and arbitrarily granular control over log management and configuration. It is modelled after the Java log4j API. so it might be possible to build that as derivation as well. But C++ libraries are really finicky and may have unstable ABI depending on which compiler, version and settings were used.

Anyhow, to bundle, you install these libs to $out/lib/ and then use makeWrapper to setup LD_LIBRARY_PATH so the binary can load them.

By the way, I think kdrive tries to read the sync-exclude.lst relative to its binary location. So because you have:

 AppRun.wrapped -> usr/bin/kDrive

This symlink, it fails because the symlink makes it try to read from the AppImage root and not usr/bin where it would if the binary was executed directly. So maybe try replacing AppRun.wrapped with shell script that calls usr/bin/kDrive (Not sure if it has to cd there first)

1 Like

You have the same issue as @nicolas-goudry regarding sync-exclude.lst

First of all, huge thanks for your help on this matter, it’s much appreciated.

You’re absolutely right about the sync-exclude.lst file wrongly read relatively from the symlink. I do believe this is the exact root cause of the error.

Therefore, I took some time to find a way to force change the directory before launching the application, but since the appimage extracted content directory is read-only, I didn’t find a way to do this (yet). My way was to rewrite the AppRun script from this:

#! /usr/bin/env bash

# autogenerated by linuxdeploy

# make sure errors in sourced scripts will cause this script to stop
set -e

this_dir="$(readlink -f "$(dirname "$0")")"

source "$this_dir"/apprun-hooks/"linuxdeploy-plugin-qt-hook.sh"

exec "$this_dir"/AppRun.wrapped "$@"

to this

#! /usr/bin/env bash

# autogenerated by linuxdeploy

# make sure errors in sourced scripts will cause this script to stop
set -e

this_dir="$(readlink -f "$(dirname "$0")")"

source "$this_dir"/apprun-hooks/"linuxdeploy-plugin-qt-hook.sh"

bin_dir="$(dirname "$(readlink -f "$this_dir"/AppRun.wrapped)")"
bin="$(basename "$(readlink -f "$this_dir"/AppRun.wrapped)")"

cd "$bin_dir"
exec "$bin" "$@"

But as I said, it’s read-only, so I couldn’t make it work.

Now, while reading your message again, I realize that what you’re suggesting is to first extract the appimage (I guess somewhere else than in the nix store), tamper with the AppRun script and then repackage or move it in the nix store?

Since I didn’t understand what you were saying at first, I spent some time trying to adapt my derivation from the appimage content, and I went further down the road thanks to your (very good) pointers. I’m using patchelf to set the rpath to the original lib subdirectory of the appimage (you can see the changes I made here).

I don’t have the error about sync-exclude.lst anymore, but now I do have a Qt-related error:

kDrive server starting
qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in ""
qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: minimal, minimalegl, vkkhrdisplay, offscreen, eglfs, xcb, linuxfb, vnc.

[1]    821897 IOT instruction (core dumped)  kDrive

As you can see from the derivation, I tried to set the QT_PLUGIN_PATH to the plugins directory of the extracted content:

wrapProgram $out/bin/kDrive --set QT_PLUGIN_PATH $out/plugins

But, sadly, it doesn’t work.

I strongly believe that this is not the right direction and I should stick to using the AppImage wrapper, but I looked at the nix code involved as well as the bash helper script and I don’t see anything in there allowing me to edit the AppRun script from the extracted content.

I had the same error with my Flatpak (in fact I got that error first, before the database error).

I managed to get rid of it by forcing kDrive to run on X11:

finish-args:
  - --socket=x11
  - --socket=fallback-x11
  - --env=XDG_SESSION_TYPE=x11 # otherwise get errors relating to qt.qpa.plugin and qt.qpa.xcb
  - --env=QT_QPA_PLATFORM=xcb # otherwise get errors relating to qt.qpa.plugin and qt.qpa.xcb
  - --unset-env=WAYLAND_DISPLAY # otherwise get errors relating to qt.qpa.plugin and qt.qpa.xcb
  - --unset-env=SESSION_MANAGER # otherwise get "Qt Session management error: Could not open network socket"

This is most likely that kDrive tries to load those Xorg libs from /usr/lib but in nix that won’t work. You need to add those libs to the libPath in your nix derivation. Btw, doing strings binary | grep '.*[.]so[.0-9]*$' is good to find any libs the binary might dlopen. It could also be that the Qt plugins are linked against said libs, but the solution is still the same:

I don’t think modifying the binary’s RPATH will work for dlopen’d libs, so you instead have to use makeWrapper / wrapProgram and set the LD_LIBRARY_PATH

Also, I thought you were the one building the AppImage, but I realized you are extracting it now, after reading your nix derivation, sorry for the confusion.

Btw, what you are doing right now is certainly the right direction and makes more sense than trying to run the AppImage directly, extracting it and repackaging it using the mkDerivation’s phases is the correct way if you want to package it for nixpkgs.

EDIT:
I see you are trying to point the binary to use nixpkgs qt6.full, but if it’s actually using that then things most likely should work out of box and should not need QT_PLUGIN_PATH.

I can advice you better if you give me the file hierarchy of kdrive’s $out so I can see what’s actually bundled there and what not. And perhaps ldd output of kdrive’s binary.

(I probably can build your derivation as well later when I have more time :smiley: )

1 Like

Thanks for the tips about strings, I usually use ldd in combination with nix-locate to find which package provides a given library.

As for the RPATH / LD_LIBRARY_PATH, I don’t quite understand when to use which yet. Afaict, rpath is for static lib while ld_lib is for dynamic lib, but I’m not even sure about that :sweat_smile:

Thanks for steering me in the right direction, I’ll continue to try to make it work with a normal derivation instead of running the AppImage then!

Here are the top two levels hierarchy of kDrive’s $out:

.
├── bin
├── lib
│   ├── nss
│   ├── pkgconfig
│   └── qt5
├── libexec
├── plugins
│   ├── assetimporters
│   ├── canbus
│   ├── designer
│   ├── egldeviceintegrations
│   ├── generic
│   ├── geometryloaders
│   ├── iconengines
│   ├── imageformats
│   ├── networkinformation
│   ├── opcua
│   ├── platforminputcontexts
│   ├── platforms
│   ├── platformthemes
│   ├── position
│   ├── printsupport
│   ├── qmltooling
│   ├── renderers
│   ├── renderplugins
│   ├── sceneparsers
│   ├── scxmldatamodel
│   ├── sensors
│   ├── sqldrivers
│   ├── tls
│   ├── virtualkeyboard
│   ├── webview
│   └── xcbglintegrations
├── qml
├── resources
├── share
│   ├── applications
│   ├── doc
│   ├── icons
│   ├── kDrive_client
│   └── mime
└── translations
    └── qtwebengine_locales

And here is the whole hierarchy:

.
├── bin
├── lib
│   ├── nss
│   ├── pkgconfig
│   └── qt5
│       └── plugins
├── libexec
├── plugins
│   ├── assetimporters
│   ├── canbus
│   ├── designer
│   ├── egldeviceintegrations
│   ├── generic
│   ├── geometryloaders
│   ├── iconengines
│   ├── imageformats
│   ├── networkinformation
│   ├── opcua
│   ├── platforminputcontexts
│   ├── platforms
│   ├── platformthemes
│   ├── position
│   ├── printsupport
│   ├── qmltooling
│   ├── renderers
│   ├── renderplugins
│   ├── sceneparsers
│   ├── scxmldatamodel
│   ├── sensors
│   ├── sqldrivers
│   ├── tls
│   ├── virtualkeyboard
│   ├── webview
│   └── xcbglintegrations
├── qml
├── resources
├── share
│   ├── applications
│   ├── doc
│   │   ├── libasn1-8-heimdal
│   │   ├── libavahi-client3
│   │   ├── libavahi-common3
│   │   ├── libbrotli1
│   │   ├── libbsd0
│   │   ├── libcups2
│   │   ├── libcurl4
│   │   ├── libffi7
│   │   ├── libgcrypt20
│   │   ├── libglib2.0-0
│   │   ├── libgnutls30
│   │   ├── libgssapi3-heimdal
│   │   ├── libgssapi-krb5-2
│   │   ├── libhcrypto4-heimdal
│   │   ├── libheimbase1-heimdal
│   │   ├── libheimntlm0-heimdal
│   │   ├── libhogweed5
│   │   ├── libhx509-5-heimdal
│   │   ├── libicu66
│   │   ├── libidn2-0
│   │   ├── libjbig0
│   │   ├── libjpeg-turbo8
│   │   ├── libk5crypto3
│   │   ├── libkrb5-26-heimdal
│   │   ├── libkrb5-3
│   │   ├── libkrb5support0
│   │   ├── libldap-2.4-2
│   │   ├── liblz4-1
│   │   ├── libnettle7
│   │   ├── libnghttp2-14
│   │   ├── libnspr4
│   │   ├── libnss3
│   │   ├── libpcre2-16-0
│   │   ├── libpcre2-8-0
│   │   ├── libpng16-16
│   │   ├── libpsl5
│   │   ├── libroken18-heimdal
│   │   ├── librtmp1
│   │   ├── libsasl2-2
│   │   ├── libsecret-1-0
│   │   ├── libsqlite3-0
│   │   ├── libssh-4
│   │   ├── libtasn1-6
│   │   ├── libtiff5
│   │   ├── libunistring2
│   │   ├── libwebp6
│   │   ├── libwind0-heimdal
│   │   ├── libx11-xcb1
│   │   ├── libxau6
│   │   ├── libxcb-glx0
│   │   ├── libxcb-icccm4
│   │   ├── libxcb-image0
│   │   ├── libxcb-keysyms1
│   │   ├── libxcb-randr0
│   │   ├── libxcb-render0
│   │   ├── libxcb-render-util0
│   │   ├── libxcb-shape0
│   │   ├── libxcb-shm0
│   │   ├── libxcb-sync1
│   │   ├── libxcb-util1
│   │   ├── libxcb-xfixes0
│   │   ├── libxcb-xinput0
│   │   ├── libxcb-xkb1
│   │   ├── libxcomposite1
│   │   ├── libxdamage1
│   │   ├── libxdmcp6
│   │   ├── libxext6
│   │   ├── libxfixes3
│   │   ├── libxkbcommon0
│   │   ├── libxkbcommon-x11-0
│   │   ├── libxkbfile1
│   │   ├── libxml2
│   │   ├── libxrandr2
│   │   ├── libxrender1
│   │   ├── libxshmfence1
│   │   ├── libxtst6
│   │   └── libzstd1
│   ├── icons
│   │   └── hicolor
│   │       ├── 1024x1024
│   │       │   └── apps
│   │       ├── 128x128
│   │       │   └── apps
│   │       ├── 16x16
│   │       │   └── apps
│   │       ├── 24x24
│   │       │   └── apps
│   │       ├── 256x256
│   │       │   └── apps
│   │       ├── 32x32
│   │       │   └── apps
│   │       ├── 48x48
│   │       │   └── apps
│   │       ├── 512x512
│   │       │   └── apps
│   │       ├── 64x64
│   │       │   └── apps
│   │       ├── 72x72
│   │       │   └── apps
│   │       └── scalable
│   │           └── apps
│   ├── kDrive_client
│   │   └── i18n
│   └── mime
│       └── packages
└── translations
    └── qtwebengine_locales

147 directories

Here is the ldd output:

ldd bin/.kDrive-wrapped
        linux-vdso.so.1 (0x00007ffc8af89000)
        libsentry.so => /nix/store/59s2xrl6980dpiv5sxf889zg1d86wd1f-sentry-native-0.6.7/lib/libsentry.so (0x00007f07a6309000)
        libz.so.1 => /nix/store/4znq11s8j9d29kj2l4qivl5pyhbbzy8q-zlib-1.3/lib/libz.so.1 (0x00007f07a62eb000)
        libQt6Widgets.so.6 => /nix/store/fmnz3r0gihr33p7r3019zv5x1zhjm455-qt-full-6.6.1/lib/libQt6Widgets.so.6 (0x00007f07a4c00000)
        libPocoNetSSL.so.95 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libPocoNetSSL.so.95 (0x00007f07a5393000)
        libPocoNet.so.95 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libPocoNet.so.95 (0x00007f07a4a4b000)
        libPocoJSON.so.95 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libPocoJSON.so.95 (0x00007f07a49d0000)
        libPocoXML.so.95 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libPocoXML.so.95 (0x00007f07a4907000)
        libPocoFoundation.so.95 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libPocoFoundation.so.95 (0x00007f07a4600000)
        libQt6Network.so.6 => /nix/store/fmnz3r0gihr33p7r3019zv5x1zhjm455-qt-full-6.6.1/lib/libQt6Network.so.6 (0x00007f07a4441000)
        libQt6Gui.so.6 => /nix/store/fmnz3r0gihr33p7r3019zv5x1zhjm455-qt-full-6.6.1/lib/libQt6Gui.so.6 (0x00007f07a3a00000)
        libsqlite3.so.0 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libsqlite3.so.0 (0x00007f07a4315000)
        libxxhash.so.0 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libxxhash.so.0 (0x00007f07a62d7000)
        liblog4cplusU.so.9 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/liblog4cplusU.so.9 (0x00007f07a3200000)
        libpthread.so.0 => /nix/store/7jiqcrg061xi5clniy7z5pvkc4jiaqav-glibc-2.38-27/lib/libpthread.so.0 (0x00007f07a62d2000)
        libQt6Xml.so.6 => /nix/store/fmnz3r0gihr33p7r3019zv5x1zhjm455-qt-full-6.6.1/lib/libQt6Xml.so.6 (0x00007f07a48de000)
        libQt6Core.so.6 => /nix/store/fmnz3r0gihr33p7r3019zv5x1zhjm455-qt-full-6.6.1/lib/libQt6Core.so.6 (0x00007f07a2a00000)
        libsecret-1.so.0 => /nix/store/3k0rlifw3p7wr1jdag2s1hdsk8f7l78x-libsecret-0.21.2/lib/libsecret-1.so.0 (0x00007f07a399f000)
        libglib-2.0.so.0 => /nix/store/nynq8wryq2lzq92mcj0niiwady33qhss-glib-2.78.3/lib/libglib-2.0.so.0 (0x00007f07a30b8000)
        libstdc++.so.6 => /nix/store/np3cndfk53miqg2cilv7vfdxckga665h-gcc-13.2.0-lib/lib/libstdc++.so.6 (0x00007f07a2600000)
        libgcc_s.so.1 => /nix/store/np3cndfk53miqg2cilv7vfdxckga665h-gcc-13.2.0-lib/lib/libgcc_s.so.1 (0x00007f07a48b9000)
        libc.so.6 => /nix/store/7jiqcrg061xi5clniy7z5pvkc4jiaqav-glibc-2.38-27/lib/libc.so.6 (0x00007f07a2417000)
        libcurl.so.4 => /nix/store/l5rgcblia1bvrhp8p7s9xbyhf25alnpy-curl-8.5.0/lib/libcurl.so.4 (0x00007f07a38e1000)
        libdl.so.2 => /nix/store/7jiqcrg061xi5clniy7z5pvkc4jiaqav-glibc-2.38-27/lib/libdl.so.2 (0x00007f07a538e000)
        librt.so.1 => /nix/store/7jiqcrg061xi5clniy7z5pvkc4jiaqav-glibc-2.38-27/lib/librt.so.1 (0x00007f07a5389000)
        libm.so.6 => /nix/store/7jiqcrg061xi5clniy7z5pvkc4jiaqav-glibc-2.38-27/lib/libm.so.6 (0x00007f07a291e000)
        libGLX.so.0 => /nix/store/fmnz3r0gihr33p7r3019zv5x1zhjm455-qt-full-6.6.1/lib/libGLX.so.0 (0x00007f07a42e1000)
        libOpenGL.so.0 => /nix/store/fmnz3r0gihr33p7r3019zv5x1zhjm455-qt-full-6.6.1/lib/libOpenGL.so.0 (0x00007f07a38b4000)
        libxkbcommon.so.0 => /nix/store/pav3ikskqx8nzynjr09pnd4js0v0hanp-libxkbcommon-1.5.0/lib/libxkbcommon.so.0 (0x00007f07a3072000)
        libPocoCrypto.so.95 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libPocoCrypto.so.95 (0x00007f07a28c2000)
        libPocoUtil.so.95 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libPocoUtil.so.95 (0x00007f07a2378000)
        libssl.so.3 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libssl.so.3 (0x00007f07a22c5000)
        libcrypto.so.3 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libcrypto.so.3 (0x00007f07a1c00000)
        libgssapi_krb5.so.2 => /nix/store/jqcm3z315k4dx4qqdcvvs3b80fganpbr-libkrb5-1.21.2/lib/libgssapi_krb5.so.2 (0x00007f07a286e000)
        libbrotlidec.so.1 => /nix/store/9nsd8bhgzb7ar3366lvlycj9lr0wldpx-brotli-1.1.0-lib/lib/libbrotlidec.so.1 (0x00007f07a5377000)
        libzstd.so.1 => /nix/store/c5gp1vii3qmma428db3gyyb91p710whs-zstd-1.5.5/lib/libzstd.so.1 (0x00007f07a21f5000)
        libresolv.so.2 => /nix/store/7jiqcrg061xi5clniy7z5pvkc4jiaqav-glibc-2.38-27/lib/libresolv.so.2 (0x00007f07a48a8000)
        libproxy.so.1 => /nix/store/9vrqakbxqny19cijzld65fvwwnbgji5p-libproxy-0.4.18/lib/libproxy.so.1 (0x00007f07a21c9000)
        libEGL.so.1 => /nix/store/fmnz3r0gihr33p7r3019zv5x1zhjm455-qt-full-6.6.1/lib/libEGL.so.1 (0x00007f07a4892000)
        libfontconfig.so.1 => /nix/store/2l7n2j174m0r2w6g3fa3yhw959d8nsx1-fontconfig-2.15.0-lib/lib/libfontconfig.so.1 (0x00007f07a217c000)
        libX11.so.6 => /nix/store/x51ly05chwj47xgz5grn48rz5k2mvzlg-libX11-1.8.7/lib/libX11.so.6 (0x00007f07a1abb000)
        libQt6DBus.so.6 => /nix/store/fmnz3r0gihr33p7r3019zv5x1zhjm455-qt-full-6.6.1/lib/libQt6DBus.so.6 (0x00007f07a19f0000)
        libpng16.so.16 => /nix/store/954azsd5c9fzkbywi67dcfx7d9zs6zn8-libpng-apng-1.6.40/lib/libpng16.so.16 (0x00007f07a19b7000)
        libharfbuzz.so.0 => /nix/store/yigjjj9bfm0bdq3pcjqir1jvkg2wy5ai-harfbuzz-7.3.0/lib/libharfbuzz.so.0 (0x00007f07a189b000)
        libmd4c.so.0 => /nix/store/vzkbqr9ls5lpjvjw92s8q8cz9whr2rsg-md4c-0.5.1-lib/lib/libmd4c.so.0 (0x00007f07a389e000)
        libfreetype.so.6 => /nix/store/a08037rgj7gam8qp1ma134n1pqbdfisa-freetype-2.13.2/lib/libfreetype.so.6 (0x00007f07a17cd000)
        libgthread-2.0.so.0 => /nix/store/nynq8wryq2lzq92mcj0niiwady33qhss-glib-2.78.3/lib/libgthread-2.0.so.0 (0x00007f07a42dc000)
        /nix/store/7jiqcrg061xi5clniy7z5pvkc4jiaqav-glibc-2.38-27/lib/ld-linux-x86-64.so.2 => /nix/store/7jiqcrg061xi5clniy7z5pvkc4jiaqav-glibc-2.38-27/lib64/ld-linux-x86-64.so.2 (0x00007f07a6360000)
        libicui18n.so.73 => /nix/store/v3bkb7jmz1d4q2wf3zzd3r8d4y5bndp7-icu4c-73.2/lib/libicui18n.so.73 (0x00007f07a1400000)
        libicuuc.so.73 => /nix/store/v3bkb7jmz1d4q2wf3zzd3r8d4y5bndp7-icu4c-73.2/lib/libicuuc.so.73 (0x00007f07a1000000)
        libicudata.so.73 => /nix/store/v3bkb7jmz1d4q2wf3zzd3r8d4y5bndp7-icu4c-73.2/lib/libicudata.so.73 (0x00007f079f000000)
        libsystemd.so.0 => /nix/store/p29wd6v1nr9c11w58x45pcykrllc88rn-systemd-minimal-libs-255.2/lib/libsystemd.so.0 (0x00007f07a12f1000)
        libdouble-conversion.so.3 => /nix/store/k2n0m5xvw4vsvqrdf3q2r4m32sb3d35y-double-conversion-3.3.0/lib/libdouble-conversion.so.3 (0x00007f07a216a000)
        libb2.so.1 => /nix/store/bi495fbridg6i82wx5x1m9nf84hnvpf4-libb2-0.98.1/lib/libb2.so.1 (0x00007f07a17af000)
        libpcre2-16.so.0 => /nix/store/w0q7xgwb18fdfrmsbzalxdbrhvzfrn5i-pcre2-10.42/lib/libpcre2-16.so.0 (0x00007f07a1262000)
        libgio-2.0.so.0 => /nix/store/nynq8wryq2lzq92mcj0niiwady33qhss-glib-2.78.3/lib/libgio-2.0.so.0 (0x00007f079ee11000)
        libgobject-2.0.so.0 => /nix/store/nynq8wryq2lzq92mcj0niiwady33qhss-glib-2.78.3/lib/libgobject-2.0.so.0 (0x00007f07a0f9f000)
        libgcrypt.so.20 => /nix/store/419yk337bja2haqhi2qcd2918l9gjrap-libgcrypt-1.10.3/lib/libgcrypt.so.20 (0x00007f079ecca000)
        libpcre2-8.so.0 => /nix/store/w0q7xgwb18fdfrmsbzalxdbrhvzfrn5i-pcre2-10.42/lib/libpcre2-8.so.0 (0x00007f07a0f02000)
        libnghttp2.so.14 => /nix/store/4z9wwg9lgdy30drvizy891zisj2makq4-nghttp2-1.57.0-lib/lib/libnghttp2.so.14 (0x00007f07a177f000)
        libidn2.so.0 => /nix/store/x3wc0s3165pfcakkbbc22j7k5hndc73k-libidn2-2.3.4/lib/libidn2.so.0 (0x00007f07a1231000)
        libssh2.so.1 => /nix/store/4hdjb7r9k0dpcyk11k568c6y9kdgf6zc-libssh2-1.11.0/lib/libssh2.so.1 (0x00007f07a0ebc000)
        libXext.so.6 => /nix/store/8a30syk0pipph0m1baz281as60q2d33m-libXext-1.3.5/lib/libXext.so.6 (0x00007f07a2155000)
        libGLdispatch.so.0 => /nix/store/k203rr7im6rhbqpdravvzp92y2fn9mkn-libglvnd-1.7.0/lib/libGLdispatch.so.0 (0x00007f079ec11000)
        libkrb5.so.3 => /nix/store/jqcm3z315k4dx4qqdcvvs3b80fganpbr-libkrb5-1.21.2/lib/libkrb5.so.3 (0x00007f079eb3a000)
        libk5crypto.so.3 => /nix/store/jqcm3z315k4dx4qqdcvvs3b80fganpbr-libkrb5-1.21.2/lib/libk5crypto.so.3 (0x00007f07a1750000)
        libcom_err.so.3 => /nix/store/jqcm3z315k4dx4qqdcvvs3b80fganpbr-libkrb5-1.21.2/lib/libcom_err.so.3 (0x00007f07a3065000)
        libkrb5support.so.0 => /nix/store/jqcm3z315k4dx4qqdcvvs3b80fganpbr-libkrb5-1.21.2/lib/libkrb5support.so.0 (0x00007f07a1223000)
        libkeyutils.so.1 => /nix/store/d3jhphmgval3c9hhvmz04qj3qavy8hns-keyutils-1.6.3-lib/lib/libkeyutils.so.1 (0x00007f07a2867000)
        libbrotlicommon.so.1 => /nix/store/9nsd8bhgzb7ar3366lvlycj9lr0wldpx-brotli-1.1.0-lib/lib/libbrotlicommon.so.1 (0x00007f07a0e99000)
        libduktape.so.207 => /nix/store/55kf5w9a1q32hf8pss630ypcgsnin7v0-duktape-2.7.0/lib/libduktape.so.207 (0x00007f079eaef000)
        libbz2.so.1 => /nix/store/rmnl7cvvr3gfx4g821xbcaqy3x0g6v6r-bzip2-1.0.8/lib/libbz2.so.1 (0x00007f07a1210000)
        libexpat.so.1 => /nix/store/8ah0ykrhnb24rppms5dp8nzg1z9n8r40-expat-2.5.0/lib/libexpat.so.1 (0x00007f079eac4000)
        libxcb.so.1 => /nix/store/d34xzgg5adx5l4ps79ppyb98lvyhkgm5-libxcb-1.16/lib/libxcb.so.1 (0x00007f079ea99000)
        libdbus-1.so.3 => /nix/store/vw8rfrcf4rqc72a5z6lzy4sgn7p6c11z-dbus-1.14.10-lib/lib/libdbus-1.so.3 (0x00007f079ea42000)
        libgraphite2.so.3 => /nix/store/2p1azsamsaksql5pgdpmlsr4b7pz50kx-graphite2-1.3.14/lib/libgraphite2.so.3 (0x00007f079ea19000)
        libcap.so.2 => /nix/store/6cs25bzy29gilhwwv2wwy0pj2pisvcf1-libcap-2.69-lib/lib/libcap.so.2 (0x00007f079ea0d000)
        libgomp.so.1 => /nix/store/np3cndfk53miqg2cilv7vfdxckga665h-gcc-13.2.0-lib/lib/libgomp.so.1 (0x00007f079e9c0000)
        libgmodule-2.0.so.0 => /nix/store/nynq8wryq2lzq92mcj0niiwady33qhss-glib-2.78.3/lib/libgmodule-2.0.so.0 (0x00007f07a0e92000)
        libmount.so.1 => /nix/store/zkcb4vjfisrs1nd8c632hgz1rg9wnys5-util-linux-minimal-2.39.3-lib/lib/libmount.so.1 (0x00007f079e950000)
        libselinux.so.1 => /nix/store/6d58n94mxvbnz3i94kg532kkakv5kclk-libselinux-3.3/lib/libselinux.so.1 (0x00007f079e923000)
        libffi.so.8 => /nix/store/npfpil5nswlaqy7y56dwp0csj91pjiyd-libffi-3.4.4/lib/libffi.so.8 (0x00007f079e912000)
        libgpg-error.so.0 => /nix/store/wqigl7a7nv4v0494s6qx7mlnngmpb6v0-libgpg-error-1.47/lib/libgpg-error.so.0 (0x00007f079e8ea000)
        libunistring.so.5 => /nix/store/mgkvalznvc8ik2r9p93445vjbd80ax00-libunistring-1.1/lib/libunistring.so.5 (0x00007f079e73a000)
        libXau.so.6 => /nix/store/y83n31linby6r3j74qmrx07p4j3cvn3n-libXau-1.0.11/lib/libXau.so.6 (0x00007f079e735000)
        libXdmcp.so.6 => /nix/store/2dk15lndgdakw0psnhlqcc20ar05iqj3-libXdmcp-1.1.4/lib/libXdmcp.so.6 (0x00007f079e72d000)
        libblkid.so.1 => /nix/store/zkcb4vjfisrs1nd8c632hgz1rg9wnys5-util-linux-minimal-2.39.3-lib/lib/libblkid.so.1 (0x00007f079e6d1000)
        libpcre.so.1 => /nix/store/6yy1qjh33sjvdybxqd5qasa33scz3m7g-pcre-8.45/lib/libpcre.so.1 (0x00007f079e657000)

As you can see, most of the libs points to the Nix store, while some points to the ones from the extracted AppImage content:

        libPocoNetSSL.so.95 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libPocoNetSSL.so.95 (0x00007f881a355000)
        libPocoNet.so.95 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libPocoNet.so.95 (0x00007f8818a4b000)
        libPocoJSON.so.95 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libPocoJSON.so.95 (0x00007f881a2d8000)
        libPocoXML.so.95 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libPocoXML.so.95 (0x00007f8818982000)
        libPocoFoundation.so.95 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libPocoFoundation.so.95 (0x00007f8818600000)
        libsqlite3.so.0 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libsqlite3.so.0 (0x00007f8818315000)
        libxxhash.so.0 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libxxhash.so.0 (0x00007f88193f0000)
        liblog4cplusU.so.9 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/liblog4cplusU.so.9 (0x00007f8817200000)
        libPocoCrypto.so.95 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libPocoCrypto.so.95 (0x00007f88170a0000)
        libPocoUtil.so.95 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libPocoUtil.so.95 (0x00007f881687f000)
        libssl.so.3 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libssl.so.3 (0x00007f8816364000)
        libcrypto.so.3 => /nix/store/kd7k51xscy8jkdgryr24cmpsrkzb7diw-kDrive-3.5.7.20240124/lib/libcrypto.so.3 (0x00007f8815e00000)

As per the proposal to write the whole derivation, I’d like to first thank you but I’d rather having us working together so I can learn in the process than you doing all the work!

From what I understand, ldd is not complaining about any missing library, and all libraries mentioned by strings are either provided via the derivation libPath or the lib directory added to rpath.

I’ll try to update the derivation to use wrapProgram to set LD_LIBRARY_PATH instead of using patchelf to set RPATH. Will let you know how it goes!

I meant that I could look up the file hierarchies and symbols myself, not write the solution for you of course :smile:

RPATH works for all the libraries that are directly linked to .so or executable. The ones you see in ldd output. LD_LIBRARY_PATH works for that and also when the executable dlopen’s something, aka loads library runtime. This is what Qt does when it loads platform plugins.

Based on your LDD outputs, it seems you’ve managed to nicely make the program link against nixpkgs packaged libraries instead of any kdrive’s bundled ones. Now, I must confess I haven’t ever packaged Qt program using nix, so I don’t know how it handles QT_PLUGIN_PATH (I would assume they patch Qt to always find the correct location), but alas, it seems nixpkgs has this thing called wrapQtAppsHook that you are supposed to use.

Unless kDrive ships modified Qt plugins / backends, then I think it might also be safe to remove the plugins folder from the $out, the lib and share/doc folders might be unneccessary too