lol
1{ buildGoModule
2, fetchFromGitHub
3, lib
4, wirelesstools
5, makeWrapper
6, wireguard-tools
7, openvpn
8, obfs4
9, iproute2
10, dnscrypt-proxy
11, iptables
12, gawk
13, util-linux
14}:
15
16builtins.mapAttrs (pname: attrs: buildGoModule (attrs // rec {
17 inherit pname;
18 version = "3.10.15";
19
20 src = fetchFromGitHub {
21 owner = "ivpn";
22 repo = "desktop-app";
23 rev = "v${version}";
24 hash = "sha256-3yVRVM98tVjot3gIkUb/CDwmwKdOOBjBjzGL6htDtpk=";
25 };
26
27 ldflags = [
28 "-s"
29 "-w"
30 "-X github.com/ivpn/desktop-app/daemon/version._version=${version}"
31 "-X github.com/ivpn/desktop-app/daemon/version._time=1970-01-01"
32 ];
33
34 postInstall = ''
35 mv $out/bin/{${attrs.modRoot},${pname}}
36 '';
37
38 meta = with lib; {
39 description = "Official IVPN Desktop app";
40 homepage = "https://www.ivpn.net/apps";
41 changelog = "https://github.com/ivpn/desktop-app/releases/tag/v${version}";
42 license = licenses.gpl3Only;
43 maintainers = with maintainers; [ urandom ataraxiasjel ];
44 mainProgram = "ivpn";
45 };
46})) {
47 ivpn = {
48 modRoot = "cli";
49 vendorHash = "sha256-T49AE3SUmdP3Tu9Sp5C/QryKDto/NzEqRuUQ3+aJFL0=";
50 };
51 ivpn-service = {
52 modRoot = "daemon";
53 vendorHash = "sha256-9Rk6ruMpyWtQe+90kw4F8OLq7/JcDSrG6ufkfcrS4W8=";
54 nativeBuildInputs = [ makeWrapper ];
55 buildInputs = [ wirelesstools ];
56
57 patches = [ ./permissions.patch ];
58 postPatch = ''
59 substituteInPlace daemon/service/platform/platform_linux.go \
60 --replace 'openVpnBinaryPath = "/usr/sbin/openvpn"' \
61 'openVpnBinaryPath = "${openvpn}/bin/openvpn"' \
62 --replace 'routeCommand = "/sbin/ip route"' \
63 'routeCommand = "${iproute2}/bin/ip route"'
64
65 substituteInPlace daemon/netinfo/netinfo_linux.go \
66 --replace 'retErr := shell.ExecAndProcessOutput(log, outParse, "", "/sbin/ip", "route")' \
67 'retErr := shell.ExecAndProcessOutput(log, outParse, "", "${iproute2}/bin/ip", "route")'
68
69 substituteInPlace daemon/service/platform/platform_linux_release.go \
70 --replace 'installDir := "/opt/ivpn"' "installDir := \"$out\"" \
71 --replace 'obfsproxyStartScript = path.Join(installDir, "obfsproxy/obfs4proxy")' \
72 'obfsproxyStartScript = "${obfs4}/bin/obfs4proxy"' \
73 --replace 'wgBinaryPath = path.Join(installDir, "wireguard-tools/wg-quick")' \
74 'wgBinaryPath = "${wireguard-tools}/bin/wg-quick"' \
75 --replace 'wgToolBinaryPath = path.Join(installDir, "wireguard-tools/wg")' \
76 'wgToolBinaryPath = "${wireguard-tools}/bin/wg"' \
77 --replace 'dnscryptproxyBinPath = path.Join(installDir, "dnscrypt-proxy/dnscrypt-proxy")' \
78 'dnscryptproxyBinPath = "${dnscrypt-proxy}/bin/dnscrypt-proxy"'
79 '';
80
81 postFixup = ''
82 mkdir -p $out/etc
83 cp -r $src/daemon/References/Linux/etc/* $out/etc/
84 cp -r $src/daemon/References/common/etc/* $out/etc/
85
86 patchShebangs --build $out/etc/firewall.sh $out/etc/splittun.sh $out/etc/client.down $out/etc/client.up
87
88 wrapProgram "$out/bin/ivpn-service" \
89 --suffix PATH : ${lib.makeBinPath [ iptables gawk util-linux ]}
90 '';
91 };
92}