{ pkgs, ... }: let mainProgram = "proton-mail"; srcHashes = { universal-darwin = "sha256-JfZwHFp0aZtHcbP7tyG7uqFs2w+LWKfnfyuxxpxDJZ8="; x86_64-linux = "sha256-En5vkTHYtwN6GMgbtyhzsPqknOPRO9KlTqZfbBFaIFQ="; }; in pkgs.stdenv.mkDerivation rec { pname = mainProgram; version = "1.0.5"; nativeBuildInputs = [ pkgs.makeWrapper ] ++ pkgs.lib.optional pkgs.stdenv.isLinux pkgs.dpkg ++ pkgs.lib.optional pkgs.stdenv.isDarwin pkgs.unzip; src = pkgs.fetchurl { url = if pkgs.stdenv.isDarwin then "https://github.com/ProtonMail/inbox-desktop/releases/download/${version}/Proton.Mail-darwin-universal-${version}.zip" else "https://github.com/ProtonMail/inbox-desktop/releases/download/${version}/proton-mail_${version}_amd64.deb"; sha256 = { x86_64-linux = srcHashes.x86_64-linux; x86_64-darwin = srcHashes.universal-darwin; aarch64-darwin = srcHashes.universal-darwin; } .${pkgs.stdenv.hostPlatform.system} or (throw "unsupported system ${pkgs.stdenv.hostPlatform.system}"); }; sourceRoot = pkgs.lib.optionalString pkgs.stdenv.isDarwin "."; dontConfigure = true; dontBuild = true; installPhase = let darwin = '' mkdir -p $out/{Applications,bin} cp -r "Proton Mail.app" $out/Applications/ makeWrapper $out/Applications/"Proton Mail.app"/Contents/MacOS/Proton\ Mail $out/bin/protonmail-desktop ''; linux = '' runHook preInstall mkdir -p $out cp -r usr/share/ $out/ cp -r usr/lib/ $out/ ''; in '' runHook preInstall ${if pkgs.stdenv.isDarwin then darwin else linux} runHook postInstall ''; preFixup = pkgs.lib.optionalString pkgs.stdenv.isLinux '' makeWrapper ${pkgs.steam-run}/bin/steam-run $out/bin/${mainProgram} \ --add-flags "$out'/lib/proton-mail/Proton Mail Beta'" ''; }