git.iko.soy/typeable/nixpkgs
on master help sign in
v2ray: simplify nix
commit32940aeec4c1c25d63bc9c75c22ee92dd05283c4 authorServal <servalcat@pm.me> dateTue 8 Sep 2020, 03:23 (6 years ago) parent4ac99e7
2 files changed+55−60
pkgs/tools/networking/v2ray/default.nix+55−4 pkgs/tools/networking/v2ray/generic.nix−56
pkgs/tools/networking/v2ray/default.nix+55−4
@@ -1,8 +1,8 @@
1−{ callPackage, fetchFromGitHub, fetchurl
1+{ lib, fetchFromGitHub, fetchurl, linkFarm, buildGoModule, runCommand, makeWrapper, nixosTests
22, assetOverrides ? {}
3−, ... } @ args:
3+}:
44
5−callPackage ./generic.nix (rec {
5+let
66 version = "4.27.5";
77
88 src = fetchFromGitHub {
@@ -35,4 +35,55 @@ callPackage ./generic.nix (rec {
3535
3636 } // assetOverrides;
3737
38−} // args)
38+ assetsDrv = linkFarm "v2ray-assets" (lib.mapAttrsToList (name: path: {
39+ inherit name path;
40+ }) assets);
41+
42+ core = buildGoModule rec {
43+ pname = "v2ray-core";
44+ inherit version src;
45+
46+ inherit vendorSha256;
47+
48+ doCheck = false;
49+
50+ buildPhase = ''
51+ runHook preBuild
52+
53+ go build -o v2ray v2ray.com/core/main
54+ go build -o v2ctl v2ray.com/core/infra/control/main
55+
56+ runHook postBuild
57+ '';
58+
59+ installPhase = ''
60+ install -Dm755 v2ray v2ctl -t $out/bin
61+ '';
62+ };
63+
64+in runCommand "v2ray-${version}" {
65+ inherit version;
66+
67+ buildInputs = [ assetsDrv core ];
68+ nativeBuildInputs = [ makeWrapper ];
69+
70+ meta = {
71+ homepage = "https://www.v2ray.com/en/index.html";
72+ description = "A platform for building proxies to bypass network restrictions";
73+ license = with lib.licenses; [ mit ];
74+ maintainers = with lib.maintainers; [ servalcatty ];
75+ };
76+
77+ passthru = {
78+ updateScript = ./update.sh;
79+ tests = {
80+ simple-vmess-proxy-test = nixosTests.v2ray;
81+ };
82+ };
83+
84+} ''
85+ for file in ${core}/bin/*; do
86+ makeWrapper "$file" "$out/bin/$(basename "$file")" \
87+ --set-default V2RAY_LOCATION_ASSET ${assetsDrv}
88+ done
89+''
pkgs/tools/networking/v2ray/generic.nixdeleted−56
@@ -1,56 +0,0 @@
1−{ lib, linkFarm, buildGoModule, runCommand, makeWrapper, nixosTests
2−
3−# Version specific args
4−, version, src, assets, vendorSha256
5−, ... }:
6−
7−let
8− assetsDrv = linkFarm "v2ray-assets" (lib.mapAttrsToList (name: path: {
9− inherit name path;
10− }) assets);
11−
12− core = buildGoModule rec {
13− pname = "v2ray-core";
14− inherit version src;
15−
16− inherit vendorSha256;
17−
18− doCheck = false;
19−
20− buildPhase = ''
21− runHook preBuild
22−
23− go build -o v2ray v2ray.com/core/main
24− go build -o v2ctl v2ray.com/core/infra/control/main
25−
26− runHook postBuild
27− '';
28−
29− installPhase = ''
30− install -Dm755 v2ray v2ctl -t $out/bin
31− '';
32− };
33−
34−in runCommand "v2ray-${version}" {
35− inherit version;
36−
37− buildInputs = [ assetsDrv core ];
38− nativeBuildInputs = [ makeWrapper ];
39−
40− meta = {
41− homepage = "https://www.v2ray.com/en/index.html";
42− description = "A platform for building proxies to bypass network restrictions";
43− license = with lib.licenses; [ mit ];
44− maintainers = with lib.maintainers; [ servalcatty ];
45− };
46−
47− passthru.tests = {
48− simple-vmess-proxy-test = nixosTests.v2ray;
49− };
50−
51−} ''
52− for file in ${core}/bin/*; do
53− makeWrapper "$file" "$out/bin/$(basename "$file")" \
54− --set-default V2RAY_LOCATION_ASSET ${assetsDrv}
55− done
56−''