nixpkgs/pkgs/by-name/v2/v2ray-geoip/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

70 lines
1.4 KiB
Nix

{ lib
, stdenvNoCC
, fetchFromGitHub
, pkgsBuildBuild
, jq
, moreutils
, dbip-country-lite
}:
let
generator = pkgsBuildBuild.buildGoModule rec {
pname = "v2ray-geoip";
version = "202403140037";
src = fetchFromGitHub {
owner = "v2fly";
repo = "geoip";
rev = version;
hash = "sha256-nqobjgeDvD5RYvCVVd14XC/tb/+SVfvdQUFZ3gfeDrI=";
};
vendorHash = "sha256-cuKcrYAzjIt6Z4wYg5R6JeL413NDwTub2fZndXEKdTo=";
meta = with lib; {
description = "GeoIP for V2Ray";
homepage = "https://github.com/v2fly/geoip";
license = licenses.cc-by-sa-40;
maintainers = with maintainers; [ nickcao ];
};
};
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
'';
installPhase = ''
runHook preInstall
install -Dm444 -t "$out/share/v2ray" output/dat/{cn,geoip-only-cn-private,geoip,private}.dat
runHook postInstall
'';
passthru.generator = generator;
meta = generator.meta // {
inherit (dbip-country-lite.meta) license;
};
}