summary refs log tree commit diff
path: root/pkgs/tools/networking/ntopng/default.nix
blob: 06d28e844ff31105aadeae5777c225275f2dbc17 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{ stdenv, fetchurl, libpcap,/* gnutls, libgcrypt,*/ libxml2, glib
, geoip, geolite-legacy, sqlite, which, autoreconfHook, git
, pkgconfig, groff, curl, json_c, luajit, zeromq, rrdtool
}:

# ntopng includes LuaJIT, mongoose, rrdtool and zeromq in its third-party/
# directory, but we use luajit, zeromq, and rrdtool from nixpkgs

stdenv.mkDerivation rec {
  name = "ntopng-2.0";

  src = fetchurl {
    urls = [
      "mirror://sourceforge/project/ntop/ntopng/old/${name}.tar.gz"
      "mirror://sourceforge/project/ntop/ntopng/${name}.tar.gz"
    ];
    sha256 = "0l82ivh05cmmqcvs26r6y69z849d28njipphqzvnakf43ggddgrw";
  };

  patches = [
    ./0001-Undo-weird-modification-of-data_dir.patch
    ./0002-Remove-requirement-to-have-writeable-callback-dir.patch
  ];

  buildInputs = [ libpcap/* gnutls libgcrypt*/ libxml2 glib geoip geolite-legacy
    sqlite which autoreconfHook git pkgconfig groff curl json_c luajit zeromq
    rrdtool ];


  autoreconfPhase = ''
    substituteInPlace autogen.sh --replace "/bin/rm" "rm"
    substituteInPlace nDPI/autogen.sh --replace "/bin/rm" "rm"
    $shell autogen.sh
  '';

  preConfigure = ''
    substituteInPlace Makefile.in --replace "/bin/rm" "rm"
  '';

  preBuild = ''
    substituteInPlace src/Ntop.cpp --replace "/usr/local" "$out"

    sed -e "s|\(#define CONST_DEFAULT_DATA_DIR\).*|\1 \"/var/lib/ntopng\"|g" \
        -e "s|\(#define CONST_DEFAULT_DOCS_DIR\).*|\1 \"$out/share/ntopng/httpdocs\"|g" \
        -e "s|\(#define CONST_DEFAULT_SCRIPTS_DIR\).*|\1 \"$out/share/ntopng/scripts\"|g" \
        -e "s|\(#define CONST_DEFAULT_CALLBACKS_DIR\).*|\1 \"$out/share/ntopng/scripts/callbacks\"|g" \
        -e "s|\(#define CONST_DEFAULT_INSTALL_DIR\).*|\1 \"$out/share/ntopng\"|g" \
        -i include/ntop_defines.h

    rm -rf httpdocs/geoip
    ln -s ${geolite-legacy}/share/GeoIP httpdocs/geoip
  '' + stdenv.lib.optionalString stdenv.isDarwin ''
    sed 's|LIBS += -lstdc++.6||' -i Makefile
  '';

  NIX_CFLAGS_COMPILE = [ "-fpermissive" ]
    ++ stdenv.lib.optional stdenv.cc.isClang "-Wno-error=reserved-user-defined-literal";

  meta = with stdenv.lib; {
    description = "High-speed web-based traffic analysis and flow collection tool";
    homepage = http://www.ntop.org/products/ntop/;
    license = licenses.gpl3Plus;
    platforms = platforms.linux ++ platforms.darwin;
    maintainers = [ maintainers.bjornfor ];
  };
}