1 { lib, stdenv, fetchurl, afl, python2, zlib, pkg-config, glib, perl
2 , texinfo, libuuid, flex, bison, pixman, autoconf
8 cpuTarget = if stdenv.hostPlatform.system == "x86_64-linux" then "x86_64-linux-user"
9 else if stdenv.hostPlatform.system == "i686-linux" then "i386-linux-user"
10 else throw "afl: no support for ${stdenv.hostPlatform.system}!";
12 stdenv.mkDerivation rec {
18 url = "http://wiki.qemu.org/download/qemu-${version}.tar.bz2";
19 sha256 = "0j3dfxzrzdp1w21k21fjvmakzc6lcha1rsclaicwqvbf63hkk7vy";
24 sourceRoot = "qemu-${version}";
27 cp ${afl.src.name}/types.h $sourceRoot/afl-types.h
28 substitute ${afl.src.name}/config.h $sourceRoot/afl-config.h \
29 --replace "types.h" "afl-types.h"
30 substitute ${afl.src.name}/qemu_mode/patches/afl-qemu-cpu-inl.h $sourceRoot/afl-qemu-cpu-inl.h \
31 --replace "../../config.h" "afl-config.h"
32 substituteInPlace ${afl.src.name}/qemu_mode/patches/cpu-exec.diff \
33 --replace "../patches/afl-qemu-cpu-inl.h" "afl-qemu-cpu-inl.h"
37 python2 perl pkg-config flex bison autoconf texinfo
41 zlib glib pixman libuuid
44 enableParallelBuilding = true;
47 # patches extracted from afl source
48 "../${afl.src.name}/qemu_mode/patches/cpu-exec.diff"
49 "../${afl.src.name}/qemu_mode/patches/elfload.diff"
50 "../${afl.src.name}/qemu_mode/patches/syscall.diff"
51 "../${afl.src.name}/qemu_mode/patches/configure.diff"
52 "../${afl.src.name}/qemu_mode/patches/memfd.diff"
53 # nix-specific patches to make installation more well-behaved
54 ./qemu-patches/no-etc-install.patch
55 # patch for fixing qemu build on glibc >= 2.30
56 ./qemu-patches/syscall-glibc2_30.diff
66 "--target-list=${cpuTarget}"
69 "--localstatedir=/var"
73 homepage = "http://www.qemu.org/";
74 description = "Fork of QEMU with AFL instrumentation support";
75 license = licenses.gpl2Plus;
76 maintainers = with maintainers; [ thoughtpolice ];
77 platforms = platforms.linux;