1{ lib
2, stdenv
3, fetchFromGitHub
4, pkg-config
5, cmake
6, IOKit
7, cctools
8}:
9
10stdenv.mkDerivation rec {
11 pname = "unicorn";
12 version = "2.0.1.post1";
13
14 src = fetchFromGitHub {
15 owner = "unicorn-engine";
16 repo = pname;
17 rev = version;
18 hash = "sha256-Jz5C35rwnDz0CXcfcvWjkwScGNQO1uijF7JrtZhM7mI=";
19 };
20
21 nativeBuildInputs = [
22 cmake
23 pkg-config
24 ] ++ lib.optionals stdenv.isDarwin [
25 cctools
26 ];
27
28 buildInputs = lib.optionals stdenv.isDarwin [
29 IOKit
30 ];
31
32 # Ensure the linker is using atomic when compiling for RISC-V, otherwise fails
33 NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isRiscV "-latomic";
34
35 cmakeFlags = lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
36 # Some x86 tests are interrupted by signal 10
37 "-DCMAKE_CTEST_ARGUMENTS=--exclude-regex;test_x86"
38 ];
39
40 doCheck = true;
41
42 meta = with lib; {
43 description = "Lightweight multi-platform CPU emulator library";
44 homepage = "https://www.unicorn-engine.org";
45 license = licenses.gpl2Only;
46 platforms = platforms.unix;
47 maintainers = with maintainers; [ thoughtpolice luc65r ];
48 };
49}