From 6ad1c86872910ad25e7208627dbee8cd157da354 Mon Sep 17 00:00:00 2001 From: Serval Date: Thu, 3 Oct 2019 03:04:44 +0800 Subject: [PATCH 1/4] maintainers: add servalcatty --- maintainers/maintainer-list.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index bb7bc8bd827..472122efb03 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -6062,6 +6062,16 @@ githubId = 307899; name = "Gurkan Gur"; }; + servalcatty = { + email = "servalcat@pm.me"; + github = "servalcatty"; + githubid = 51969817; + name = "Serval"; + keys = [{ + longkeyid = "rsa4096/0x4A2AAAA382F8294C"; + fingerprint = "A317 37B3 693C 921B 480C C629 4A2A AAA3 82F8 294C"; + }]; + }; sfrijters = { email = "sfrijters@gmail.com"; github = "sfrijters"; From 3e1fc7ac1e1dc76ad704c0fff7a47d72ac7a9d5d Mon Sep 17 00:00:00 2001 From: Serval Date: Thu, 3 Oct 2019 03:05:07 +0800 Subject: [PATCH 2/4] v2ray: init at 4.21.3 --- pkgs/tools/networking/v2ray/default.nix | 36 ++++ pkgs/tools/networking/v2ray/deps.nix | 219 ++++++++++++++++++++++++ pkgs/tools/networking/v2ray/generic.nix | 53 ++++++ pkgs/tools/networking/v2ray/update.sh | 57 ++++++ pkgs/top-level/all-packages.nix | 2 + 5 files changed, 367 insertions(+) create mode 100644 pkgs/tools/networking/v2ray/default.nix create mode 100644 pkgs/tools/networking/v2ray/deps.nix create mode 100644 pkgs/tools/networking/v2ray/generic.nix create mode 100755 pkgs/tools/networking/v2ray/update.sh diff --git a/pkgs/tools/networking/v2ray/default.nix b/pkgs/tools/networking/v2ray/default.nix new file mode 100644 index 00000000000..78f17934a78 --- /dev/null +++ b/pkgs/tools/networking/v2ray/default.nix @@ -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) diff --git a/pkgs/tools/networking/v2ray/deps.nix b/pkgs/tools/networking/v2ray/deps.nix new file mode 100644 index 00000000000..40128b1c1fb --- /dev/null +++ b/pkgs/tools/networking/v2ray/deps.nix @@ -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"; + }; + } +] diff --git a/pkgs/tools/networking/v2ray/generic.nix b/pkgs/tools/networking/v2ray/generic.nix new file mode 100644 index 00000000000..ce10d186ba5 --- /dev/null +++ b/pkgs/tools/networking/v2ray/generic.nix @@ -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 +'' diff --git a/pkgs/tools/networking/v2ray/update.sh b/pkgs/tools/networking/v2ray/update.sh new file mode 100755 index 00000000000..a7bd40bc2e5 --- /dev/null +++ b/pkgs/tools/networking/v2ray/update.sh @@ -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 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5937fc95a78..553825846e1 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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 {}; From 740e85f847551b277d36a5502cd763ccfbea0315 Mon Sep 17 00:00:00 2001 From: Serval Date: Thu, 21 Nov 2019 21:51:10 +0800 Subject: [PATCH 3/4] v2ray: add v2ray service --- nixos/modules/module-list.nix | 1 + nixos/modules/services/networking/v2ray.nix | 81 +++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 nixos/modules/services/networking/v2ray.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 6b578cd5619..9e9edba52a5 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -724,6 +724,7 @@ ./services/networking/tvheadend.nix ./services/networking/unbound.nix ./services/networking/unifi.nix + ./services/networking/v2ray.nix ./services/networking/vsftpd.nix ./services/networking/wakeonlan.nix ./services/networking/websockify.nix diff --git a/nixos/modules/services/networking/v2ray.nix b/nixos/modules/services/networking/v2ray.nix new file mode 100644 index 00000000000..f1556bb1279 --- /dev/null +++ b/nixos/modules/services/networking/v2ray.nix @@ -0,0 +1,81 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + options = { + + services.v2ray = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to run v2ray server. + + Either `configFile` or `config` must be specified. + ''; + }; + + configFile = mkOption { + type = types.nullOr types.str; + default = null; + example = "/etc/v2ray/config.json"; + description = '' + The absolute path to the configuration file. + + Either `configFile` or `config` must be specified. + + See . + ''; + }; + + config = mkOption { + type = types.nullOr (types.attrsOf types.unspecified); + default = null; + example = { + inbounds = [{ + port = 1080; + listen = "127.0.0.1"; + protocol = "http"; + }]; + outbounds = [{ + protocol = "freedom"; + }]; + }; + description = '' + The configuration object. + + Either `configFile` or `config` must be specified. + + See . + ''; + }; + }; + + }; + + config = let + cfg = config.services.v2ray; + configFile = if cfg.configFile != null + then cfg.configFile + else (pkgs.writeText "v2ray.json" (builtins.toJSON cfg.config)); + + in mkIf cfg.enable { + assertions = [ + { + assertion = (cfg.configFile == null) != (cfg.config == null); + message = "Either but not both `configFile` and `config` should be specified for v2ray."; + } + ]; + + systemd.services.v2ray = { + description = "v2ray Daemon"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + path = [ pkgs.v2ray ]; + script = '' + exec v2ray -config ${configFile} + ''; + }; + }; +} From 899d38170cfedc567da0b11d346a9f47f65e0a86 Mon Sep 17 00:00:00 2001 From: Serval Date: Thu, 28 Nov 2019 02:09:18 +0800 Subject: [PATCH 4/4] v2ray: fixups and change to `buildGoModule` --- nixos/modules/services/networking/v2ray.nix | 4 +- pkgs/tools/networking/v2ray/deps.nix | 219 -------------------- pkgs/tools/networking/v2ray/generic.nix | 11 +- pkgs/tools/networking/v2ray/update.sh | 6 +- 4 files changed, 7 insertions(+), 233 deletions(-) delete mode 100644 pkgs/tools/networking/v2ray/deps.nix diff --git a/nixos/modules/services/networking/v2ray.nix b/nixos/modules/services/networking/v2ray.nix index f1556bb1279..a1774cdffbb 100644 --- a/nixos/modules/services/networking/v2ray.nix +++ b/nixos/modules/services/networking/v2ray.nix @@ -12,7 +12,7 @@ with lib; description = '' Whether to run v2ray server. - Either `configFile` or `config` must be specified. + Either configFile or config must be specified. ''; }; @@ -23,7 +23,7 @@ with lib; description = '' The absolute path to the configuration file. - Either `configFile` or `config` must be specified. + Either configFile or config must be specified. See . ''; diff --git a/pkgs/tools/networking/v2ray/deps.nix b/pkgs/tools/networking/v2ray/deps.nix deleted file mode 100644 index 40128b1c1fb..00000000000 --- a/pkgs/tools/networking/v2ray/deps.nix +++ /dev/null @@ -1,219 +0,0 @@ -# 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"; - }; - } -] diff --git a/pkgs/tools/networking/v2ray/generic.nix b/pkgs/tools/networking/v2ray/generic.nix index ce10d186ba5..bf6e6cd55ae 100644 --- a/pkgs/tools/networking/v2ray/generic.nix +++ b/pkgs/tools/networking/v2ray/generic.nix @@ -1,4 +1,4 @@ -{ lib, linkFarm, buildGoPackage, runCommand, makeWrapper, go +{ lib, linkFarm, buildGoModule, runCommand, makeWrapper # Version specific args , version, src, assets @@ -9,14 +9,11 @@ let inherit name path; }) assets); - core = buildGoPackage rec { + core = buildGoModule rec { pname = "v2ray-core"; inherit version src; - goPackagePath = "v2ray.com/core"; - goDeps = ./deps.nix; - - nativeBuildInputs = [ go ]; + modSha256 = "11gsncy3449a7y6w6pr7acqabyj2q2a1q52f8fcl5cdz1vjbmmxi"; buildPhase = '' runHook preBuild @@ -28,7 +25,7 @@ let ''; installPhase = '' - install -Dm755 v2ray v2ctl -t $bin/bin + install -Dm755 v2ray v2ctl -t $out/bin ''; }; diff --git a/pkgs/tools/networking/v2ray/update.sh b/pkgs/tools/networking/v2ray/update.sh index a7bd40bc2e5..38ad77e98f8 100755 --- a/pkgs/tools/networking/v2ray/update.sh +++ b/pkgs/tools/networking/v2ray/update.sh @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -i bash -p curl jq vgo2nix +#!nix-shell -i bash -p curl jq set -eo pipefail version_nix=$(dirname "$0")/default.nix @@ -28,10 +28,6 @@ if [[ $core_rev != $old_core_rev ]]; then 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\"/" \