2022-01-28 16:44:01 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, writeText
|
|
|
|
, rustPlatform
|
|
|
|
, fetchFromGitHub
|
2023-02-25 21:55:19 +00:00
|
|
|
, fetchpatch
|
2022-01-28 16:44:01 +00:00
|
|
|
, pkg-config
|
|
|
|
, protobuf
|
|
|
|
, makeWrapper
|
2023-01-18 22:34:39 +00:00
|
|
|
, git
|
2022-01-28 16:44:01 +00:00
|
|
|
, dbus
|
|
|
|
, libnftnl
|
|
|
|
, libmnl
|
|
|
|
, libwg
|
2023-02-25 22:01:40 +00:00
|
|
|
, enableOpenvpn ? true
|
2022-03-26 12:55:54 +00:00
|
|
|
, openvpn-mullvad
|
2022-03-26 19:05:21 +00:00
|
|
|
, shadowsocks-rust
|
2022-01-28 16:44:01 +00:00
|
|
|
}:
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "mullvad";
|
2023-02-25 21:55:19 +00:00
|
|
|
version = "2023.1";
|
2022-01-28 16:44:01 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "mullvad";
|
|
|
|
repo = "mullvadvpn-app";
|
|
|
|
rev = version;
|
2023-02-25 21:55:19 +00:00
|
|
|
hash = "sha256-BoduliiDOpzEPYHAjr636e7DbrhFnC/v9au6Mp9T/Qs=";
|
2022-01-28 16:44:01 +00:00
|
|
|
};
|
|
|
|
|
2023-02-25 21:55:19 +00:00
|
|
|
cargoHash = "sha256-5kK2IA0Z1dQbHlnGXNZHD+BycurshfpqrwcIEveWKT0=";
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
# https://github.com/mullvad/mullvadvpn-app/pull/4389
|
|
|
|
# can be removed after next release
|
|
|
|
(fetchpatch {
|
|
|
|
name = "mullvad-version-dont-check-git.patch";
|
|
|
|
url = "https://github.com/mullvad/mullvadvpn-app/commit/8062cc74fc94bbe073189e78328901606c859d41.patch";
|
|
|
|
hash = "sha256-1BhCId0J1dxhPM3oOmhZB+07N+k1GlvAT1h6ayfx174=";
|
|
|
|
})
|
|
|
|
];
|
2022-01-28 16:44:01 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
pkg-config
|
|
|
|
protobuf
|
|
|
|
makeWrapper
|
2023-01-18 22:34:39 +00:00
|
|
|
git
|
2022-01-28 16:44:01 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
dbus.dev
|
|
|
|
libnftnl
|
|
|
|
libmnl
|
|
|
|
];
|
|
|
|
|
|
|
|
# talpid-core wants libwg.a in build/lib/{triple}
|
|
|
|
preBuild = ''
|
|
|
|
dest=build/lib/${stdenv.targetPlatform.config}
|
|
|
|
mkdir -p $dest
|
|
|
|
ln -s ${libwg}/lib/libwg.a $dest
|
|
|
|
'';
|
|
|
|
|
|
|
|
postFixup =
|
|
|
|
# Place all binaries in the 'mullvad-' namespace, even though these
|
|
|
|
# specific binaries aren't used in the lifetime of the program.
|
|
|
|
''
|
2023-02-25 21:55:19 +00:00
|
|
|
for bin in relay_list translations-converter tunnel-obfuscation; do
|
2022-01-28 16:44:01 +00:00
|
|
|
mv "$out/bin/$bin" "$out/bin/mullvad-$bin"
|
|
|
|
done
|
|
|
|
'' +
|
2022-03-26 19:05:21 +00:00
|
|
|
# Files necessary for OpenVPN tunnels to work.
|
2023-02-25 22:01:40 +00:00
|
|
|
lib.optionalString enableOpenvpn ''
|
2022-07-04 23:04:45 +00:00
|
|
|
mkdir -p $out/share/mullvad
|
2022-03-26 19:05:21 +00:00
|
|
|
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
|
2022-01-28 16:44:01 +00:00
|
|
|
'' +
|
|
|
|
# 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"
|
|
|
|
'';
|
|
|
|
|
2022-03-26 19:05:21 +00:00
|
|
|
passthru = {
|
|
|
|
inherit libwg;
|
|
|
|
inherit openvpn-mullvad;
|
|
|
|
};
|
2022-03-26 12:55:54 +00:00
|
|
|
|
2022-01-28 16:44:01 +00:00
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
}
|