nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenv
3, fetchFromGitHub
4, pkg-config
5, fixDarwinDylibNames
6}:
7
8stdenv.mkDerivation rec {
9 pname = "capstone";
10 version = "4.0.2";
11
12 src = fetchFromGitHub {
13 owner = "aquynh";
14 repo = "capstone";
15 rev = version;
16 sha256 = "sha256-XMwQ7UaPC8YYu4yxsE4bbR3leYPfBHu5iixSLz05r3g=";
17 };
18
19 # replace faulty macos detection
20 postPatch = lib.optionalString stdenv.isDarwin ''
21 sed -i 's/^IS_APPLE := .*$/IS_APPLE := 1/' Makefile
22 '';
23
24 configurePhase = "patchShebangs make.sh ";
25 buildPhase = "PREFIX=$out ./make.sh";
26
27 doCheck = true;
28 checkPhase = ''
29 # first remove fuzzing steps from check target
30 substituteInPlace Makefile --replace "fuzztest fuzzallcorp" ""
31 make check
32 '';
33
34 installPhase = (lib.optionalString stdenv.isDarwin "HOMEBREW_CAPSTONE=1 ")
35 + "PREFIX=$out ./make.sh install";
36
37 nativeBuildInputs = [
38 pkg-config
39 ] ++ lib.optionals stdenv.isDarwin [
40 fixDarwinDylibNames
41 ];
42
43 enableParallelBuilding = true;
44
45 meta = {
46 description = "Advanced disassembly library";
47 homepage = "http://www.capstone-engine.org";
48 license = lib.licenses.bsd3;
49 maintainers = with lib.maintainers; [ thoughtpolice ris ];
50 mainProgram = "cstool";
51 platforms = lib.platforms.unix;
52 };
53}