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.
This commit is contained in:
Aneesh Agrawal 2016-09-01 23:52:34 -04:00 committed by Frederik Rietdijk
parent c8dba2581c
commit 6321a1b67c

View file

@ -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
];