2022-07-14 12:49:19 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, autoreconfHook
|
2020-04-24 23:36:52 +00:00
|
|
|
, drvName ? "geoip"
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
# in geoipDatabase, you can insert a package defining
|
|
|
|
# "${geoipDatabase}/share/GeoIP" e.g. geolite-legacy
|
2020-04-24 23:36:52 +00:00
|
|
|
, geoipDatabase ? "/var/lib/geoip-databases"
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2022-07-14 12:49:19 +00:00
|
|
|
dataDir =
|
|
|
|
if lib.isDerivation geoipDatabase
|
2020-04-24 23:36:52 +00:00
|
|
|
then "${toString geoipDatabase}/share/GeoIP"
|
|
|
|
else geoipDatabase;
|
2022-07-14 12:49:19 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = drvName;
|
|
|
|
version = "1.6.12";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2022-07-14 12:49:19 +00:00
|
|
|
owner = "maxmind";
|
|
|
|
repo = "geoip-api-c";
|
|
|
|
rev = "v${version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
sha256 = "0ixyp3h51alnncr17hqp1p0rlqz9w69nlhm60rbzjjz3vjx52ajv";
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ autoreconfHook ];
|
|
|
|
|
|
|
|
# Cross compilation shenanigans
|
2021-02-05 17:12:51 +00:00
|
|
|
configureFlags = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
2020-04-24 23:36:52 +00:00
|
|
|
"ac_cv_func_malloc_0_nonnull=yes"
|
|
|
|
"ac_cv_func_realloc_0_nonnull=yes"
|
|
|
|
];
|
|
|
|
|
|
|
|
# Fix up the default data directory
|
|
|
|
postConfigure = ''
|
|
|
|
find . -name Makefile.in -exec sed -i -r 's#^pkgdatadir\s*=.+$#pkgdatadir = ${dataDir}#' {} \;
|
|
|
|
'';
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
passthru = { inherit dataDir; };
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "An API for GeoIP/Geolocation databases";
|
|
|
|
maintainers = with maintainers; [ thoughtpolice raskin ];
|
2022-07-14 12:49:19 +00:00
|
|
|
license = licenses.lgpl21;
|
|
|
|
platforms = platforms.unix;
|
|
|
|
homepage = "https://www.maxmind.com";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|