1{
2 rustPlatform,
3 glib-networking,
4 gpauth,
5 makeWrapper,
6 openconnect,
7 openssl,
8 perl,
9 pkg-config,
10 vpnc-scripts,
11 fetchFromGitHub,
12}:
13
14rustPlatform.buildRustPackage rec {
15 pname = "gpclient";
16 version = "2.4.1";
17
18 src = fetchFromGitHub {
19 owner = "yuezk";
20 repo = "GlobalProtect-openconnect";
21 rev = "v${version}";
22 hash = "sha256-MY4JvftrC6sR8M0dFvnGZOkvHIhPRcyct9AG/8527gw=";
23 };
24
25 inherit (gpauth) meta;
26
27 buildAndTestSubdir = "apps/gpclient";
28
29 cargoHash = "sha256-8LSGuRnWRWeaY6t25GdZ2y4hGIJ+mP3UBXRjcvPuD6U=";
30
31 nativeBuildInputs = [
32 perl
33 makeWrapper
34 pkg-config
35 ];
36 buildInputs = [
37 gpauth
38 openconnect
39 openssl
40 glib-networking
41 ];
42
43 preConfigure = ''
44 substituteInPlace crates/gpapi/src/lib.rs \
45 --replace-fail /usr/bin/gpauth ${gpauth}/bin/gpauth
46 substituteInPlace crates/common/src/vpn_utils.rs \
47 --replace-fail /usr/sbin/vpnc-script ${vpnc-scripts}/bin/vpnc-script
48 '';
49
50 postInstall = ''
51 mkdir -p $out/share/applications
52 cp packaging/files/usr/share/applications/gpgui.desktop $out/share/applications/gpgui.desktop
53 '';
54
55 preFixup = ''
56 wrapProgram "$out/bin/gpclient" \
57 --prefix GIO_EXTRA_MODULES : ${glib-networking}/lib/gio/modules
58 '';
59
60 postFixup = ''
61 substituteInPlace $out/share/applications/gpgui.desktop \
62 --replace-fail /usr/bin/gpclient gpclient
63 '';
64}