Skip to content

Commit

Permalink
geoip: set default dir to '/var/lib/geoip-databases'
Browse files Browse the repository at this point in the history
  • Loading branch information
Volth authored and bjornfor committed Aug 19, 2017
1 parent 95bb851 commit 8b4f537
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions pkgs/development/libraries/geoip/default.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
# in geoipDatabase, you can insert a package defining ${geoipDatabase}/share/GeoIP
# e.g. geolite-legacy
{ stdenv, fetchurl, pkgs, drvName ? "geoip", geoipDatabase ? null }:
{ stdenv, fetchurl, pkgs, drvName ? "geoip", geoipDatabase ? "/var/lib/geoip-databases" }:

let version = "1.6.2"; in

stdenv.mkDerivation {
let version = "1.6.2";
dataDir = if (stdenv.lib.isDerivation geoipDatabase) then "${toString geoipDatabase}/share/GeoIP" else geoipDatabase;
in stdenv.mkDerivation {
name = "${drvName}-${version}";

src = fetchurl {
url = "http://geolite.maxmind.com/download/geoip/api/c/GeoIP-${version}.tar.gz";
sha256 = "0dd6si4cvip73kxdn43apg6yygvaf7dnk5awqfg9w2fd2ll0qnh7";
};

postInstall = ''
DB=${toString geoipDatabase}
if [ -n "$DB" ]; then
ln -s $DB/share/GeoIP $out/share/GeoIP
fi
postPatch = ''
find . -name Makefile.in -exec sed -i -r 's#^pkgdatadir\s*=.+$#pkgdatadir = ${dataDir}#' {} \;
'';

meta = {
Expand Down

0 comments on commit 8b4f537

Please sign in to comment.