summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/netmap
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/python-modules/netmap')
-rw-r--r--pkgs/development/python-modules/netmap/default.nix43
-rw-r--r--pkgs/development/python-modules/netmap/nmap-path.patch17
2 files changed, 60 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/netmap/default.nix b/pkgs/development/python-modules/netmap/default.nix
new file mode 100644
index 000000000000..012599216074
--- /dev/null
+++ b/pkgs/development/python-modules/netmap/default.nix
@@ -0,0 +1,43 @@
+{ lib
+, buildPythonPackage
+, fetchFromGitHub
+, substituteAll
+, nmap
+, python
+}:
+
+buildPythonPackage rec {
+ pname = "netmap";
+ version = "0.7.0.2";
+
+ src = fetchFromGitHub {
+ owner = "home-assistant-libs";
+ repo = "python-nmap";
+ rev = version;
+ sha256 = "1a44zz9zsxy48ahlpjjrddpyfi7cnfknicfcp35hi588qm430mag";
+ };
+
+ patches = [
+ (substituteAll {
+ src = ./nmap-path.patch;
+ nmap = "${lib.getBin nmap}/bin/nmap";
+ })
+ ];
+
+ # upstream tests require sudo
+ # make sure nmap is found instead
+ checkPhase = ''
+ runHook preCheck
+ ${python.interpreter} -c 'import nmap; nmap.PortScanner()'
+ runHook postCheck
+ '';
+
+ pythonImportsCheck = [ "nmap" ];
+
+ meta = with lib; {
+ description = "Python class to use nmap and access scan results from python3";
+ homepage = "https://github.com/home-assistant-libs/python-nmap";
+ license = licenses.gpl3Plus;
+ maintainers = with maintainers; [ dotlambda ];
+ };
+}
diff --git a/pkgs/development/python-modules/netmap/nmap-path.patch b/pkgs/development/python-modules/netmap/nmap-path.patch
new file mode 100644
index 000000000000..99f9cb43a940
--- /dev/null
+++ b/pkgs/development/python-modules/netmap/nmap-path.patch
@@ -0,0 +1,17 @@
+diff --git a/nmap/nmap.py b/nmap/nmap.py
+index 91c460d..8c5ff0a 100755
+--- a/nmap/nmap.py
++++ b/nmap/nmap.py
+@@ -77,11 +77,7 @@ class PortScanner(object):
+ def __init__(
+ self,
+ nmap_search_path=(
+- "nmap",
+- "/usr/bin/nmap",
+- "/usr/local/bin/nmap",
+- "/sw/bin/nmap",
+- "/opt/local/bin/nmap",
++ "@nmap@",
+ ),
+ ):
+ """