1{ stdenv, fetchurl, libpcap, pkgconfig, openssl
2, graphicalSupport ? false
3, libX11 ? null
4, gtk2 ? null
5, withPython ? false # required for the `ndiff` binary
6, python2Packages ? null
7, makeWrapper ? null
8}:
9
10assert withPython -> python2Packages != null;
11
12with stdenv.lib;
13
14let
15
16 # Zenmap (the graphical program) also requires Python,
17 # so automatically enable pythonSupport if graphicalSupport is requested.
18 pythonSupport = withPython || graphicalSupport;
19
20in stdenv.mkDerivation rec {
21 name = "nmap${optionalString graphicalSupport "-graphical"}-${version}";
22 version = "7.60";
23
24 src = fetchurl {
25 url = "https://nmap.org/dist/nmap-${version}.tar.bz2";
26 sha256 = "08bga42ipymmbxd7wy4x5sl26c0ir1fm3n9rc6nqmhx69z66wyd8";
27 };
28
29 patches = ./zenmap.patch;
30
31 prePatch = optionalString stdenv.isDarwin ''
32 substituteInPlace libz/configure \
33 --replace /usr/bin/libtool ar \
34 --replace 'AR="libtool"' 'AR="ar"' \
35 --replace 'ARFLAGS="-o"' 'ARFLAGS="-r"'
36 '';
37
38 configureFlags = []
39 ++ optional (!pythonSupport) "--without-ndiff"
40 ++ optional (!graphicalSupport) "--without-zenmap"
41 ;
42
43 postInstall = optionalString pythonSupport ''
44 wrapProgram $out/bin/ndiff --prefix PYTHONPATH : "$(toPythonPath $out)" --prefix PYTHONPATH : "$PYTHONPATH"
45 '' + optionalString graphicalSupport ''
46 wrapProgram $out/bin/zenmap --prefix PYTHONPATH : "$(toPythonPath $out)" --prefix PYTHONPATH : "$PYTHONPATH" --prefix PYTHONPATH : $(toPythonPath $pygtk)/gtk-2.0 --prefix PYTHONPATH : $(toPythonPath $pygobject)/gtk-2.0 --prefix PYTHONPATH : $(toPythonPath $pycairo)/gtk-2.0
47 '';
48
49 nativeBuildInputs = [ pkgconfig ];
50 buildInputs = with python2Packages; [ libpcap openssl ]
51 ++ optionals pythonSupport [ makeWrapper python ]
52 ++ optionals graphicalSupport [
53 libX11 gtk2 pygtk pysqlite pygobject2 pycairo
54 ];
55
56 meta = {
57 description = "A free and open source utility for network discovery and security auditing";
58 homepage = http://www.nmap.org;
59 license = licenses.gpl2;
60 platforms = platforms.all;
61 maintainers = with maintainers; [ thoughtpolice fpletz ];
62 };
63}