lol
1{ lib
2, stdenv
3, fetchFromGitHub
4, fetchpatch
5, installShellFiles
6, makeWrapper
7, libpcap
8}:
9
10stdenv.mkDerivation rec {
11 pname = "masscan";
12 version = "1.3.2";
13
14 src = fetchFromGitHub {
15 owner = "robertdavidgraham";
16 repo = "masscan";
17 rev = version;
18 sha256 = "sha256-mnGC/moQANloR5ODwRjzJzBa55OEZ9QU+9WpAHxQE/g=";
19 };
20
21 patches = [
22 # Patches the missing "--resume" functionality
23 (fetchpatch {
24 name = "resume.patch";
25 url = "https://github.com/robertdavidgraham/masscan/commit/90791550bbdfac8905917a109ed74024161f14b3.patch";
26 sha256 = "sha256-A7Fk3MBNxaad69MrUYg7fdMG77wba5iESDTIRigYslw=";
27 })
28 ];
29
30 postPatch = lib.optionalString stdenv.isDarwin ''
31 # Fix broken install command
32 substituteInPlace Makefile --replace "-pm755" "-pDm755"
33 '';
34
35 nativeBuildInputs = [ makeWrapper installShellFiles ];
36
37 makeFlags = [
38 "PREFIX=$(out)"
39 "GITVER=${version}"
40 "CC=${stdenv.cc.targetPrefix}cc"
41 ];
42
43 enableParallelBuilding = true;
44
45 postInstall = ''
46 installManPage doc/masscan.?
47
48 install -Dm444 -t $out/etc/masscan data/exclude.conf
49 install -Dm444 -t $out/share/doc/masscan doc/*.{html,js,md}
50 install -Dm444 -t $out/share/licenses/masscan LICENSE
51
52 wrapProgram $out/bin/masscan \
53 --prefix LD_LIBRARY_PATH : "${libpcap}/lib"
54 '';
55
56 doInstallCheck = true;
57
58 installCheckPhase = ''
59 $out/bin/masscan --selftest
60 '';
61
62 meta = with lib; {
63 description = "Fast scan of the Internet";
64 mainProgram = "masscan";
65 homepage = "https://github.com/robertdavidgraham/masscan";
66 changelog = "https://github.com/robertdavidgraham/masscan/releases/tag/${version}";
67 license = licenses.agpl3Only;
68 platforms = platforms.unix;
69 maintainers = with maintainers; [ rnhmjoj ];
70 };
71}