nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenv
3, buildPythonPackage
4, setuptools
5, unicorn-emu
6}:
7
8buildPythonPackage rec {
9 pname = "unicorn";
10 version = lib.getVersion unicorn-emu;
11 format = "setuptools";
12
13 src = unicorn-emu.src;
14
15 sourceRoot = "source/bindings/python";
16
17 prePatch = ''
18 ln -s ${unicorn-emu}/lib/libunicorn${stdenv.targetPlatform.extensions.sharedLibrary} prebuilt/
19 ln -s ${unicorn-emu}/lib/libunicorn.a prebuilt/
20 '';
21
22 # needed on non-x86 linux
23 setupPyBuildFlags = lib.optionals stdenv.isLinux [ "--plat-name" "linux" ]
24 # aarch64 only available from MacOS SDK 11 onwards, so fix the version tag.
25 # otherwise, bdist_wheel may detect "macosx_10_6_arm64" which doesn't make sense.
26 ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ "--plat-name" "macosx_11_0" ];
27
28 propagatedBuildInputs = [
29 setuptools
30 ];
31
32 checkPhase = ''
33 runHook preCheck
34
35 mv unicorn unicorn.hidden
36 patchShebangs sample_*.py shellcode.py
37 sh -e sample_all.sh
38
39 runHook postCheck
40 '';
41
42 pythonImportsCheck = [
43 "unicorn"
44 ];
45
46 meta = with lib; {
47 description = "Python bindings for Unicorn CPU emulator engine";
48 homepage = "https://www.unicorn-engine.org/";
49 license = licenses.gpl2Plus;
50 maintainers = with maintainers; [ bennofs ris ];
51 };
52}