Packing proton-mail

Hey! I am trying to run proton-mail in NixOS. here’s my try to pack it.

{ pkgs, lib, ... }:
let
  stdenv = pkgs.stdenv;

in
stdenv.mkDerivation {
	name = "proton-mail";
	src = pkgs.fetchurl {
		url = "https://proton.me/download/mail/linux/ProtonMail-desktop-beta.deb";
		hash = "sha256-2uUDceqAYW9144NBQdBwqZBlaTk5AGeyI12CUyCoW1E=";
	};

  buildInputs = with pkgs; [
    libsForQt5.qt5.qtbase
    libgcc
    wlroots
    expat
    alsa-lib
    at-spi2-atk
    gtk3
    spacx-gtk-theme
    cups
    pango
    cairo
    nss
    p11-kit
    nspr
    python312Packages.pyatspi
  ] ++ (with xorg; [
    libX11
    libXext
    libxcb
    libXdamage
    libXfixes
    libXrandr
    libxkbcommon
    libXcomposite
  ]);

  nativeBuildInputs = with pkgs; [
    dpkg
    pkg-config
    autoPatchelfHook
    libsForQt5.qt5.wrapQtAppsHook
  ];

  unpackPhase = ''
    dpkg-deb --fsys-tarfile $src | \
      tar -x --no-same-owner
    mv usr $out
  '';

  installPhase = ''
    cp ${pkgs.writeShellScriptBin "proton-check" ''
      echo $XAUTHORITY
      echo $DISPLAY
      echo "f-conf $FONTCONFIG_FILE"
      echo ${pkgs.makeFontsConf { fontDirectories = [ ]; } }
      echo $HOME
    ''}/bin/proton-check $out/bin

    wrapQtApp $out/lib/proton-mail/Proton\ Mail\ Beta \
      --set FONTCONFIG_FILE ${pkgs.makeFontsConf {
          fontDirectories = [
            pkgs.dejavu_fonts
            pkgs.noto-fonts
          ];
        }
      } \
      --set G_LOG_USE_STRUCTURED "1" \
      --add-flags --disable-gpu \
      --add-flags --headless \
      --add-flags --screenshot \
      --add-flags -with-trust-paths=/etc/ssl/certs/ca-certificates.crt
  '';

  dontWrapQtApps = true;

  meta = {
    description = "Proton Mail app";
    homepage = "https://proton.me/support/mail-desktop-app";
  };
}

but it fails when I run

$ proton-mail
12:14:55.774 (settings) › Settings saved {"spellChecker":true,"overrideError":false,"releaseCategory":"Stable","rolloutProportion":0.7692008027825401}
12:14:55.788 (main)     › App start is mac: false is windows: false isLinux: true version: 1.1.0
12:14:55.789 (main)     › Desktop features: InAppPayments:true, ThemeSelection:true, EarlyAccess:true, MultiAccount:true, LatestVersionCheck:true
12:14:55.828 (main)     › App is not default mailto client

(proton-mail:3674910): Gtk-WARNING **: 12:14:55.852: Theme parsing error: gtk.css:56:7: 'filter' is not a valid property name

(proton-mail:3674910): Gtk-WARNING **: 12:14:55.853: Theme parsing error: gtk.css:78:25: The :insensitive pseudo-class is deprecated. Use :disabled instead.

(proton-mail:3674910): Gtk-WARNING **: 12:14:55.853: Theme parsing error: gtk.css:79:25: The :insensitive pseudo-class is deprecated. Use :disabled instead.

(proton-mail:3674910): Gtk-WARNING **: 12:14:55.853: Theme parsing error: gtk.css:80:18: The :insensitive pseudo-class is deprecated. Use :disabled instead.

(proton-mail:3674910): Gtk-WARNING **: 12:14:55.853: Theme parsing error: gtk.css:81:19: The :insensitive pseudo-class is deprecated. Use :disabled instead.

(proton-mail:3674910): Gtk-WARNING **: 12:14:55.853: Theme parsing error: gtk.css:82:19: The :insensitive pseudo-class is deprecated. Use :disabled instead.

(proton-mail:3674910): Gtk-WARNING **: 12:14:55.853: Theme parsing error: gtk.css:83:18: The :insensitive pseudo-class is deprecated. Use :disabled instead.

(proton-mail:3674910): Gtk-WARNING **: 12:14:55.853: Theme parsing error: gtk.css:84:18: The :insensitive pseudo-class is deprecated. Use :disabled instead.

(proton-mail:3674910): Gtk-WARNING **: 12:14:55.853: Theme parsing error: gtk.css:85:17: The :insensitive pseudo-class is deprecated. Use :disabled instead.

(proton-mail:3674910): Gtk-WARNING **: 12:14:55.853: Theme parsing error: gtk.css:97:7: 'filter' is not a valid property name
[1]    3674910 trace trap (core dumped)  proton-mail
[3674920:0100/000000.383920:ERROR:zygote_linux.cc(625)] Zygote could not fork: process_type gpu-process numfds 3 child_pid -1
[3674920:0100/000000.384020:ERROR:zygote_linux.cc(657)] write: Broken pipe (32)

couldn’t fix the issue. Thank you for your insight.

I have a much better alternative for you: nixos-x260/pkgs/by-name/chromium-protonmail/package.nix at 6167103dbe4552db85904ca4ff81a99dd33274e2 · drupol/nixos-x260 · GitHub

This is basically a wrapper that creates a chromium application. No need to install their client, this is a very good option.

2 Likes

thanks @drupol it looks great, but I am using their webapp currently. isn’t their app different from their webapp? are they both implemented in Javascript? if no, I have to reveal one of my personality traits and say that I don’t trust Javascript to handle my stuff! :smiley: so let’s try to make the packaging above works.

There’s a lot of chance that their closed source webapp is just a chromium with custom Javascript… so I definitely prefer using my own version :wink:

Anyway, your choice here.

2 Likes