build-bazel-package: added rm of extra local folders for toolchain configuration...
[NixPkgs.git] / pkgs / by-name / pr / protonmail-bridge-gui / package.nix
blob3d159ffb6459f0baabff47cc6c7e878e4fd211ae
2   lib,
3   stdenv,
4   pkg-config,
5   libsecret,
6   cmake,
7   ninja,
8   qt6,
9   grpc,
10   protobuf,
11   zlib,
12   gtest,
13   sentry-native,
14   protonmail-bridge,
17 stdenv.mkDerivation (finalAttrs: {
18   pname = "protonmail-bridge-gui";
20   inherit (protonmail-bridge) version src;
22   patches = [
23     # Use `gtest` from Nixpkgs to allow an offline build
24     ./use-nix-googletest.patch
25   ];
27   nativeBuildInputs = [
28     pkg-config
29     cmake
30     ninja
31     qt6.qtbase
32     qt6.qtdeclarative
33     qt6.qtwayland
34     qt6.qtsvg
35     qt6.wrapQtAppsHook
36   ];
38   buildInputs = [
39     libsecret
40     grpc
41     protobuf
42     zlib
43     gtest
44     sentry-native
45   ];
47   sourceRoot = "${finalAttrs.src.name}/internal/frontend/bridge-gui";
49   postPatch = ''
50     # Bypass `vcpkg` by deleting lines that `include` BridgeSetup.cmake
51     find . -type f -name "CMakeLists.txt" -exec sed -i "/BridgeSetup\\.cmake/d" {} \;
53     # Use the available ICU version
54     sed -i "s/libicu\(i18n\|uc\|data\)\.so\.56/libicu\1.so/g" bridge-gui/DeployLinux.cmake
56     # Create a Desktop Entry that uses a `protonmail-bridge-gui` binary without upstream's launcher
57     sed "s/^\(Icon\|Exec\)=.*$/\1=protonmail-bridge-gui/" ../../../dist/proton-bridge.desktop > proton-bridge-gui.desktop
59     # Also update `StartupWMClass` to match the GUI binary's `wmclass` (Wayland app id)
60     sed -i "s/^\(StartupWMClass=\)Proton Mail Bridge$/\1ch.proton.bridge-gui/" proton-bridge-gui.desktop
62     # Don't build `bridge-gui-tester`
63     sed -i "/add_subdirectory(bridge-gui-tester)/d" CMakeLists.txt
64   '';
66   cmakeFlags = [
67     "-DBRIDGE_APP_FULL_NAME=Proton Mail Bridge"
68     "-DBRIDGE_VENDOR=Proton AG"
69     "-DBRIDGE_REVISION=${finalAttrs.src.rev}"
70     "-DBRIDGE_TAG=${finalAttrs.version}"
71     "-DBRIDGE_BUILD_ENV=Nix"
72     "-DBRIDGE_APP_VERSION=${finalAttrs.version}"
73   ];
75   installPhase = ''
76     runHook preInstall
78     # Install the GUI binary
79     install -Dm755 bridge-gui/bridge-gui $out/lib/bridge-gui
81     # Symlink the backend binary from the protonmail-bridge (CLI) package
82     ln -s ${protonmail-bridge}/bin/protonmail-bridge $out/lib/bridge
84     # Symlink the GUI binary
85     mkdir -p $out/bin
86     ln -s $out/lib/bridge-gui $out/bin/protonmail-bridge-gui
88     # Install desktop assets
89     install -Dm644 ../proton-bridge-gui.desktop -t $out/share/applications
90     install -Dm644 ../../../../dist/bridge.svg $out/share/icons/hicolor/scalable/apps/protonmail-bridge-gui.svg
92     runHook postInstall
93   '';
95   meta = {
96     changelog = "https://github.com/ProtonMail/proton-bridge/blob/${finalAttrs.src.rev}/Changelog.md";
97     description = "Qt-based GUI to use your ProtonMail account with your local e-mail client";
98     downloadPage = "https://github.com/ProtonMail/proton-bridge/releases";
99     homepage = "https://github.com/ProtonMail/proton-bridge";
100     license = lib.licenses.gpl3Plus;
101     longDescription = ''
102       Provides a GUI application that runs in the background and seamlessly encrypts
103       and decrypts your mail as it enters and leaves your computer.
105       To work, use secret-service freedesktop.org API (e.g. Gnome keyring) or pass.
106     '';
107     mainProgram = "protonmail-bridge-gui";
108     maintainers = with lib.maintainers; [ daniel-fahey ];
109     platforms = lib.platforms.linux;
110   };