summary refs log tree commit diff
path: root/pkgs/development/libraries/geoip
diff options
context:
space:
mode:
authorHerwig Hochleitner <herwig@bendlas.net>2015-04-21 04:21:41 +0200
committerHerwig Hochleitner <herwig@bendlas.net>2015-04-21 04:21:41 +0200
commitcf07760a2cfc92b347be9159661bd104a034c7cc (patch)
tree8f244833dc7790801989dbe92cf36805f94ee9e9 /pkgs/development/libraries/geoip
parent74235b70f1d957d0f17a36d026f89fa00bc9e9a3 (diff)
downloadnixpkgs-cf07760a2cfc92b347be9159661bd104a034c7cc.tar
nixpkgs-cf07760a2cfc92b347be9159661bd104a034c7cc.tar.gz
nixpkgs-cf07760a2cfc92b347be9159661bd104a034c7cc.tar.bz2
nixpkgs-cf07760a2cfc92b347be9159661bd104a034c7cc.tar.lz
nixpkgs-cf07760a2cfc92b347be9159661bd104a034c7cc.tar.xz
nixpkgs-cf07760a2cfc92b347be9159661bd104a034c7cc.tar.zst
nixpkgs-cf07760a2cfc92b347be9159661bd104a034c7cc.zip
geoip: add geoipWithDatabase for shell use
This installs (by default) geolite-legacy as the default database for geoiplookup
Diffstat (limited to 'pkgs/development/libraries/geoip')
-rw-r--r--pkgs/development/libraries/geoip/default.nix13
1 files changed, 11 insertions, 2 deletions
diff --git a/pkgs/development/libraries/geoip/default.nix b/pkgs/development/libraries/geoip/default.nix
index 99a566cf195..77ea6b6a016 100644
--- a/pkgs/development/libraries/geoip/default.nix
+++ b/pkgs/development/libraries/geoip/default.nix
@@ -1,15 +1,24 @@
-{ stdenv, fetchurl }:
+# in geoipDatabase, you can insert a package defining ${geoipDatabase}/share/GeoIP
+# e.g. geolite-legacy
+{ stdenv, fetchurl, pkgs, drvName ? "geoip", geoipDatabase ? null }:
 
 let version = "1.6.2"; in
 
 stdenv.mkDerivation {
-  name = "geoip-${version}";
+  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
+  '';
+
   meta = {
     description = "Geolocation API";
     maintainers = [ stdenv.lib.maintainers.raskin ];