1 { lib, stdenv, fetchurl, aflplusplus, python3, zlib, pkg-config, glib, perl
2 , texinfo, libuuid, flex, bison, pixman, autoconf
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}!";
14 name = "aflplusplus-${qemuName}";
18 url = "http://wiki.qemu.org/download/${qemuName}.tar.bz2";
19 sha256 = "08frr1fdjx8qcfh3fafn10kibdwbvkqqvfl7hpqbm7i9dg4f1zlq";
24 sourceRoot = qemuName;
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
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
47 python3 perl pkg-config flex bison autoconf texinfo
51 zlib glib pixman libuuid
54 enableParallelBuilding = true;
57 # patches extracted from aflplusplus source
59 # nix-specific patches to make installation more well-behaved
60 ./qemu-no-etc-install.patch
70 "--target-list=${cpuTarget}"
73 "--localstatedir=/var"
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;