v2ray: init at 4.21.3
This commit is contained in:
parent
6ad1c86872
commit
3e1fc7ac1e
36
pkgs/tools/networking/v2ray/default.nix
Normal file
36
pkgs/tools/networking/v2ray/default.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ callPackage, fetchFromGitHub, fetchurl
|
||||
, assetOverrides ? {}
|
||||
, ... } @ args:
|
||||
|
||||
callPackage ./generic.nix (rec {
|
||||
version = "4.21.3";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "v2ray";
|
||||
repo = "v2ray-core";
|
||||
rev = "v${version}";
|
||||
sha256 = "0z45nrjnalrvpprq7g4zrjbrdkc3d3lhs4ci8hb8m69f92asiwbs";
|
||||
};
|
||||
|
||||
assets = {
|
||||
# MIT licensed
|
||||
"geoip.dat" = let
|
||||
geoipRev = "20190516.1";
|
||||
geoipSha256 = "14h4rq7rlcl1397pwpylfgwpk3fiscpzqb04c4wd5lxkfvk5f02r";
|
||||
in fetchurl {
|
||||
url = "https://github.com/v2ray/geoip/releases/download/${geoipRev}/geoip.dat";
|
||||
sha256 = geoipSha256;
|
||||
};
|
||||
|
||||
# MIT licensed
|
||||
"geosite.dat" = let
|
||||
geositeRev = "20191121.1";
|
||||
geositeSha256 = "0ijmvy43pvm69w38djf114j8swni7wfq5ry9wdpv9dj0rzb59m74";
|
||||
in fetchurl {
|
||||
url = "https://github.com/v2ray/domain-list-community/releases/download/${geositeRev}/dlc.dat";
|
||||
sha256 = geositeSha256;
|
||||
};
|
||||
|
||||
} // assetOverrides;
|
||||
|
||||
} // args)
|
219
pkgs/tools/networking/v2ray/deps.nix
generated
Normal file
219
pkgs/tools/networking/v2ray/deps.nix
generated
Normal file
|
@ -0,0 +1,219 @@
|
|||
# file generated from go.mod using vgo2nix (https://github.com/adisbladis/vgo2nix)
|
||||
[
|
||||
{
|
||||
goPackagePath = "cloud.google.com/go";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://code.googlesource.com/gocloud";
|
||||
rev = "v0.26.0";
|
||||
sha256 = "149v3ci17g6wd2pm18mzcncq5qpl9hwdjnz3rlbn5rfidyn46la1";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/BurntSushi/toml";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/BurntSushi/toml";
|
||||
rev = "v0.3.1";
|
||||
sha256 = "1fjdwwfzyzllgiwydknf1pwjvy49qxfsczqx5gz3y0izs7as99j6";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/client9/misspell";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/client9/misspell";
|
||||
rev = "v0.3.4";
|
||||
sha256 = "1vwf33wsc4la25zk9nylpbp9px3svlmldkm0bha4hp56jws4q9cs";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/golang/glog";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/golang/glog";
|
||||
rev = "23def4e6c14b";
|
||||
sha256 = "0jb2834rw5sykfr937fxi8hxi2zy80sj2bdn9b3jb4b26ksqng30";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/golang/mock";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/golang/mock";
|
||||
rev = "v1.2.0";
|
||||
sha256 = "12ddj2g8ab87id6n2n67vnbhq6p8dvgsq1pzpqfriym4dk8w54fg";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/golang/protobuf";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/golang/protobuf";
|
||||
rev = "v1.3.2";
|
||||
sha256 = "1k1wb4zr0qbwgpvz9q5ws9zhlal8hq7dmq62pwxxriksayl6hzym";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/google/go-cmp";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/google/go-cmp";
|
||||
rev = "v0.2.0";
|
||||
sha256 = "1fbv0x27k9sn8svafc0hjwsnckk864lv4yi7bvzrxvmd3d5hskds";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/gorilla/websocket";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/gorilla/websocket";
|
||||
rev = "v1.4.1";
|
||||
sha256 = "03n1n0nwz3k9qshmriycqznnnvd3dkzsfwpnfjzzvafjxk9kyapv";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/miekg/dns";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/miekg/dns";
|
||||
rev = "v1.1.4";
|
||||
sha256 = "17apnm7q5v7bhmpvrk3rbi0gjqk8z3cwkm90q1dfzrfvbvp71z5d";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/refraction-networking/utls";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/refraction-networking/utls";
|
||||
rev = "43c36d3c1f57";
|
||||
sha256 = "0hrilfij4aj72xrwi457h1hdzrjv20mybzw7xl1qa4i2v74f888q";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "go.starlark.net";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/google/starlark-go";
|
||||
rev = "979af19b165c";
|
||||
sha256 = "15iypn482brrx6agw363hzd7vx9p22h407n9mnzshfv4smsfgj81";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "golang.org/x/crypto";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://go.googlesource.com/crypto";
|
||||
rev = "c2843e01d9a2";
|
||||
sha256 = "01xgxbj5r79nmisdvpq48zfy8pzaaj90bn6ngd4nf33j9ar1dp8r";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "golang.org/x/lint";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://go.googlesource.com/lint";
|
||||
rev = "d0100b6bd8b3";
|
||||
sha256 = "0b0amr9x4ji66iv9ayfx7zrfx52k1m5g66qfcxkgj80qrb1y2yn7";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "golang.org/x/net";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://go.googlesource.com/net";
|
||||
rev = "d8887717615a";
|
||||
sha256 = "1wfm6ngxjyj7v5a2dqib6lw8bb2rdnf1kl48diykxjrsddn0s163";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "golang.org/x/oauth2";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://go.googlesource.com/oauth2";
|
||||
rev = "d2e6202438be";
|
||||
sha256 = "0wbn75fd10485nb93bm4kqldqifdim5xqy4v7r5sdvimvf3fyhn7";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "golang.org/x/sync";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://go.googlesource.com/sync";
|
||||
rev = "112230192c58";
|
||||
sha256 = "05i2k43j2d0llq768hg5pf3hb2yhfzp9la1w5wp0rsnnzblr0lfn";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "golang.org/x/sys";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://go.googlesource.com/sys";
|
||||
rev = "d0b11bdaac8a";
|
||||
sha256 = "18yfsmw622l7gc5sqriv5qmck6903vvhivpzp8i3xfy3z33dybdl";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "golang.org/x/text";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://go.googlesource.com/text";
|
||||
rev = "v0.3.0";
|
||||
sha256 = "0r6x6zjzhr8ksqlpiwm5gdd7s209kwk5p4lw54xjvz10cs3qlq19";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "golang.org/x/tools";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://go.googlesource.com/tools";
|
||||
rev = "2c0ae7006135";
|
||||
sha256 = "1lsi2ssxajclj3bciz2a41v1vjv768ja3v6wnbyhxy8xphwkp4fk";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "google.golang.org/appengine";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/golang/appengine";
|
||||
rev = "v1.1.0";
|
||||
sha256 = "1pz202zszg8f35dk5pfhwgcdi3r6dx1l4yk6x6ly7nb4j45zi96x";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "google.golang.org/genproto";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/google/go-genproto";
|
||||
rev = "11092d34479b";
|
||||
sha256 = "12qcrjq658zga5fj4n0wgm11pzpr3gafwg25cinl5qcq4p9cnl0r";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "google.golang.org/grpc";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/grpc/grpc-go";
|
||||
rev = "v1.24.0";
|
||||
sha256 = "0h8mwv74vzcfb7p4ai247x094skxca71vjp4wpj2wzmri0x9p4v6";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "h12.io/socks";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/h12w/socks";
|
||||
rev = "v1.0.0";
|
||||
sha256 = "05iq2i3idpwv1n087zsmcrva5ix8akngm37a36mg0ndidn7ypgis";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "honnef.co/go/tools";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/dominikh/go-tools";
|
||||
rev = "ea95bdfd59fc";
|
||||
sha256 = "1763nw7pwpzkvzfnm63dgzcgbq9hwmq5l1nffchnhh77vgkaq4ic";
|
||||
};
|
||||
}
|
||||
]
|
53
pkgs/tools/networking/v2ray/generic.nix
Normal file
53
pkgs/tools/networking/v2ray/generic.nix
Normal file
|
@ -0,0 +1,53 @@
|
|||
{ lib, linkFarm, buildGoPackage, runCommand, makeWrapper, go
|
||||
|
||||
# Version specific args
|
||||
, version, src, assets
|
||||
, ... }:
|
||||
|
||||
let
|
||||
assetsDrv = linkFarm "v2ray-assets" (lib.mapAttrsToList (name: path: {
|
||||
inherit name path;
|
||||
}) assets);
|
||||
|
||||
core = buildGoPackage rec {
|
||||
pname = "v2ray-core";
|
||||
inherit version src;
|
||||
|
||||
goPackagePath = "v2ray.com/core";
|
||||
goDeps = ./deps.nix;
|
||||
|
||||
nativeBuildInputs = [ go ];
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
go build -o v2ray v2ray.com/core/main
|
||||
go build -o v2ctl v2ray.com/core/infra/control/main
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
install -Dm755 v2ray v2ctl -t $bin/bin
|
||||
'';
|
||||
};
|
||||
|
||||
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
|
||||
''
|
57
pkgs/tools/networking/v2ray/update.sh
Executable file
57
pkgs/tools/networking/v2ray/update.sh
Executable file
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl jq vgo2nix
|
||||
set -eo pipefail
|
||||
|
||||
version_nix=$(dirname "$0")/default.nix
|
||||
deps_nix=$(dirname "$0")/deps.nix
|
||||
|
||||
old_core_rev="v$(sed -En 's/.*\bversion = "(.*?)".*/\1/p' "$version_nix")"
|
||||
old_geoip_rev=$(sed -En 's/.*\bgeoipRev = "(.*?)".*/\1/p' "$version_nix")
|
||||
old_geosite_rev=$(sed -En 's/.*\bgeositeRev = "(.*?)".*/\1/p' "$version_nix")
|
||||
echo "Current version:" >&2
|
||||
echo "core: $old_core_rev, geoip: $old_geoip_rev, geosite: $old_geosite_rev" >&2
|
||||
|
||||
function fetch_latest_rev {
|
||||
curl "https://api.github.com/repos/v2ray/$1/releases" |
|
||||
jq '.[0].tag_name' --raw-output
|
||||
}
|
||||
|
||||
core_rev=$(fetch_latest_rev 'v2ray-core')
|
||||
geoip_rev=$(fetch_latest_rev 'geoip')
|
||||
geosite_rev=$(fetch_latest_rev 'domain-list-community')
|
||||
echo "Latest version:" >&2
|
||||
echo "core: $core_rev, geoip: $geoip_rev, geosite: $geosite_rev" >&2
|
||||
|
||||
if [[ $core_rev != $old_core_rev ]]; then
|
||||
echo "Prefetching core..." >&2
|
||||
{ read hash; read store_path; } < <(
|
||||
nix-prefetch-url --unpack --print-path "https://github.com/v2ray/v2ray-core/archive/$core_rev.zip"
|
||||
)
|
||||
|
||||
echo "Generating deps.nix..." >&2
|
||||
# `outfile` is required to be absolute path
|
||||
vgo2nix -dir "$store_path" -outfile "$(realpath "$deps_nix")"
|
||||
|
||||
sed --in-place \
|
||||
-e "s/\bversion = \".*\"/version = \"$(echo "$core_rev" | tail -c+2)\"/" \
|
||||
-e "s/\bsha256 = \".*\"/sha256 = \"$hash\"/" \
|
||||
"$version_nix"
|
||||
fi
|
||||
|
||||
if [[ $geoip_rev != $old_geoip_rev ]]; then
|
||||
echo "Prefetching geoip..." >&2
|
||||
hash=$(nix-prefetch-url "https://github.com/v2ray/geoip/releases/download/$geoip_rev/geoip.dat")
|
||||
sed --in-place \
|
||||
-e "s/\bgeoipRev = \".*\"/geoipRev = \"$geoip_rev\"/" \
|
||||
-e "s/\bgeoipSha256 = \".*\"/geoipSha256 = \"$hash\"/" \
|
||||
"$version_nix"
|
||||
fi
|
||||
|
||||
if [[ $geosite_rev != $old_geosite_rev ]]; then
|
||||
echo "Prefetching geosite..." >&2
|
||||
hash=$(nix-prefetch-url "https://github.com/v2ray/domain-list-community/releases/download/$geosite_rev/dlc.dat")
|
||||
sed --in-place \
|
||||
-e "s/\bgeositeRev = \".*\"/geositeRev = \"$geosite_rev\"/" \
|
||||
-e "s/\bgeositeSha256 = \".*\"/geositeSha256 = \"$hash\"/" \
|
||||
"$version_nix"
|
||||
fi
|
|
@ -6905,6 +6905,8 @@ in
|
|||
|
||||
uwsgi = callPackage ../servers/uwsgi { };
|
||||
|
||||
v2ray = callPackage ../tools/networking/v2ray { };
|
||||
|
||||
vacuum = callPackage ../applications/networking/instant-messengers/vacuum {};
|
||||
|
||||
vampire = callPackage ../applications/science/logic/vampire {};
|
||||
|
|
Loading…
Reference in a new issue