mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-15 14:26:33 +01:00
3536f16682
Update pkgs/data/misc/sing-geoip/default.nix Co-authored-by: Aleksana <alexander.huang.y@gmail.com>
67 lines
1.4 KiB
Nix
67 lines
1.4 KiB
Nix
{ lib
|
|
, stdenvNoCC
|
|
, buildGoModule
|
|
, fetchFromGitHub
|
|
, dbip-country-lite
|
|
}:
|
|
|
|
let
|
|
generator = buildGoModule rec {
|
|
pname = "sing-geoip";
|
|
version = "20240312";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "SagerNet";
|
|
repo = pname;
|
|
rev = "refs/tags/${version}";
|
|
hash = "sha256-nIrbiECK25GyuPEFqMvPdZUShC2JC1NI60Y10SsoWyY=";
|
|
};
|
|
|
|
vendorHash = "sha256-WH0eMg06qCiVcy4H+vBtYrmLMA2KJRCPGXiEnatW+LU=";
|
|
|
|
postPatch = ''
|
|
sed -i -e '/func main()/,/^}/d' main.go
|
|
cat ${./main.go} >> main.go
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "GeoIP data for sing-box";
|
|
homepage = "https://github.com/SagerNet/sing-geoip";
|
|
license = licenses.gpl3Plus;
|
|
maintainers = with maintainers; [ linsui ];
|
|
mainProgram = "sing-geoip";
|
|
};
|
|
};
|
|
in
|
|
stdenvNoCC.mkDerivation {
|
|
inherit (generator) pname;
|
|
inherit (dbip-country-lite) version;
|
|
|
|
dontUnpack = true;
|
|
|
|
nativeBuildInputs = [ generator ];
|
|
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
|
|
sing-geoip ${dbip-country-lite.mmdb}
|
|
|
|
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
|
|
install -Dm644 rule-set/* -t $out/share/sing-box/rule-set
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
passthru = { inherit generator; };
|
|
|
|
meta = generator.meta // {
|
|
inherit (dbip-country-lite.meta) license;
|
|
};
|
|
}
|