mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 15:22:59 +01:00
v2ray: switch to packaged assets
This commit is contained in:
parent
f6e6287d0b
commit
8a5667342e
2 changed files with 9 additions and 51 deletions
|
@ -1,5 +1,5 @@
|
|||
{ lib, fetchFromGitHub, fetchurl, linkFarm, buildGoModule, runCommand, makeWrapper, nixosTests
|
||||
, assetOverrides ? {}
|
||||
{ lib, fetchFromGitHub, fetchurl, symlinkJoin, buildGoModule, runCommand, makeWrapper, nixosTests
|
||||
, v2ray-geoip, v2ray-domain-list-community, assets ? [ v2ray-geoip v2ray-domain-list-community ]
|
||||
}:
|
||||
|
||||
let
|
||||
|
@ -14,30 +14,10 @@ let
|
|||
|
||||
vendorSha256 = "sha256-7zSIAKcMwtaTvokKuLJ8orqJc2jGuaw5FglEJadeZ9I=";
|
||||
|
||||
assets = {
|
||||
# MIT licensed
|
||||
"geoip.dat" = let
|
||||
geoipRev = "202109300030";
|
||||
geoipSha256 = "1d2z3ljs0v9rd10cfj8cpiijz3ikkplsymr44f7y90g4dmniwqh0";
|
||||
in fetchurl {
|
||||
url = "https://github.com/v2fly/geoip/releases/download/${geoipRev}/geoip.dat";
|
||||
sha256 = geoipSha256;
|
||||
};
|
||||
|
||||
# MIT licensed
|
||||
"geosite.dat" = let
|
||||
geositeRev = "20211001023210";
|
||||
geositeSha256 = "02d55i1pdndwvmi4v42hnncjng517s0k06gr3yn5krnj2qfjli2w";
|
||||
in fetchurl {
|
||||
url = "https://github.com/v2fly/domain-list-community/releases/download/${geositeRev}/dlc.dat";
|
||||
sha256 = geositeSha256;
|
||||
};
|
||||
|
||||
} // assetOverrides;
|
||||
|
||||
assetsDrv = linkFarm "v2ray-assets" (lib.mapAttrsToList (name: path: {
|
||||
inherit name path;
|
||||
}) assets);
|
||||
assetsDrv = symlinkJoin {
|
||||
name = "v2ray-assets";
|
||||
paths = assets;
|
||||
};
|
||||
|
||||
core = buildGoModule rec {
|
||||
pname = "v2ray-core";
|
||||
|
@ -84,6 +64,6 @@ in runCommand "v2ray-${version}" {
|
|||
} ''
|
||||
for file in ${core}/bin/*; do
|
||||
makeWrapper "$file" "$out/bin/$(basename "$file")" \
|
||||
--set-default V2RAY_LOCATION_ASSET ${assetsDrv}
|
||||
--set-default V2RAY_LOCATION_ASSET ${assetsDrv}/share/v2ray
|
||||
done
|
||||
''
|
||||
|
|
|
@ -8,10 +8,8 @@ deps_nix=./deps.nix
|
|||
nixpkgs=../../../..
|
||||
|
||||
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
|
||||
echo "core: $old_core_rev, geoip: $old_geoip_rev, geosite: $old_geosite_rev" >&2
|
||||
echo "core: $old_core_rev" >&2
|
||||
|
||||
function fetch_latest_rev {
|
||||
curl "https://api.github.com/repos/v2fly/$1/releases" |
|
||||
|
@ -20,10 +18,8 @@ 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
|
||||
echo "core: $core_rev, geoip: $geoip_rev, geosite: $geosite_rev" >&2
|
||||
echo "core: $core_rev" >&2
|
||||
|
||||
if [[ $core_rev != $old_core_rev ]]; then
|
||||
echo "Prefetching core..." >&2
|
||||
|
@ -38,24 +34,6 @@ if [[ $core_rev != $old_core_rev ]]; then
|
|||
"$version_nix"
|
||||
fi
|
||||
|
||||
if [[ $geoip_rev != $old_geoip_rev ]]; then
|
||||
echo "Prefetching geoip..." >&2
|
||||
hash=$(nix-prefetch-url "https://github.com/v2fly/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/v2fly/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
|
||||
|
||||
echo "Prebuilding..." >&2
|
||||
set +o pipefail
|
||||
vendorSha256=$(
|
||||
|
|
Loading…
Reference in a new issue