nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 aiohttp,
6 cryptography,
7 distro,
8 fido2,
9 gobject-introspection,
10 iproute2,
11 jinja2,
12 networkmanager,
13 proton-core,
14 proton-vpn-local-agent,
15 pycairo,
16 pygobject3,
17 pynacl,
18 pyopenssl,
19 pytest-asyncio,
20 pytest-cov-stub,
21 pytestCheckHook,
22 pyxdg,
23 requests,
24 sentry-sdk,
25 setuptools,
26}:
27
28buildPythonPackage rec {
29 pname = "proton-vpn-api-core";
30 version = "4.14.3";
31 pyproject = true;
32
33 src = fetchFromGitHub {
34 owner = "ProtonVPN";
35 repo = "python-proton-vpn-api-core";
36 rev = "v${version}";
37 hash = "sha256-yWiUiR0us+ISa9cdjfN4IzlbiZEzUlndNFy/BpfHYqk=";
38 };
39
40 postPatch = ''
41 substituteInPlace proton/vpn/backend/networkmanager/killswitch/wireguard/killswitch_connection_handler.py \
42 --replace-fail '["/usr/sbin/ip", "route"]' '["${iproute2}/bin/ip", "route"]'
43 '';
44
45 nativeBuildInputs = [
46 # Needed to recognize the NM namespace
47 gobject-introspection
48 ];
49
50 propagatedBuildInputs = [
51 # Needed here for the NM namespace
52 networkmanager
53 ];
54
55 build-system = [
56 setuptools
57 ];
58
59 dependencies = [
60 cryptography
61 distro
62 fido2
63 jinja2
64 proton-core
65 proton-vpn-local-agent
66 pycairo
67 pygobject3
68 pynacl
69 pyxdg
70 sentry-sdk
71 ];
72
73 pythonImportsCheck = [
74 "proton.vpn.backend.networkmanager.core"
75 "proton.vpn.backend.networkmanager.killswitch.default"
76 "proton.vpn.backend.networkmanager.killswitch.wireguard"
77 "proton.vpn.backend.networkmanager.protocol.openvpn"
78 "proton.vpn.backend.networkmanager.protocol.wireguard"
79 "proton.vpn.connection"
80 "proton.vpn.core"
81 "proton.vpn.killswitch.interface"
82 "proton.vpn.logging"
83 "proton.vpn.session"
84 "proton.vpn.split_tunneling"
85 ];
86
87 nativeCheckInputs = [
88 aiohttp
89 pyopenssl
90 pytest-asyncio
91 requests
92 pytestCheckHook
93 pytest-cov-stub
94 ];
95
96 # Needed for `pythonImportsCheck`, `postInstall` happens between `pythonImportsCheckPhase` and `pytestCheckPhase`.
97 postInstall = ''
98 # Needed for Permission denied: '/homeless-shelter'
99 export HOME=$(mktemp -d)
100 export XDG_RUNTIME_DIR=$(mktemp -d)
101 '';
102
103 disabledTests = [
104 # Permission denied: '/run'
105 "test_ensure_configuration_file_is_created"
106 "test_ovpnconfig_with_certificate"
107 "test_ovpnconfig_with_settings"
108 "test_wireguard_config_content_generation"
109 "test_wireguard_with_non_certificate"
110 "test_ensure_generate_is_returning_expected_content"
111 "test_ensure_same_configuration_file_in_case_of_duplicate"
112 "test_ensure_configuration_file_is_deleted"
113 ];
114
115 meta = {
116 description = "Acts as a facade to the other Proton VPN components, exposing a uniform API to the available Proton VPN services";
117 homepage = "https://github.com/ProtonVPN/python-proton-vpn-api-core";
118 license = lib.licenses.gpl3Only;
119 platforms = lib.platforms.linux;
120 maintainers = with lib.maintainers; [
121 anthonyroussel
122 sebtm
123 rapiteanu
124 ];
125 };
126}