@@ -0,0 +1,86 @@
1+{ lib, fetchFromGitHub, makeDesktopItem, makeWrapper, imagemagick
2+, python3Packages, wrapGAppsHook, protonvpn-cli, gtk3, pango
3+, gobject-introspection, libnotify, libappindicator-gtk3
4+, procps, openvpn }:
5+
6+let
7+ extraPath = lib.makeBinPath [ procps openvpn ];
8+
9+in python3Packages.buildPythonApplication rec {
10+ pname = "protonvpn-linux-gui";
11+ version = "2.1.1";
12+
13+ src = fetchFromGitHub {
14+ owner = "protonvpn";
15+ repo = "linux-gui";
16+ rev = "v${version}";
17+ sha256 = "avo5/2eq53HSHCnnjtxrsmpURtHvxmLZn2BxActImGY=";
18+ };
19+
20+ desktopItem = makeDesktopItem {
21+ name = "ProtonVPN";
22+ desktopName = "ProtonVPN GUI";
23+ type = "Application";
24+ exec = "protonvpn-gui";
25+ icon = "protonvpn";
26+ categories = "Network;";
27+ terminal = "false";
28+ };
29+
30+ trayDesktopItem = makeDesktopItem {
31+ name = "ProtonVPN Tray";
32+ desktopName = "ProtonVPN Tray";
33+ type = "Application";
34+ exec = "protonvpn-tray";
35+ icon = "protonvpn";
36+ categories = "Network;";
37+ terminal = "false";
38+ };
39+
40+ nativeBuildInputs = [ wrapGAppsHook makeWrapper imagemagick ];
41+
42+ propagatedBuildInputs = (with python3Packages; [
43+ pygobject3
44+ pycairo
45+ requests
46+ configparser
47+ ]) ++ [
48+ protonvpn-cli
49+ gtk3
50+ gobject-introspection
51+ libnotify
52+ libappindicator-gtk3
53+ ];
54+
55+ prePatch = ''
56+ # if pkexec is used, we want to have more time to enter password
57+ substituteInPlace linux_gui/services/login_service.py --replace 'timeout=8' 'timeout=30'
58+ '';
59+
60+ postInstall = ''
61+ # wrap binaries with extra required path
62+ wrapProgram "$out/bin/protonvpn-tray" --prefix PATH ":" ${extraPath}
63+ wrapProgram "$out/bin/protonvpn-gui" --prefix PATH ":" ${extraPath}
64+
65+ # install desktop files
66+ mkdir -p $out/share/applications
67+ cp "$desktopItem/share/applications/ProtonVPN.desktop" $out/share/applications/protonvpn-gui.desktop
68+ cp "$trayDesktopItem/share/applications/ProtonVPN Tray.desktop" $out/share/applications/protonvpn-tray.desktop
69+
70+ # create icons
71+ for size in 16 32 48 64 72 96 128 192 512 1024; do
72+ mkdir -p $out/share/icons/hicolor/"$size"x"$size"/apps
73+ convert -resize "$size"x"$size" \
74+ linux_gui/resources/img/logo/protonvpn_logo.png \
75+ $out/share/icons/hicolor/"$size"x"$size"/apps/protonvpn.png
76+ done
77+ '';
78+
79+ meta = with lib; {
80+ description = "Linux GUI for ProtonVPN, written in Python.";
81+ homepage = "https://github.com/ProtonVPN/linux-gui";
82+ maintainers = with maintainers; [ offline ];
83+ license = licenses.gpl3;
84+ platforms = platforms.linux;
85+ };
86+}