2019-01-14 11:22:42 +00:00
|
|
|
{ stdenv, lib, fetchFromGitHub, makeWrapper, coreutils
|
|
|
|
, openvpn, python, dialog, wget, update-resolv-conf }:
|
|
|
|
|
|
|
|
let
|
|
|
|
expectedUpdateResolvPath = "/etc/openvpn/update-resolv-conf";
|
|
|
|
actualUpdateResolvePath = "${update-resolv-conf}/libexec/openvpn/update-resolv-conf";
|
|
|
|
|
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
name = "protonvpn-cli";
|
|
|
|
version = "1.1.2";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ProtonVPN";
|
|
|
|
repo = "protonvpn-cli";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "0xvflr8zf267n3dv63nkk4wjxhbckw56sqmyca3krf410vrd7zlv";
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p "$out/bin"
|
|
|
|
substituteInPlace protonvpn-cli.sh \
|
|
|
|
--replace ${expectedUpdateResolvPath} ${actualUpdateResolvePath} \
|
|
|
|
--replace \$UID 0 \
|
|
|
|
--replace /etc/resolv.conf /dev/null \
|
|
|
|
--replace \
|
|
|
|
" echo \"Connecting...\"" \
|
|
|
|
" sed -ri 's@${expectedUpdateResolvPath}@${actualUpdateResolvePath}@g' \"\$openvpn_config\"; echo \"Connecting...\""
|
|
|
|
cp protonvpn-cli.sh "$out/bin/protonvpn-cli"
|
2019-09-17 10:38:55 +00:00
|
|
|
wrapProgram $out/bin/protonvpn-cli \
|
2019-01-14 11:22:42 +00:00
|
|
|
--prefix PATH : ${lib.makeBinPath [ coreutils openvpn python dialog wget update-resolv-conf ]}
|
2019-09-17 10:38:55 +00:00
|
|
|
ln -s "$out/bin/protonvpn-cli" "$out/bin/pvpn"
|
2019-01-14 11:22:42 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "ProtonVPN Command-Line Tool";
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://github.com/ProtonVPN/protonvpn-cli";
|
2019-01-14 11:22:42 +00:00
|
|
|
maintainers = with maintainers; [ caugner ];
|
|
|
|
license = licenses.mit;
|
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|