1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 gobject-introspection,
6 apt,
7 iproute2,
8 setuptools,
9 networkmanager,
10 proton-core,
11 proton-vpn-api-core,
12 proton-vpn-local-agent,
13 pycairo,
14 pygobject3,
15 pytest-asyncio,
16 pytestCheckHook,
17 pytest-cov-stub,
18}:
19
20buildPythonPackage rec {
21 pname = "proton-vpn-network-manager";
22 version = "0.10.1";
23 pyproject = true;
24
25 src = fetchFromGitHub {
26 owner = "ProtonVPN";
27 repo = "python-proton-vpn-network-manager";
28 rev = "refs/tags/v${version}";
29 hash = "sha256-zS/H7efEJlvDlcoxil6pd6lFLdLRAV7Bmr/ngtZ8Nuc";
30 };
31
32 nativeBuildInputs = [
33 # Needed to recognize the NM namespace
34 gobject-introspection
35 ];
36
37 build-system = [
38 setuptools
39 ];
40
41 dependencies = [
42 # Needed here for the NM namespace
43 networkmanager
44 proton-core
45 proton-vpn-api-core
46 proton-vpn-local-agent
47 pycairo
48 pygobject3
49 ];
50
51 postPatch = ''
52 substituteInPlace proton/vpn/backend/linux/networkmanager/killswitch/wireguard/killswitch_connection_handler.py \
53 --replace '/usr/sbin/ip' '${iproute2}/bin/ip'
54 substituteInPlace proton/vpn/backend/linux/networkmanager/killswitch/wireguard/wgkillswitch.py \
55 --replace '/usr/bin/apt' '${apt}/bin/apt'
56 '';
57
58 pythonImportsCheck = [
59 "proton.vpn.backend.linux.networkmanager"
60 "proton.vpn.backend.linux.networkmanager.killswitch.default"
61 "proton.vpn.backend.linux.networkmanager.killswitch.wireguard"
62 ];
63
64 nativeCheckInputs = [
65 pytestCheckHook
66 pytest-cov-stub
67 pytest-asyncio
68 ];
69
70 preCheck = ''
71 # Needed for Permission denied: '/homeless-shelter'
72 export HOME=$(mktemp -d)
73 '';
74
75 meta = {
76 description = "Provides the necessary functionality for other ProtonVPN components to interact with NetworkManager";
77 homepage = "https://github.com/ProtonVPN/python-proton-vpn-network-manager";
78 license = lib.licenses.gpl3Only;
79 platforms = lib.platforms.linux;
80 maintainers = with lib.maintainers; [ sebtm ];
81 };
82}