summary refs log tree commit diff
path: root/pkgs/applications/misc/kiwix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/misc/kiwix')
-rw-r--r--pkgs/applications/misc/kiwix/default.nix94
1 files changed, 46 insertions, 48 deletions
diff --git a/pkgs/applications/misc/kiwix/default.nix b/pkgs/applications/misc/kiwix/default.nix
index 91076f0bf99d..b0590fdc38f7 100644
--- a/pkgs/applications/misc/kiwix/default.nix
+++ b/pkgs/applications/misc/kiwix/default.nix
@@ -1,9 +1,12 @@
-{ stdenv, callPackage, overrideCC, fetchurl, makeWrapper, pkgconfig
-, zip, python, zlib, which, icu, libmicrohttpd, lzma, ctpp2, aria2, wget, bc
+{ stdenv, fetchurl, makeWrapper, pkgconfig
+, zip, python, zlib, which, icu, libmicrohttpd, lzma, aria2, wget, bc
 , libuuid, glibc, libX11, libXext, libXt, libXrender, glib, dbus, dbus_glib
-, gtk2, gdk_pixbuf, pango, cairo , freetype, fontconfig, alsaLib, atk
+, gtk2, gdk_pixbuf, pango, cairo, freetype, fontconfig, alsaLib, atk, cmake
+, xapian, ctpp2, zimlib
 }:
 
+with stdenv.lib;
+
 let
   xulrunner64_tar = fetchurl {
     url = http://download.kiwix.org/dev/xulrunner-29.0.en-US.linux-x86_64.tar.bz2;
@@ -22,18 +25,38 @@ let
     sha256 = "1h9vcbvf8wgds6i2z20y7krpys0mqsqhv1ijyfljanp6vyll9fvi";
   };
 
-  xulrunner_tar = if stdenv.system == "x86_64-linux" then xulrunner64_tar else xulrunner32_tar;
-  xulrunnersdk_tar = if stdenv.system == "x86_64-linux" then xulrunnersdk64_tar else xulrunnersdk32_tar;
-  pugixml_tar = fetchurl {
-    url = http://download.kiwix.org/dev/pugixml-1.2.tar.gz;
-    sha256 = "0sqk0vdwjq44jxbbkj1cy8qykrmafs1sickzldb2w2nshsnjshhg";
-  };
+  xulrunner = if stdenv.system == "x86_64-linux"
+              then { tar = xulrunner64_tar; sdk = xulrunnersdk64_tar; }
+              else { tar = xulrunner32_tar; sdk = xulrunnersdk32_tar; };
+
+  ctpp2_ = ctpp2.override { inherit stdenv; };
+  xapian_ = xapian.override { inherit stdenv; };
+  zimlib_ = zimlib.override { inherit stdenv; };
+
+  pugixml = stdenv.mkDerivation rec {
+    version = "1.2";
+    name = "pugixml-${version}";
 
-  xapian = callPackage ../../../development/libraries/xapian { inherit stdenv; };
-  zimlib = callPackage ../../../development/libraries/zimlib { inherit stdenv; };
+    src = fetchurl {
+      url = "http://download.kiwix.org/dev/${name}.tar.gz";
+      sha256 = "0sqk0vdwjq44jxbbkj1cy8qykrmafs1sickzldb2w2nshsnjshhg";
+    };
+
+    buildInputs = [ cmake ];
+
+    unpackPhase = ''
+      # not a nice src archive: all the files are in the root :(
+      mkdir ${name}
+      cd ${name}
+      tar -xf ${src}
+
+      # and the build scripts are in there :'(
+      cd scripts
+    '';
+  };
 
 in
-with stdenv.lib;
+
 stdenv.mkDerivation rec {
   name = "kiwix-${version}";
   version = "0.9";
@@ -44,57 +67,32 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs = [
-    zip
-    pkgconfig
-    python
-    zlib
-    xapian
-    which
-    icu
-    libmicrohttpd
-    lzma
-    zimlib
-    ctpp2
-    aria2
-    wget
-    bc
-    libuuid
-    makeWrapper
+    zip pkgconfig python zlib xapian_ which icu libmicrohttpd
+    lzma zimlib_ ctpp2_ aria2 wget bc libuuid makeWrapper pugixml
   ];
 
   postUnpack = ''
-    cd kiwix-*
+    cd kiwix*
     mkdir static
     cp Makefile.in static/
 
     cd src/dependencies
-    cp ${pugixml_tar} pugixml-1.2.tar.gz
 
-    tar -xf ${xulrunner_tar}
-    tar -xf ${xulrunnersdk_tar}
+    tar -xf ${xulrunner.tar}
+    tar -xf ${xulrunner.sdk}
 
     cd ../../..
   '';
 
-  configurePhase = ''
-    bash ./configure --disable-static --disable-dependency-tracking --prefix=$out --with-libpugixml=SELF
-  '';
-
-  buildPhase = ''
-    cd src/dependencies
-    make pugixml-1.2/libpugixml.a
-
-    cd ../..
-    bash ./configure --disable-static --disable-dependency-tracking --prefix=$out --with-libpugixml=SELF
-
-    make
-  '';
+  configureFlags = [
+    "--disable-static"
+    "--disable-staticbins"
+  ];
 
-  installPhase = ''
-    make install
+  postInstall = ''
     cp -r src/dependencies/xulrunner $out/lib/kiwix
 
-    patchelf --set-interpreter ${glibc.out}/lib/ld-linux${optionalString (stdenv.system == "x86_64-linux") "-x86-64"}.so.2 $out/lib/kiwix/xulrunner/xulrunner
+    patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/lib/kiwix/xulrunner/xulrunner
 
     rm $out/bin/kiwix
     makeWrapper $out/lib/kiwix/kiwix-launcher $out/bin/kiwix \