1{ buildPythonPackage, fetchFromGitHub, lib, isPyPy, isPy3k, pythonOlder
2, pycrypto, ecdsa # TODO
3, enum34, mock
4, withOptionalDeps ? true, tcpdump, ipython
5, withCryptography ? true, cryptography
6, withVoipSupport ? true, sox
7, withPlottingSupport ? true, matplotlib
8, withGraphicsSupport ? false, pyx, texlive, graphviz, imagemagick
9, withManufDb ? false, wireshark
10# 2D/3D graphics and graphs TODO: VPython
11# TODO: nmap, numpy
12}:
13
14buildPythonPackage rec {
15 pname = "scapy";
16 version = "2.4.3";
17
18 disabled = isPyPy;
19
20 src = fetchFromGitHub {
21 owner = "secdev";
22 repo = "scapy";
23 rev = "v${version}";
24 sha256 = "08ypdzp0p3gvmz3pwi0i9q5f7hz9cq8yn6gawia49ynallwnv4zy";
25 };
26
27 # TODO: Temporary workaround
28 patches = [ ./fix-version.patch ];
29
30 postPatch = ''
31 sed -i "s/NIXPKGS_SCAPY_VERSION/${version}/" scapy/__init__.py
32 '' + lib.optionalString withManufDb ''
33 substituteInPlace scapy/data.py --replace "/opt/wireshark" "${wireshark}"
34 '';
35
36 propagatedBuildInputs = [ pycrypto ecdsa ]
37 ++ lib.optionals withOptionalDeps [ tcpdump ipython ]
38 ++ lib.optional withCryptography cryptography
39 ++ lib.optional withVoipSupport sox
40 ++ lib.optional withPlottingSupport matplotlib
41 ++ lib.optionals withGraphicsSupport [ pyx texlive.combined.scheme-minimal graphviz imagemagick ]
42 ++ lib.optional (isPy3k && pythonOlder "3.4") enum34
43 ++ lib.optional doCheck mock;
44
45 # Tests fail with Python 3.6 (seems to be an upstream bug, I'll investigate)
46 doCheck = if isPy3k then false else true;
47
48 meta = with lib; {
49 description = "Powerful interactive network packet manipulation program";
50 homepage = https://scapy.net/;
51 license = licenses.gpl2;
52 platforms = platforms.unix;
53 maintainers = with maintainers; [ primeos bjornfor ];
54 };
55}