nixpkgs/pkgs/data/misc/sing-geoip/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
1.4 KiB
Nix
Raw Normal View History

2023-02-25 06:20:56 +00:00
{ lib
, stdenvNoCC
, buildGoModule
, fetchFromGitHub
, dbip-country-lite
2023-02-25 06:20:56 +00:00
}:
let
generator = buildGoModule rec {
pname = "sing-geoip";
version = "20240312";
2023-02-25 06:20:56 +00:00
src = fetchFromGitHub {
owner = "SagerNet";
repo = pname;
rev = "refs/tags/${version}";
hash = "sha256-nIrbiECK25GyuPEFqMvPdZUShC2JC1NI60Y10SsoWyY=";
2023-02-25 06:20:56 +00:00
};
vendorHash = "sha256-WH0eMg06qCiVcy4H+vBtYrmLMA2KJRCPGXiEnatW+LU=";
postPatch = ''
sed -i -e '/func main()/,/^}/d' main.go
cat ${./main.go} >> main.go
'';
2023-02-25 06:20:56 +00:00
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";
2023-02-25 06:20:56 +00:00
};
};
in
stdenvNoCC.mkDerivation {
2023-02-25 06:20:56 +00:00
inherit (generator) pname;
inherit (dbip-country-lite) version;
2023-02-25 06:20:56 +00:00
dontUnpack = true;
nativeBuildInputs = [ generator ];
buildPhase = ''
runHook preBuild
sing-geoip ${dbip-country-lite.mmdb}
2023-02-25 06:20:56 +00: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
install -Dm644 rule-set/* -t $out/share/sing-box/rule-set
2023-02-25 06:20:56 +00:00
runHook postInstall
'';
passthru = { inherit generator; };
meta = generator.meta // {
inherit (dbip-country-lite.meta) license;
2023-02-25 06:20:56 +00:00
};
}