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