1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 python,
6 buildPythonPackage,
7 cargo,
8 rustPlatform,
9}:
10
11buildPythonPackage rec {
12 pname = "proton-vpn-local-agent";
13 version = "1.4.8";
14 pyproject = false;
15 withDistOutput = false;
16
17 src = fetchFromGitHub {
18 owner = "ProtonVPN";
19 repo = "python-proton-vpn-local-agent";
20 rev = version;
21 hash = "sha256-AHY2b0JaYaLhgnNkTsm9ERkw0s0NWnpbPAPgw+r2Gz4=";
22 };
23
24 cargoDeps = rustPlatform.fetchCargoVendor {
25 inherit
26 pname
27 version
28 src
29 sourceRoot
30 ;
31 hash = "sha256-zzUZsF0R0QGhxe4To6xSHYUVJTIDddf+UdTJg7E9Ef8=";
32 };
33
34 sourceRoot = "${src.name}/python-proton-vpn-local-agent";
35
36 cargoBuildType = "release";
37 nativeBuildInputs = [
38 cargo
39 rustPlatform.cargoSetupHook
40 rustPlatform.cargoBuildHook
41 ];
42
43 cargoCheckType = "release";
44 nativeCheckInputs = [
45 rustPlatform.cargoCheckHook
46 ];
47
48 installPhase = ''
49 runHook preInstall
50
51 # manually install the python binding
52 mkdir -p $out/${python.sitePackages}/proton/vpn/
53 cp ./target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/libpython_proton_vpn_local_agent.so $out/${python.sitePackages}/proton/vpn/local_agent.so
54
55 runHook postInstall
56 '';
57
58 pythonImportsCheck = [ "proton.vpn.local_agent" ];
59
60 meta = {
61 description = "Proton VPN local agent written in Rust with Python bindings";
62 homepage = "https://github.com/ProtonVPN/python-proton-vpn-local-agent";
63 license = lib.licenses.gpl3Only;
64 platforms = lib.platforms.linux;
65 maintainers = with lib.maintainers; [ sebtm ];
66 };
67}