From 6321a1b67c869b70520ab9479c86b198c439bca9 Mon Sep 17 00:00:00 2001 From: Aneesh Agrawal Date: Thu, 1 Sep 2016 23:52:34 -0400 Subject: nmap: pin to Python 2, make Python optional Python 3 is not supported, so use python2Packages. Python is only required for the `ndiff` and `zenmap` binaries, not the main `nmap` binary, so disable Python by default to reduce the default closure size, and add a `withPython` arg to re-enable it. Note that Zenmap is the graphical program, so passing `graphicalSupport = true` will also automatically enable Python support. --- pkgs/tools/security/nmap/default.nix | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'pkgs/tools/security/nmap/default.nix') diff --git a/pkgs/tools/security/nmap/default.nix b/pkgs/tools/security/nmap/default.nix index 3bc5d415834..ff32ba6fa25 100644 --- a/pkgs/tools/security/nmap/default.nix +++ b/pkgs/tools/security/nmap/default.nix @@ -2,14 +2,21 @@ , graphicalSupport ? false , libX11 ? null , gtk2 ? null -, pythonPackages +, withPython ? false # required for the `ndiff` binary +, python2Packages ? null , makeWrapper ? null }: +assert withPython -> python2Packages != null; + with stdenv.lib; let - inherit (pythonPackages) python pygtk pygobject2 pycairo pysqlite; + + # Zenmap (the graphical program) also requires Python, + # so automatically enable pythonSupport if graphicalSupport is requested. + pythonSupport = withPython || graphicalSupport; + in stdenv.mkDerivation rec { name = "nmap${optionalString graphicalSupport "-graphical"}-${version}"; version = "7.12"; @@ -21,15 +28,19 @@ in stdenv.mkDerivation rec { patches = ./zenmap.patch; - configureFlags = optionalString (!graphicalSupport) "--without-zenmap"; + configureFlags = [] + ++ optional (!pythonSupport) "--without-ndiff" + ++ optional (!graphicalSupport) "--without-zenmap" + ; - postInstall = '' + postInstall = optionalString pythonSupport '' wrapProgram $out/bin/ndiff --prefix PYTHONPATH : "$(toPythonPath $out)" --prefix PYTHONPATH : "$PYTHONPATH" '' + optionalString graphicalSupport '' - wrapProgram $out/bin/zenmap --prefix PYTHONPATH : "$(toPythonPath $out)" --prefix PYTHONPATH : "$PYTHONPATH" --prefix PYTHONPATH : $(toPythonPath ${pygtk})/gtk-2.0 --prefix PYTHONPATH : $(toPythonPath ${pygobject2})/gtk-2.0 --prefix PYTHONPATH : $(toPythonPath ${pycairo})/gtk-2.0 + 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 ''; - buildInputs = [ libpcap pkgconfig openssl makeWrapper python ] + buildInputs = with python2Packages; [ libpcap pkgconfig openssl ] + ++ optionals pythonSupport [ makeWrapper python ] ++ optionals graphicalSupport [ libX11 gtk2 pygtk pysqlite pygobject2 pycairo ]; -- cgit 1.4.1