I want to use ProtonMail’s import-export app: How to export emails using the Import-Export app | Proton.
I couldn’t get any of the tools like steam-run
etc to work so I figured, I’ll just try and package it properly but I am kind of stuck (fairly new to Nix).
It is a QT5 app and I’ve figured out that I want to use wrapQtAppsHook
. The app does have a launcher script which isn’t picked up by the hook AFAIK so I resorted to manually wrapping it. It builds fine but when I try to run it, I still get an error that I am trying to run an unpatched binary on NixOS.
This is where I am stuck. I thought the wrapQtAppsHook
would take care of all of that? Here is what I have:
{ stdenv, lib, dpkg, fetchurl, qtbase, wrapQtAppsHook, patchelf, ... }:
stdenv.mkDerivation rec {
pname = "protonmail-import-export-app";
version = "1.3.3-1";
src = fetchurl {
url = "https://proton.me/download/ie/protonmail-import-export-app_${version}_amd64.deb";
hash = "sha256-gz82nTWNwT5q2BPeTYwHGtkefhJv0G8x+Lc2Zj6PP9A=";
};
nativeBuildInputs = [ dpkg wrapQtAppsHook ];
buildInputs = [ qtbase ];
unpackPhase = ''
dpkg-deb -x $src .
'';
installPhase = ''
mkdir -p $out
cp -r usr/* $out
rm $out/bin/protonmail-import-export-app # Delete existing symlink so we can create our own.
'';
dontWrapQtApps = true;
preFixup = ''
wrapQtApp "$out/lib/protonmail/import-export/proton-ie"
wrapQtApp "$out/lib/protonmail/import-export/proton-ie-launcher"
'';
postFixup = ''
# Ensure the launcher is accessible and executable
ln -s $out/lib/protonmail/import-export/proton-ie-launcher $out/bin/protonmail-import-export-app
chmod +x $out/bin/protonmail-import-export-app
'';
meta = with stdenv.lib; {
description = "Proton Import-Export app";
homepage = https://proton.me/support/export-emails-import-export-app;
};
}
I don’t have any experience with QT either so I am not sure why there is a launcher binary next to the actual app. Do I need to patch both? How do I do that?
ChatGPT was suggesting something like:
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $out/lib:$out/lib/protonmail/import-export:${stdenv.lib.makeLibraryPath [ qtbase ]} \
$out/lib/protonmail/import-export/proton-ie-launcher
But that didn’t work either.
The ldd
output for both binaries is:
❯ ldd /nix/store/14mk99za3f8psykgshihp84kdpx6hbnw-protonmail-import-export-app-1.3.3-1/lib/protonmail/import-export/proton-ie
linux-vdso.so.1 (0x00007ffd52dc1000)
libc.so.6 => /nix/store/cyrrf49i2hm1w7vn2j945ic3rrzgxbqs-glibc-2.38-44/lib/libc.so.6 (0x00007f8b888d4000)
/nix/store/cyrrf49i2hm1w7vn2j945ic3rrzgxbqs-glibc-2.38-44/lib/ld-linux-x86-64.so.2 => /nix/store/cyrrf49i2hm1w7vn2j945ic3rrzgxbqs-glibc-2.38-44/lib64/ld-linux-x86-64.so.2 (0x00007f8b88abf000)
❯ ldd /nix/store/14mk99za3f8psykgshihp84kdpx6hbnw-protonmail-import-export-app-1.3.3-1/lib/protonmail/import-export/proton-ie-launcher
linux-vdso.so.1 (0x00007ffdbf2dd000)
libc.so.6 => /nix/store/cyrrf49i2hm1w7vn2j945ic3rrzgxbqs-glibc-2.38-44/lib/libc.so.6 (0x00007f701a46b000)
/nix/store/cyrrf49i2hm1w7vn2j945ic3rrzgxbqs-glibc-2.38-44/lib/ld-linux-x86-64.so.2 => /nix/store/cyrrf49i2hm1w7vn2j945ic3rrzgxbqs-glibc-2.38-44/lib64/ld-linux-x86-64.so.2 (0x00007f701a656000)