From 8fb3ddb0d7e381223d357c93efec2465151f958e Mon Sep 17 00:00:00 2001 From: depsterr Date: Fri, 26 Jul 2024 18:21:36 +0200 Subject: [PATCH] protonmail desktop --- flake.nix | 2 ++ home-manager/applications.nix | 2 +- pkgs/protonmail-desktop.nix | 63 +++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 pkgs/protonmail-desktop.nix diff --git a/flake.nix b/flake.nix index fb1a6e9..97aa73a 100644 --- a/flake.nix +++ b/flake.nix @@ -70,6 +70,7 @@ cpypsk = self.packages.${system}.cpypsk; renoise = self.packages.${system}.renoise; wall = self.packages.${system}.wall; + protonmail-desktop = self.packages.${system}.protonmail-desktop; }; }; }; @@ -119,6 +120,7 @@ cpypsk = import ./pkgs/cpypsk.nix { inherit pkgs pash; }; renoise = import ./pkgs/renoise.nix { inherit pkgs; }; wall = import ./pkgs/wall.nix { inherit pkgs; }; + protonmail-desktop = import ./pkgs/protonmail-desktop.nix { inherit pkgs; }; }; }); } diff --git a/home-manager/applications.nix b/home-manager/applications.nix index 2fd7ba7..702353b 100644 --- a/home-manager/applications.nix +++ b/home-manager/applications.nix @@ -71,6 +71,6 @@ unstable.kicad extra.renoise extra.nixprof - unstable.protonmail-desktop + extra.protonmail-desktop ]; } diff --git a/pkgs/protonmail-desktop.nix b/pkgs/protonmail-desktop.nix new file mode 100644 index 0000000..32f88ee --- /dev/null +++ b/pkgs/protonmail-desktop.nix @@ -0,0 +1,63 @@ +{ pkgs, ... }: +let mainProgram = "protonmail-desktop"; + srcHashes = { + universal-darwin = "sha256-JfZwHFp0aZtHcbP7tyG7uqFs2w+LWKfnfyuxxpxDJZ8="; + x86_64-linux = "sha256-En5vkTHYtwN6GMgbtyhzsPqknOPRO9KlTqZfbBFaIFQ="; + }; +in +pkgs.stdenv.mkDerivation rec { + pname = "protonmail-desktop"; + 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'" + ''; +}