nixpkgs/pkgs/applications/networking/mullvad/mullvad.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

106 lines
2.6 KiB
Nix
Raw Normal View History

{ lib
, stdenv
, rustPlatform
, fetchFromGitHub
, pkg-config
, protobuf
, makeWrapper
, git
, dbus
, libnftnl
, libmnl
, libwg
, enableOpenvpn ? true
, openvpn-mullvad
, shadowsocks-rust
2023-03-09 01:23:05 +00:00
, installShellFiles
}:
rustPlatform.buildRustPackage rec {
pname = "mullvad";
2023-12-28 05:58:51 +00:00
version = "2023.6";
src = fetchFromGitHub {
owner = "mullvad";
repo = "mullvadvpn-app";
rev = version;
2023-12-28 05:58:51 +00:00
hash = "sha256-O4YnHwG5GUDR7MzGsuLnElcczEct+P+4/Vn/eAoo6/s=";
};
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
2023-10-22 19:16:15 +00:00
"nix-0.26.1" = "sha256-b5bLeZVNbJE7aBnyzl0qvo0mXFeXa4hAZiuT1VJiFLk=";
"udp-over-tcp-0.3.0" = "sha256-5PeaM7/zhux1UdlaKpnQ2yIdmFy1n2weV/ux9lSRha4=";
};
};
nativeBuildInputs = [
pkg-config
protobuf
makeWrapper
git
2023-03-09 01:23:05 +00:00
installShellFiles
];
buildInputs = [
dbus.dev
libnftnl
libmnl
];
# talpid-core wants libwg.a in build/lib/{triple}
preBuild = ''
dest=build/lib/${stdenv.hostPlatform.config}
mkdir -p $dest
ln -s ${libwg}/lib/libwg.a $dest
'';
2023-03-09 01:23:05 +00:00
postInstall = ''
compdir=$(mktemp -d)
for shell in bash zsh fish; do
$out/bin/mullvad shell-completions $shell $compdir
done
installShellCompletion --cmd mullvad \
--bash $compdir/mullvad.bash \
--zsh $compdir/_mullvad \
--fish $compdir/mullvad.fish
'';
postFixup =
# Place all binaries in the 'mullvad-' namespace, even though these
# specific binaries aren't used in the lifetime of the program.
''
for bin in relay_list translations-converter tunnel-obfuscation; do
mv "$out/bin/$bin" "$out/bin/mullvad-$bin"
done
'' +
# Files necessary for OpenVPN tunnels to work.
lib.optionalString enableOpenvpn ''
mkdir -p $out/share/mullvad
cp dist-assets/ca.crt $out/share/mullvad
ln -s ${openvpn-mullvad}/bin/openvpn $out/share/mullvad
ln -s ${shadowsocks-rust}/bin/sslocal $out/share/mullvad
ln -s $out/lib/libtalpid_openvpn_plugin.so $out/share/mullvad
'' +
# Set the directory where Mullvad will look for its resources by default to
# `$out/share`, so that we can avoid putting the files in `$out/bin` --
# Mullvad defaults to looking inside the directory its binary is located in
# for its resources.
''
wrapProgram $out/bin/mullvad-daemon \
--set-default MULLVAD_RESOURCE_DIR "$out/share/mullvad"
'';
passthru = {
inherit libwg;
inherit openvpn-mullvad;
};
meta = with lib; {
description = "Mullvad VPN command-line client tools";
homepage = "https://github.com/mullvad/mullvadvpn-app";
license = licenses.gpl3Only;
maintainers = with maintainers; [ cole-h ];
};
}