2023-02-25 07:20:56 +01:00
|
|
|
{ lib
|
|
|
|
, stdenvNoCC
|
|
|
|
, buildGoModule
|
|
|
|
, fetchFromGitHub
|
2023-06-03 16:45:09 +02:00
|
|
|
, dbip-country-lite
|
2023-02-25 07:20:56 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
generator = buildGoModule rec {
|
|
|
|
pname = "sing-geoip";
|
2023-06-05 08:29:31 +02:00
|
|
|
version = "20230512";
|
2023-02-25 07:20:56 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "SagerNet";
|
|
|
|
repo = pname;
|
2023-06-05 08:29:31 +02:00
|
|
|
rev = "refs/tags/${version}";
|
|
|
|
hash = "sha256-Zm+5N/37hoHpH/TLNJrHeaBXI8G1jEpM1jz6Um8edNE=";
|
2023-02-25 07:20:56 +01:00
|
|
|
};
|
|
|
|
|
2023-06-05 08:29:31 +02:00
|
|
|
vendorHash = "sha256-ejXAdsJwXhqet+Ca+pDLWwu0gex79VcIxW6rmhRnbTQ=";
|
2023-02-25 07:20:56 +01:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "GeoIP data for sing-box";
|
|
|
|
homepage = "https://github.com/SagerNet/sing-geoip";
|
|
|
|
license = licenses.gpl3Plus;
|
|
|
|
maintainers = with maintainers; [ linsui ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
stdenvNoCC.mkDerivation rec {
|
|
|
|
inherit (generator) pname;
|
2023-06-03 16:45:09 +02:00
|
|
|
inherit (dbip-country-lite) version;
|
2023-02-25 07:20:56 +01:00
|
|
|
|
|
|
|
dontUnpack = true;
|
|
|
|
|
|
|
|
nativeBuildInputs = [ generator ];
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
2023-06-03 16:45:09 +02:00
|
|
|
${pname} ${dbip-country-lite.mmdb} geoip.db
|
|
|
|
${pname} ${dbip-country-lite.mmdb} geoip-cn.db cn
|
2023-02-25 07:20:56 +01:00
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
install -Dm644 geoip.db $out/share/sing-box/geoip.db
|
|
|
|
install -Dm644 geoip-cn.db $out/share/sing-box/geoip-cn.db
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru = { inherit generator; };
|
|
|
|
|
|
|
|
meta = generator.meta // {
|
2023-06-03 16:45:09 +02:00
|
|
|
inherit (dbip-country-lite.meta) license;
|
2023-02-25 07:20:56 +01:00
|
|
|
};
|
|
|
|
}
|