2023-07-15 17:15:38 +00:00
|
|
|
{ lib
|
|
|
|
, stdenvNoCC
|
|
|
|
, fetchFromGitHub
|
|
|
|
, pkgsBuildBuild
|
|
|
|
, jq
|
|
|
|
, moreutils
|
|
|
|
, dbip-country-lite
|
|
|
|
}:
|
2021-12-19 01:06:50 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
let
|
2023-11-16 04:20:00 +00:00
|
|
|
generator = pkgsBuildBuild.buildGo120Module {
|
2023-07-15 17:15:38 +00:00
|
|
|
pname = "v2ray-geoip";
|
2023-11-16 04:20:00 +00:00
|
|
|
version = "unstable-2023-10-11";
|
2021-12-19 01:06:50 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "v2fly";
|
|
|
|
repo = "geoip";
|
2023-11-16 04:20:00 +00:00
|
|
|
rev = "3182dda7b38c900f28505b91a44b09ec486e6f36";
|
|
|
|
hash = "sha256-KSRgof78jScwnUeMtryj34J0mBsM/x9hFE4H9WtZUuM=";
|
2023-07-15 17:15:38 +00:00
|
|
|
};
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
vendorHash = "sha256-rlRazevKnWy/Ig143s8TZgV3JlQMlHID9rnncLYhQDc=";
|
2023-07-15 17:15:38 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "GeoIP for V2Ray";
|
|
|
|
homepage = "https://github.com/v2fly/geoip";
|
|
|
|
license = licenses.cc-by-sa-40;
|
|
|
|
maintainers = with maintainers; [ nickcao ];
|
|
|
|
};
|
2021-12-19 01:06:50 +00:00
|
|
|
};
|
2023-07-15 17:15:38 +00:00
|
|
|
input = {
|
|
|
|
type = "maxmindMMDB";
|
|
|
|
action = "add";
|
|
|
|
args = {
|
|
|
|
uri = dbip-country-lite.mmdb;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
stdenvNoCC.mkDerivation {
|
|
|
|
inherit (generator) pname src;
|
|
|
|
inherit (dbip-country-lite) version;
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
jq
|
|
|
|
moreutils
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
jq '.input[0] |= ${builtins.toJSON input}' config.json | sponge config.json
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
${generator}/bin/geoip
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
2021-12-19 01:06:50 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2023-07-15 17:15:38 +00:00
|
|
|
install -Dm444 -t "$out/share/v2ray" output/dat/{cn,geoip-only-cn-private,geoip,private}.dat
|
2021-12-19 01:06:50 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
passthru.generator = generator;
|
2021-12-19 01:06:50 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
meta = generator.meta // {
|
|
|
|
inherit (dbip-country-lite.meta) license;
|
2021-12-19 01:06:50 +00:00
|
|
|
};
|
|
|
|
}
|