Files
nixpkgs/pkgs/by-name/ex/expressvpn/package.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

116 lines
2.9 KiB
Nix

{
autoPatchelfHook,
buildFHSEnv,
dpkg,
fetchurl,
inotify-tools,
lib,
stdenvNoCC,
sysctl,
writeScript,
}:
let
pname = "expressvpn";
clientVersion = "3.52.0";
clientBuild = "2";
version = lib.strings.concatStringsSep "." [
clientVersion
clientBuild
];
expressvpnBase = stdenvNoCC.mkDerivation {
inherit pname version;
src = fetchurl {
url = "https://www.expressvpn.works/clients/linux/expressvpn_${version}-1_amd64.deb";
hash = "sha256-cDZ9R+MA3FXEto518bH4/c1X4W9XxgTvXns7zisylew=";
};
nativeBuildInputs = [
dpkg
autoPatchelfHook
];
dontConfigure = true;
dontBuild = true;
unpackPhase = ''
runHook preUnpack
dpkg --fsys-tarfile $src | tar --extract
runHook postUnpack
'';
installPhase = ''
runHook preInstall
mv usr/ $out/
runHook postInstall
'';
};
expressvpndFHS = buildFHSEnv {
inherit version;
pname = "expressvpnd";
# When connected, it directly creates/deletes resolv.conf to change the DNS entries.
# Since it's running in an FHS environment, it has no effect on actual resolv.conf.
# Hence, place a watcher that updates host resolv.conf when FHS resolv.conf changes.
# Mount the host's resolv.conf to the container's /etc/resolv.conf
runScript = writeScript "${pname}-wrapper" ''
mkdir -p /host/etc
[ -e /host/etc/resolv.conf ] || touch /host/etc/resolv.conf
mount --bind /etc/resolv.conf /host/etc/resolv.conf
mount -o remount,rw /host/etc/resolv.conf
trap "umount /host/etc/resolv.conf" EXIT
while inotifywait /etc 2>/dev/null;
do
cp /etc/resolv.conf /host/etc/resolv.conf;
done &
expressvpnd --client-version ${clientVersion} --client-build ${clientBuild}
'';
# expressvpnd binary has hard-coded the path /sbin/sysctl hence below workaround.
extraBuildCommands = ''
mkdir -p sbin
chmod +w sbin
ln -s ${sysctl}/bin/sysctl sbin/sysctl
'';
# The expressvpnd binary also uses hard-coded paths to the other binaries and files
# it ships with, hence the FHS environment.
targetPkgs =
pkgs: with pkgs; [
expressvpnBase
inotify-tools
iproute2
];
};
in
stdenvNoCC.mkDerivation {
inherit pname version;
dontUnpack = true;
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/bin $out/share
ln -s ${expressvpnBase}/bin/expressvpn $out/bin
ln -s ${expressvpndFHS}/bin/expressvpnd $out/bin
ln -s ${expressvpnBase}/share/{bash-completion,doc,man} $out/share/
runHook postInstall
'';
meta = with lib; {
description = "CLI client for ExpressVPN";
homepage = "https://www.expressvpn.com";
license = licenses.unfree;
platforms = [ "x86_64-linux" ];
maintainers = with maintainers; [ yureien ];
};
}