2019-11-27 21:09:18 +03:00
|
|
|
{ lib, linkFarm, buildGoModule, runCommand, makeWrapper
|
2019-10-02 22:05:07 +03:00
|
|
|
|
|
|
|
# Version specific args
|
2020-07-08 20:14:28 +03:00
|
|
|
, version, src, assets, vendorSha256
|
2019-10-02 22:05:07 +03:00
|
|
|
, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
assetsDrv = linkFarm "v2ray-assets" (lib.mapAttrsToList (name: path: {
|
|
|
|
inherit name path;
|
|
|
|
}) assets);
|
|
|
|
|
2019-11-27 21:09:18 +03:00
|
|
|
core = buildGoModule rec {
|
2019-10-02 22:05:07 +03:00
|
|
|
pname = "v2ray-core";
|
|
|
|
inherit version src;
|
|
|
|
|
2020-07-08 20:14:28 +03:00
|
|
|
inherit vendorSha256;
|
2019-10-02 22:05:07 +03:00
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
go build -o v2ray v2ray.com/core/main
|
|
|
|
go build -o v2ctl v2ray.com/core/infra/control/main
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2019-11-27 21:09:18 +03:00
|
|
|
install -Dm755 v2ray v2ctl -t $out/bin
|
2019-10-02 22:05:07 +03:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
in runCommand "v2ray-${version}" {
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
buildInputs = [ assetsDrv core ];
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
homepage = "https://www.v2ray.com/en/index.html";
|
|
|
|
description = "A platform for building proxies to bypass network restrictions";
|
|
|
|
license = with lib.licenses; [ mit ];
|
|
|
|
maintainers = with lib.maintainers; [ servalcatty ];
|
|
|
|
};
|
|
|
|
|
|
|
|
} ''
|
|
|
|
for file in ${core}/bin/*; do
|
|
|
|
makeWrapper "$file" "$out/bin/$(basename "$file")" \
|
|
|
|
--set-default V2RAY_LOCATION_ASSET ${assetsDrv}
|
|
|
|
done
|
2020-07-31 06:58:04 +03:00
|
|
|
''
|