2022-09-21 08:29:54 +02:00
|
|
|
{ lib, fetchFromGitHub, symlinkJoin, buildGoModule, makeWrapper, nixosTests
|
|
|
|
, nix-update-script
|
|
|
|
, v2ray-geoip, v2ray-domain-list-community
|
|
|
|
, assets ? [ v2ray-geoip v2ray-domain-list-community ]
|
2020-09-07 21:23:12 +02:00
|
|
|
}:
|
2019-10-02 21:05:07 +02:00
|
|
|
|
2022-09-21 08:29:54 +02:00
|
|
|
buildGoModule rec {
|
|
|
|
pname = "v2ray-core";
|
2023-02-09 16:54:21 +01:00
|
|
|
version = "5.3.0";
|
2019-10-02 21:05:07 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2020-11-09 18:08:43 +01:00
|
|
|
owner = "v2fly";
|
2019-10-02 21:05:07 +02:00
|
|
|
repo = "v2ray-core";
|
|
|
|
rev = "v${version}";
|
2023-02-09 16:54:21 +01:00
|
|
|
hash = "sha256-LLvAoPA3rLGfhrWD37OVyWd4tC9mwgpE1WjK2pY27xU=";
|
2019-10-02 21:05:07 +02:00
|
|
|
};
|
|
|
|
|
2022-09-21 08:29:54 +02:00
|
|
|
# `nix-update` doesn't support `vendorHash` yet.
|
|
|
|
# https://github.com/Mic92/nix-update/pull/95
|
2023-02-09 16:54:21 +01:00
|
|
|
vendorSha256 = "sha256-xBNVyPN9PRkraPRzZXOguGemYPm+Jw8hl04vWV8TZaA=";
|
2020-07-08 19:14:28 +02:00
|
|
|
|
2022-09-21 08:29:54 +02:00
|
|
|
ldflags = [ "-s" "-w" "-buildid=" ];
|
2020-09-07 21:23:12 +02:00
|
|
|
|
2022-09-21 08:29:54 +02:00
|
|
|
subPackages = [ "main" ];
|
2020-09-07 21:23:12 +02:00
|
|
|
|
2022-09-21 08:29:54 +02:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2020-09-07 21:23:12 +02:00
|
|
|
|
2022-09-21 08:29:54 +02:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
install -Dm555 "$GOPATH"/bin/main $out/bin/v2ray
|
|
|
|
install -Dm444 release/config/systemd/system/v2ray{,@}.service -t $out/lib/systemd/system
|
|
|
|
install -Dm444 release/config/*.json -t $out/etc/v2ray
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
2020-11-09 18:08:43 +01:00
|
|
|
|
2022-09-21 08:29:54 +02:00
|
|
|
assetsDrv = symlinkJoin {
|
|
|
|
name = "v2ray-assets";
|
|
|
|
paths = assets;
|
2020-09-07 21:23:12 +02:00
|
|
|
};
|
|
|
|
|
2022-09-21 08:29:54 +02:00
|
|
|
postFixup = ''
|
|
|
|
wrapProgram $out/bin/v2ray \
|
|
|
|
--suffix XDG_DATA_DIRS : $assetsDrv/share
|
|
|
|
substituteInPlace $out/lib/systemd/system/*.service \
|
|
|
|
--replace User=nobody DynamicUser=yes \
|
|
|
|
--replace /usr/local/bin/ $out/bin/ \
|
|
|
|
--replace /usr/local/etc/ /etc/
|
|
|
|
'';
|
2020-09-07 21:23:12 +02:00
|
|
|
|
|
|
|
passthru = {
|
2022-12-25 23:11:14 +01:00
|
|
|
updateScript = nix-update-script { };
|
2022-09-21 08:29:54 +02:00
|
|
|
tests.simple-vmess-proxy-test = nixosTests.v2ray;
|
2020-09-07 21:23:12 +02:00
|
|
|
};
|
|
|
|
|
2022-09-21 08:29:54 +02:00
|
|
|
meta = {
|
|
|
|
homepage = "https://www.v2fly.org/en_US/";
|
|
|
|
description = "A platform for building proxies to bypass network restrictions";
|
|
|
|
license = with lib.licenses; [ mit ];
|
|
|
|
maintainers = with lib.maintainers; [ servalcatty ];
|
|
|
|
};
|
|
|
|
}
|