summary refs log tree commit diff
path: root/pkgs/tools/security/nmap/default.nix
diff options
context:
space:
mode:
authorAneesh Agrawal <aneeshusa@gmail.com>2016-09-01 23:52:34 -0400
committerFrederik Rietdijk <fridh@fridh.nl>2016-09-24 15:05:28 +0200
commit6321a1b67c869b70520ab9479c86b198c439bca9 (patch)
tree16ff660e3c10486970b64611ea4742a7050f4246 /pkgs/tools/security/nmap/default.nix
parentc8dba2581cb449eb6d87968df0edd7f9b62d12eb (diff)
downloadnixpkgs-6321a1b67c869b70520ab9479c86b198c439bca9.tar
nixpkgs-6321a1b67c869b70520ab9479c86b198c439bca9.tar.gz
nixpkgs-6321a1b67c869b70520ab9479c86b198c439bca9.tar.bz2
nixpkgs-6321a1b67c869b70520ab9479c86b198c439bca9.tar.lz
nixpkgs-6321a1b67c869b70520ab9479c86b198c439bca9.tar.xz
nixpkgs-6321a1b67c869b70520ab9479c86b198c439bca9.tar.zst
nixpkgs-6321a1b67c869b70520ab9479c86b198c439bca9.zip
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.
Diffstat (limited to 'pkgs/tools/security/nmap/default.nix')
-rw-r--r--pkgs/tools/security/nmap/default.nix23
1 files changed, 17 insertions, 6 deletions
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
     ];