Unverified Commit bf52bbba authored by Kevin Cox's avatar Kevin Cox Committed by GitHub
Browse files

Merge pull request #142637 from WolfangAukang/protonvpn

protonvpn-gui: build new official client
parents 3130c88e 35278505
Loading
Loading
Loading
Loading
+31 −67
Original line number Diff line number Diff line
{ lib, fetchFromGitHub, makeDesktopItem, makeWrapper, imagemagick
, python3Packages, wrapGAppsHook, protonvpn-cli, gtk3, pango
, gobject-introspection, libnotify, libappindicator-gtk3
, procps, openvpn }:
{ lib, fetchFromGitHub, gobject-introspection, imagemagick,
wrapGAppsHook, python3Packages, gtk3, networkmanager, webkitgtk }:

let
  extraPath = lib.makeBinPath [ procps openvpn ];

in python3Packages.buildPythonApplication rec {
python3Packages.buildPythonApplication rec {
  pname = "protonvpn-linux-gui";
  version = "2.1.1";
  version = "1.4.1";

  src = fetchFromGitHub {
    owner = "protonvpn";
    repo = "linux-gui";
    rev = "v${version}";
    sha256 = "avo5/2eq53HSHCnnjtxrsmpURtHvxmLZn2BxActImGY=";
  };

  desktopItem = makeDesktopItem {
    name = "ProtonVPN";
    desktopName = "ProtonVPN GUI";
    type = "Application";
    exec = "protonvpn-gui";
    icon = "protonvpn";
    categories = "Network;";
    terminal = "false";
  };

  trayDesktopItem = makeDesktopItem {
    name = "ProtonVPN Tray";
    desktopName = "ProtonVPN Tray";
    type = "Application";
    exec = "protonvpn-tray";
    icon = "protonvpn";
    categories = "Network;";
    terminal = "false";
    owner = "ProtonVPN";
    repo = "linux-app";
    rev = version;
    sha256 = "sha256-08gXEKm8udgNltRdqvAMFL0pDCWZu/kfl1xGQtZPBCc=";
  };

  nativeBuildInputs = [ wrapGAppsHook makeWrapper imagemagick ];
  strictDeps = false;

  propagatedBuildInputs = (with python3Packages; [
      pygobject3
      pycairo
      requests
      configparser
    ]) ++ [
      protonvpn-cli
      gtk3
      gobject-introspection
      libnotify
      libappindicator-gtk3
  nativeBuildInputs = [
    gobject-introspection imagemagick wrapGAppsHook
  ];

  prePatch = ''
    # if pkexec is used, we want to have more time to enter password
    substituteInPlace linux_gui/services/login_service.py --replace 'timeout=8' 'timeout=30'
  '';

  postInstall = ''
    # wrap binaries with extra required path
    wrapProgram "$out/bin/protonvpn-tray" --prefix PATH ":" ${extraPath}
    wrapProgram "$out/bin/protonvpn-gui" --prefix PATH ":" ${extraPath}
  propagatedBuildInputs = with python3Packages; [
    protonvpn-nm-lib
    psutil
  ];

    # install desktop files
    mkdir -p $out/share/applications
    cp "$desktopItem/share/applications/ProtonVPN.desktop" $out/share/applications/protonvpn-gui.desktop
    cp "$trayDesktopItem/share/applications/ProtonVPN Tray.desktop" $out/share/applications/protonvpn-tray.desktop
  buildInputs = [
    gtk3 networkmanager webkitgtk
  ];

    # create icons
  postFixup = ''
    # Setting icons
    for size in 16 32 48 64 72 96 128 192 512 1024; do
      mkdir -p $out/share/icons/hicolor/"$size"x"$size"/apps
      convert -resize "$size"x"$size" \
        linux_gui/resources/img/logo/protonvpn_logo.png \
        $out/share/icons/hicolor/"$size"x"$size"/apps/protonvpn.png
      convert -resize $size'x'$size \
        protonvpn_gui/assets/icons/protonvpn-logo.png \
        $out/share/icons/hicolor/$size'x'$size/apps/protonvpn.png
    done

    install -Dm644 protonvpn.desktop -t $out/share/applications/
    substituteInPlace $out/share/applications/protonvpn.desktop \
      --replace 'protonvpn-logo' protonvpn
  '';

  # no tests
  # Project has a dummy test
  doCheck = false;

  meta = with lib; {
    description = "Linux GUI for ProtonVPN, written in Python";
    homepage = "https://github.com/ProtonVPN/linux-gui";
    maintainers = with maintainers; [ offline ];
    homepage = "https://github.com/ProtonVPN/linux-app";
    maintainers = with maintainers; [ offline wolfangaukang ];
    license = licenses.gpl3Plus;
    platforms = platforms.linux;
    mainProgram = "protonvpn-gui";
  };
}
+50 −0
Original line number Diff line number Diff line
{ lib
, buildPythonPackage
, fetchFromGitHub
, pythonOlder
, bcrypt
, pyopenssl
, python-gnupg
, requests
, openssl
}:

buildPythonPackage rec {
  pname = "proton-client";
  version = "0.7.0";
  disabled = pythonOlder "3.7";

  src = fetchFromGitHub {
    owner = "ProtonMail";
    repo = "proton-python-client";
    rev = version;
    sha256 = "sha256-98tEL3DUYtx27JcI6pPFS2iDJXS8K3yyvCU9UVrg1EM=";
  };

  propagatedBuildInputs = [
    bcrypt
    pyopenssl
    python-gnupg
    requests
  ];

  buildInputs = [ openssl ];

  # This patch is supposed to indicate where to load OpenSSL library,
  # but it is not working as intended.
  #patchPhase = ''
  #  substituteInPlace proton/srp/_ctsrp.py --replace \
  #    "ctypes.cdll.LoadLibrary('libssl.so.10')" "'${openssl.out}/lib/libssl.so'"
  #'';
  # Regarding the issue above, I'm disabling tests for now
  doCheck = false;

  pythonImportsCheck = [ "proton" ];

  meta = with lib; {
    description = "Python Proton client module";
    homepage = "https://github.com/ProtonMail/proton-python-client";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ wolfangaukang ];
  };
}
+47 −0
Original line number Diff line number Diff line
{ lib
, buildPythonPackage
, fetchFromGitHub
, pythonOlder
, distro
, jinja2
, keyring
, proton-client
, pygobject3
, pyxdg
, systemd
}:

buildPythonPackage rec {
  pname = "protonvpn-nm-lib";
  version = "3.5.0";
  disabled = pythonOlder "3.7";

  src = fetchFromGitHub {
    owner = "ProtonVPN";
    repo = pname;
    rev = version;
    sha256 = "sha256-E75toza++l5UFdOLGgolH8pL5xvoUkLE7u+8L5RDFbI=";
  };

  propagatedBuildInputs = [
    distro
    jinja2
    keyring
    proton-client
    pygobject3
    pyxdg
    systemd
  ];

  # Project has a dummy test.
  doCheck = false;

  pythonImportsCheck = [ "protonvpn_nm_lib" ];

  meta = with lib; {
    description = "ProtonVPN NetworkManager Library intended for every ProtonVPN service user";
    homepage = "https://github.com/ProtonVPN/protonvpn-nm-lib";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ wolfangaukang ];
  };
}
+4 −0
Original line number Diff line number Diff line
@@ -5948,8 +5948,12 @@ in {

  protobuf3-to-dict = callPackage ../development/python-modules/protobuf3-to-dict { };

  proton-client = callPackage ../development/python-modules/proton-client { };

  protonup = callPackage ../development/python-modules/protonup { };

  protonvpn-nm-lib = callPackage ../development/python-modules/protonvpn-nm-lib { };

  prov = callPackage ../development/python-modules/prov { };

  prox-tv = callPackage ../development/python-modules/prox-tv { };