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.0";
17
18 disabled = isPyPy;
19
20 src = fetchFromGitHub {
21 owner = "secdev";
22 repo = "scapy";
23 rev = "v${version}";
24 sha256 = "0dw6kl1qi9bf3rbm79gb1h40ms8y0b5dbmpip841p2905d5r2isj";
25 };
26
27 # TODO: Temporary workaround
28 patches = [ ./fix-version-1.patch ./fix-version-2.patch ];
29
30 postPatch = lib.optionalString withManufDb ''
31 substituteInPlace scapy/data.py --replace "/opt/wireshark" "${wireshark}"
32 '';
33
34 propagatedBuildInputs = [ pycrypto ecdsa ]
35 ++ lib.optional withOptionalDeps [ tcpdump ipython ]
36 ++ lib.optional withCryptography [ cryptography ]
37 ++ lib.optional withVoipSupport [ sox ]
38 ++ lib.optional withPlottingSupport [ matplotlib ]
39 ++ lib.optional withGraphicsSupport [ pyx texlive.combined.scheme-minimal graphviz imagemagick ]
40 ++ lib.optional (isPy3k && pythonOlder "3.4") [ enum34 ]
41 ++ lib.optional doCheck [ mock ];
42
43 # Tests fail with Python 3.6 (seems to be an upstream bug, I'll investigate)
44 doCheck = if isPy3k then false else true;
45
46 meta = with lib; {
47 description = "Powerful interactive network packet manipulation program";
48 homepage = https://scapy.net/;
49 license = licenses.gpl2;
50 platforms = platforms.linux;
51 maintainers = with maintainers; [ primeos bjornfor ];
52 };
53}