python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / tools / security / aflplusplus / qemu.nix
blob1fb613aef2e23c4836f348dda73084e4a6d5affd
1 { lib, stdenv, fetchurl, aflplusplus, python3, zlib, pkg-config, glib, perl
2 , texinfo, libuuid, flex, bison, pixman, autoconf
3 }:
5 with lib;
7 let
8   qemuName = "qemu-3.1.0";
9   cpuTarget = if stdenv.targetPlatform.system == "x86_64-linux" then "x86_64-linux-user"
10     else if stdenv.targetPlatform.system == "i686-linux" then "i386-linux-user"
11     else throw "aflplusplus: no support for ${stdenv.targetPlatform.system}!";
13 stdenv.mkDerivation {
14   name = "aflplusplus-${qemuName}";
16   srcs = [
17     (fetchurl {
18       url = "http://wiki.qemu.org/download/${qemuName}.tar.bz2";
19       sha256 = "08frr1fdjx8qcfh3fafn10kibdwbvkqqvfl7hpqbm7i9dg4f1zlq";
20     })
21     aflplusplus.src
22   ];
24   sourceRoot = qemuName;
26   postUnpack = ''
27     chmod -R +w ${aflplusplus.src.name}
28     for f in ${aflplusplus.src.name}/qemu_mode/patches/* ; do
29       sed -E -i 's|(\.\./)+patches/([a-z-]+\.h)|\2|g' $f
30       sed -E -i 's|\.\./\.\./config\.h|afl-config.h|g' $f
31       sed -E -i 's|\.\./\.\./include/cmplog\.h|afl-cmplog.h|g' $f
32     done
33     cp ${aflplusplus.src.name}/qemu_mode/patches/*.h $sourceRoot/
34     cp ${aflplusplus.src.name}/types.h $sourceRoot/afl-types.h
35     substitute ${aflplusplus.src.name}/config.h $sourceRoot/afl-config.h \
36       --replace "types.h" "afl-types.h"
37     substitute ${aflplusplus.src.name}/include/cmplog.h $sourceRoot/afl-cmplog.h \
38       --replace "config.h" "afl-config.h" \
39       --replace "forkserver.h" "afl-forkserver.h"
40     substitute ${aflplusplus.src.name}/include/forkserver.h $sourceRoot/afl-forkserver.h \
41       --replace "types.h" "afl-types.h"
43     cat ${aflplusplus.src.name}/qemu_mode/patches/*.diff > all.patch
44   '';
46   nativeBuildInputs = [
47     python3 perl pkg-config flex bison autoconf texinfo
48   ];
50   buildInputs = [
51     zlib glib pixman libuuid
52   ];
54   enableParallelBuilding = true;
56   patches = [
57     # patches extracted from aflplusplus source
58     "../all.patch"
59     # nix-specific patches to make installation more well-behaved
60     ./qemu-no-etc-install.patch
61   ];
63   configureFlags =
64     [ "--disable-system"
65       "--enable-linux-user"
66       "--disable-gtk"
67       "--disable-sdl"
68       "--disable-vnc"
69       "--disable-kvm"
70       "--target-list=${cpuTarget}"
71       "--enable-pie"
72       "--sysconfdir=/etc"
73       "--localstatedir=/var"
74     ];
76   meta = with lib; {
77     homepage = "https://www.qemu.org/";
78     description = "Fork of QEMU with AFL++ instrumentation support";
79     license = licenses.gpl2Plus;
80     maintainers = with maintainers; [ ris ];
81     platforms = platforms.linux;
82   };