diff --git a/pkgs/data/misc/sing-geoip/default.nix b/pkgs/data/misc/sing-geoip/default.nix new file mode 100644 index 000000000000..e8ea5ddd4428 --- /dev/null +++ b/pkgs/data/misc/sing-geoip/default.nix @@ -0,0 +1,66 @@ +{ lib +, stdenvNoCC +, buildGoModule +, fetchFromGitHub +, clash-geoip +}: + +let + generator = buildGoModule rec { + pname = "sing-geoip"; + version = "unstable-2022-07-05"; + + src = fetchFromGitHub { + owner = "SagerNet"; + repo = pname; + rev = "2ced72c94da4c9259c40353c375319d9d28a78f3"; + hash = "sha256-z8aP+OfTuzQNwOT3EEnI9uze/vbHTJLEiCPqIrnNUHw="; + }; + + vendorHash = "sha256-lr0XMLFxJmLqIqCuGgmsFh324jmZVj71blmStMn41Rs="; + + postPatch = '' + # The codes args should start from the third args + substituteInPlace main.go --replace "os.Args[2:]" "os.Args[3:]" + ''; + + 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; + inherit (clash-geoip) version; + + dontUnpack = true; + + nativeBuildInputs = [ generator ]; + + buildPhase = '' + runHook preBuild + + ${pname} ${clash-geoip}/etc/clash/Country.mmdb geoip.db + ${pname} ${clash-geoip}/etc/clash/Country.mmdb geoip-cn.db cn + + 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 // { + inherit (clash-geoip.meta) license; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index db942569cc54..7add1dd013c1 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12022,6 +12022,8 @@ with pkgs; sing-geosite = callPackage ../data/misc/sing-geosite { }; + sing-geoip = callPackage ../data/misc/sing-geoip { }; + sipcalc = callPackage ../tools/networking/sipcalc { }; skribilo = callPackage ../tools/typesetting/skribilo {