From 5ed6db229273104fc6114c09ca547a427648897c Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Mon, 14 Jan 2019 12:22:42 +0100 Subject: [PATCH] protonvpn-cli: init at 1.1.2 --- .../networking/protonvpn-cli/default.nix | 46 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 48 insertions(+) create mode 100644 pkgs/applications/networking/protonvpn-cli/default.nix diff --git a/pkgs/applications/networking/protonvpn-cli/default.nix b/pkgs/applications/networking/protonvpn-cli/default.nix new file mode 100644 index 000000000000..e79ca515b518 --- /dev/null +++ b/pkgs/applications/networking/protonvpn-cli/default.nix @@ -0,0 +1,46 @@ +{ 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" + ln -s "$out/bin/protonvpn-cli" "$out/bin/pvpn" + ''; + + postInstallPhase = '' + wrapProgram $out/protonvpn-cli \ + --prefix PATH : ${lib.makeBinPath [ coreutils openvpn python dialog wget update-resolv-conf ]} + ''; + + meta = with stdenv.lib; { + description = "ProtonVPN Command-Line Tool"; + homepage = https://github.com/ProtonVPN/protonvpn-cli; + maintainers = with maintainers; [ caugner ]; + license = licenses.mit; + platforms = platforms.unix; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 092fefd429e1..707066144132 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -18791,6 +18791,8 @@ in protonmail-bridge = libsForQt5.callPackage ../applications/networking/protonmail-bridge { }; + protonvpn-cli = callPackage ../applications/networking/protonvpn-cli { }; + psi = callPackage ../applications/networking/instant-messengers/psi { }; psi-plus = callPackage ../applications/networking/instant-messengers/psi-plus { };