nixpkgs/pkgs/tools/security/aflplusplus/qemu.nix
Profpatsch 4a7f99d55d treewide: with stdenv.lib; in meta -> with lib;
Part of: https://github.com/NixOS/nixpkgs/issues/108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
2021-01-11 10:38:22 +01:00

84 lines
2.5 KiB
Nix

{ lib, stdenv, fetchurl, aflplusplus, python2, zlib, pkgconfig, glib, perl
, texinfo, libuuid, flex, bison, pixman, autoconf
}:
with stdenv.lib;
let
qemuName = "qemu-3.1.0";
cpuTarget = if stdenv.targetPlatform.system == "x86_64-linux" then "x86_64-linux-user"
else if stdenv.targetPlatform.system == "i686-linux" then "i386-linux-user"
else throw "aflplusplus: no support for ${stdenv.targetPlatform.system}!";
in
stdenv.mkDerivation {
name = "aflplusplus-${qemuName}";
srcs = [
(fetchurl {
url = "http://wiki.qemu.org/download/${qemuName}.tar.bz2";
sha256 = "08frr1fdjx8qcfh3fafn10kibdwbvkqqvfl7hpqbm7i9dg4f1zlq";
})
aflplusplus.src
];
sourceRoot = qemuName;
postUnpack = ''
chmod -R +w ${aflplusplus.src.name}
for f in ${aflplusplus.src.name}/qemu_mode/patches/* ; do
sed -E -i 's|(\.\./)+patches/([a-z-]+\.h)|\2|g' $f
sed -E -i 's|\.\./\.\./config\.h|afl-config.h|g' $f
sed -E -i 's|\.\./\.\./include/cmplog\.h|afl-cmplog.h|g' $f
done
cp ${aflplusplus.src.name}/qemu_mode/patches/*.h $sourceRoot/
cp ${aflplusplus.src.name}/types.h $sourceRoot/afl-types.h
substitute ${aflplusplus.src.name}/config.h $sourceRoot/afl-config.h \
--replace "types.h" "afl-types.h"
substitute ${aflplusplus.src.name}/include/cmplog.h $sourceRoot/afl-cmplog.h \
--replace "config.h" "afl-config.h" \
--replace "forkserver.h" "afl-forkserver.h"
substitute ${aflplusplus.src.name}/include/forkserver.h $sourceRoot/afl-forkserver.h \
--replace "types.h" "afl-types.h"
cat ${aflplusplus.src.name}/qemu_mode/patches/*.diff > all.patch
'';
nativeBuildInputs = [
python2 perl pkgconfig flex bison autoconf texinfo
];
buildInputs = [
zlib glib pixman libuuid
];
enableParallelBuilding = true;
patches = [
# patches extracted from aflplusplus source
"../all.patch"
# nix-specific patches to make installation more well-behaved
./qemu-no-etc-install.patch
];
configureFlags =
[ "--disable-system"
"--enable-linux-user"
"--disable-gtk"
"--disable-sdl"
"--disable-vnc"
"--disable-kvm"
"--target-list=${cpuTarget}"
"--enable-pie"
"--sysconfdir=/etc"
"--localstatedir=/var"
];
meta = with lib; {
homepage = "https://www.qemu.org/";
description = "Fork of QEMU with AFL++ instrumentation support";
license = licenses.gpl2Plus;
maintainers = with maintainers; [ ris ];
platforms = platforms.linux;
};
}