aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/tools/networking/v2ray
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/tools/networking/v2ray')
-rw-r--r--nixpkgs/pkgs/tools/networking/v2ray/default.nix73
-rw-r--r--nixpkgs/pkgs/tools/networking/v2ray/generic.nix50
-rwxr-xr-xnixpkgs/pkgs/tools/networking/v2ray/update.sh28
3 files changed, 86 insertions, 65 deletions
diff --git a/nixpkgs/pkgs/tools/networking/v2ray/default.nix b/nixpkgs/pkgs/tools/networking/v2ray/default.nix
index 0f0c5961c00..bc8a0873f78 100644
--- a/nixpkgs/pkgs/tools/networking/v2ray/default.nix
+++ b/nixpkgs/pkgs/tools/networking/v2ray/default.nix
@@ -1,22 +1,24 @@
-{ callPackage, fetchFromGitHub, fetchurl
+{ lib, fetchFromGitHub, fetchurl, linkFarm, buildGoModule, runCommand, makeWrapper, nixosTests
, assetOverrides ? {}
-, ... } @ args:
+}:
-callPackage ./generic.nix (rec {
- version = "4.23.3";
+let
+ version = "4.27.5";
src = fetchFromGitHub {
owner = "v2ray";
repo = "v2ray-core";
rev = "v${version}";
- sha256 = "1b0cxrpgkmgas7pwxglsvgcig8rnhffkf990b42z7awji5lw055v";
+ sha256 = "168kz8hq7mcfy6h758mmrky550p04bi9jsfqhy67jcxq81874m2k";
};
+ vendorSha256 = "0m889byxw70vv1mzlivalq444byp0y182nqqzdr458gfifvpc7s7";
+
assets = {
# MIT licensed
"geoip.dat" = let
- geoipRev = "202005270003";
- geoipSha256 = "10gf69hr32p4bpl5j8r46v8xzhpcgm70xbcdxm1a8l0jwyj0infs";
+ geoipRev = "202009020005";
+ geoipSha256 = "1xsy678cpqv6ycnhzl3pms76ic40aggq46q9dsd5ghj94mcx9837";
in fetchurl {
url = "https://github.com/v2ray/geoip/releases/download/${geoipRev}/geoip.dat";
sha256 = geoipSha256;
@@ -24,8 +26,8 @@ callPackage ./generic.nix (rec {
# MIT licensed
"geosite.dat" = let
- geositeRev = "202005292154";
- geositeSha256 = "0w6l0q8y14in5f4a406blpprqq6p438gpclnlfz7y2hkh5zf36cr";
+ geositeRev = "20200901194123";
+ geositeSha256 = "0fjx1wrq14d9v326k4fjwca3h5nv8ghk11kprf6jkjncjszwvgby";
in fetchurl {
url = "https://github.com/v2ray/domain-list-community/releases/download/${geositeRev}/dlc.dat";
sha256 = geositeSha256;
@@ -33,4 +35,55 @@ callPackage ./generic.nix (rec {
} // assetOverrides;
-} // args)
+ assetsDrv = linkFarm "v2ray-assets" (lib.mapAttrsToList (name: path: {
+ inherit name path;
+ }) assets);
+
+ core = buildGoModule rec {
+ pname = "v2ray-core";
+ inherit version src;
+
+ inherit vendorSha256;
+
+ doCheck = false;
+
+ 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 $out/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 ];
+ };
+
+ passthru = {
+ updateScript = ./update.sh;
+ tests = {
+ simple-vmess-proxy-test = nixosTests.v2ray;
+ };
+ };
+
+} ''
+ for file in ${core}/bin/*; do
+ makeWrapper "$file" "$out/bin/$(basename "$file")" \
+ --set-default V2RAY_LOCATION_ASSET ${assetsDrv}
+ done
+''
diff --git a/nixpkgs/pkgs/tools/networking/v2ray/generic.nix b/nixpkgs/pkgs/tools/networking/v2ray/generic.nix
deleted file mode 100644
index e8f4d278c32..00000000000
--- a/nixpkgs/pkgs/tools/networking/v2ray/generic.nix
+++ /dev/null
@@ -1,50 +0,0 @@
-{ lib, linkFarm, buildGoModule, runCommand, makeWrapper
-
-# Version specific args
-, version, src, assets
-, ... }:
-
-let
- assetsDrv = linkFarm "v2ray-assets" (lib.mapAttrsToList (name: path: {
- inherit name path;
- }) assets);
-
- core = buildGoModule rec {
- pname = "v2ray-core";
- inherit version src;
-
- vendorSha256 = "0d2qmnmlkl884ccg0qcd2yhfj0dwxnb9dz3cih7rcipz85w2f2rs";
-
- 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 $out/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
-'' \ No newline at end of file
diff --git a/nixpkgs/pkgs/tools/networking/v2ray/update.sh b/nixpkgs/pkgs/tools/networking/v2ray/update.sh
index 38ad77e98f8..56a148444c7 100755
--- a/nixpkgs/pkgs/tools/networking/v2ray/update.sh
+++ b/nixpkgs/pkgs/tools/networking/v2ray/update.sh
@@ -1,11 +1,13 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq
set -eo pipefail
+cd "$(dirname "${BASH_SOURCE[0]}")"
-version_nix=$(dirname "$0")/default.nix
-deps_nix=$(dirname "$0")/deps.nix
+version_nix=./default.nix
+deps_nix=./deps.nix
+nixpkgs=../../../..
-old_core_rev="v$(sed -En 's/.*\bversion = "(.*?)".*/\1/p' "$version_nix")"
+old_core_rev=$(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
@@ -17,6 +19,7 @@ function fetch_latest_rev {
}
core_rev=$(fetch_latest_rev 'v2ray-core')
+core_rev=${core_rev:1}
geoip_rev=$(fetch_latest_rev 'geoip')
geosite_rev=$(fetch_latest_rev 'domain-list-community')
echo "Latest version:" >&2
@@ -25,12 +28,13 @@ 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"
+ nix-prefetch-url --unpack --print-path "https://github.com/v2ray/v2ray-core/archive/v$core_rev.zip"
)
sed --in-place \
- -e "s/\bversion = \".*\"/version = \"$(echo "$core_rev" | tail -c+2)\"/" \
+ -e "s/\bversion = \".*\"/version = \"$core_rev\"/" \
-e "s/\bsha256 = \".*\"/sha256 = \"$hash\"/" \
+ -e "s/\bvendorSha256 = \".*\"/vendorSha256 = \"0000000000000000000000000000000000000000000000000000\"/" \
"$version_nix"
fi
@@ -51,3 +55,17 @@ if [[ $geosite_rev != $old_geosite_rev ]]; then
-e "s/\bgeositeSha256 = \".*\"/geositeSha256 = \"$hash\"/" \
"$version_nix"
fi
+
+echo "Prebuilding..." >&2
+set +o pipefail
+vendorSha256=$(
+ nix-build "$nixpkgs" -A v2ray --no-out-link 2>&1 |
+ tee /dev/stderr |
+ sed -nE 's/.*got:\s*sha256:(\w+)$/\1/p'
+)
+[[ "$vendorSha256" ]]
+sed --in-place \
+ -e "s/vendorSha256 = \".*\"/vendorSha256 = \"$vendorSha256\"/" \
+ "$version_nix"
+
+echo "vendorSha256 updated" >&2