2021-12-14 08:13:01 +00:00
|
|
|
{ lib, fetchFromGitHub, fetchurl, symlinkJoin, buildGoModule, runCommand, makeWrapper, nixosTests
|
|
|
|
, v2ray-geoip, v2ray-domain-list-community, assets ? [ v2ray-geoip v2ray-domain-list-community ]
|
2020-09-07 19:23:12 +00:00
|
|
|
}:
|
2019-10-02 19:05:07 +00:00
|
|
|
|
2020-09-07 19:23:12 +00:00
|
|
|
let
|
2021-12-19 23:47:51 +00:00
|
|
|
version = "4.44.0";
|
2019-10-02 19:05:07 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2020-11-09 17:08:43 +00:00
|
|
|
owner = "v2fly";
|
2019-10-02 19:05:07 +00:00
|
|
|
repo = "v2ray-core";
|
|
|
|
rev = "v${version}";
|
2021-12-19 23:47:51 +00:00
|
|
|
sha256 = "1yk02n2lllbcwqkz4f3l3d2df1w3m768zxvdawgmafjgmbqf0gjf";
|
2019-10-02 19:05:07 +00:00
|
|
|
};
|
|
|
|
|
2022-01-10 00:06:47 +00:00
|
|
|
vendorSha256 = "sha256-kTwISKPIFpb/OPh9rIzLH8a6mqpyDBJo2stSu5bc02Q=";
|
2020-07-08 17:14:28 +00:00
|
|
|
|
2021-12-14 08:13:01 +00:00
|
|
|
assetsDrv = symlinkJoin {
|
|
|
|
name = "v2ray-assets";
|
|
|
|
paths = assets;
|
|
|
|
};
|
2020-09-07 19:23:12 +00:00
|
|
|
|
|
|
|
core = buildGoModule rec {
|
|
|
|
pname = "v2ray-core";
|
|
|
|
inherit version src;
|
|
|
|
|
|
|
|
inherit vendorSha256;
|
|
|
|
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
buildPhase = ''
|
2021-01-08 19:23:06 +00:00
|
|
|
buildFlagsArray=(-v -p $NIX_BUILD_CORES -ldflags="-s -w")
|
2020-09-07 19:23:12 +00:00
|
|
|
runHook preBuild
|
2021-01-08 19:23:06 +00:00
|
|
|
go build "''${buildFlagsArray[@]}" -o v2ray ./main
|
|
|
|
go build "''${buildFlagsArray[@]}" -o v2ctl -tags confonly ./infra/control/main
|
2020-09-07 19:23:12 +00:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
install -Dm755 v2ray v2ctl -t $out/bin
|
|
|
|
'';
|
2020-11-09 17:08:43 +00:00
|
|
|
|
|
|
|
meta = {
|
2020-12-07 16:05:33 +00:00
|
|
|
homepage = "https://www.v2fly.org/en_US/";
|
2020-11-09 17:08:43 +00:00
|
|
|
description = "A platform for building proxies to bypass network restrictions";
|
2020-12-07 16:05:33 +00:00
|
|
|
license = with lib.licenses; [ mit ];
|
2020-11-09 17:08:43 +00:00
|
|
|
maintainers = with lib.maintainers; [ servalcatty ];
|
|
|
|
};
|
2020-09-07 19:23:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
in runCommand "v2ray-${version}" {
|
2021-03-08 18:18:07 +00:00
|
|
|
inherit src version;
|
2020-11-09 17:08:43 +00:00
|
|
|
inherit (core) meta;
|
2020-09-07 19:23:12 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
|
|
|
passthru = {
|
2020-12-07 16:05:33 +00:00
|
|
|
inherit core;
|
2020-09-07 19:23:12 +00:00
|
|
|
updateScript = ./update.sh;
|
|
|
|
tests = {
|
|
|
|
simple-vmess-proxy-test = nixosTests.v2ray;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
} ''
|
|
|
|
for file in ${core}/bin/*; do
|
|
|
|
makeWrapper "$file" "$out/bin/$(basename "$file")" \
|
2021-12-14 08:13:01 +00:00
|
|
|
--set-default V2RAY_LOCATION_ASSET ${assetsDrv}/share/v2ray
|
2020-09-07 19:23:12 +00:00
|
|
|
done
|
2020-09-07 19:35:26 +00:00
|
|
|
''
|