From 5ce55991d5b1d4cf7a90d11131a8b431d7267520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20H=C3=B6ner?= Date: Sun, 20 Nov 2022 21:27:58 +0100 Subject: [PATCH 1/2] zydis: split `zycore` into separate derivation This commit splits the Zycore dependency that was previously pulled in via `fetchSubmodules` into a separate derivation. The package previously didn't install the Zycore headers and CMake configs, making it impossible to actually compile any code that uses Zydis because Zydis includes Zycore headers. --- pkgs/development/libraries/zydis/default.nix | 30 +++++++++++++++++--- pkgs/development/libraries/zydis/zycore.nix | 25 ++++++++++++++++ 2 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 pkgs/development/libraries/zydis/zycore.nix diff --git a/pkgs/development/libraries/zydis/default.nix b/pkgs/development/libraries/zydis/default.nix index 901d32b39595..c1b2c760dd2d 100644 --- a/pkgs/development/libraries/zydis/default.nix +++ b/pkgs/development/libraries/zydis/default.nix @@ -1,9 +1,16 @@ { lib , stdenv , fetchFromGitHub +, callPackage , cmake +, python3 }: +let + zycore = callPackage ./zycore.nix { + inherit stdenv fetchFromGitHub cmake; + }; +in stdenv.mkDerivation rec { pname = "zydis"; version = "4.0.0"; @@ -12,14 +19,29 @@ stdenv.mkDerivation rec { owner = "zyantific"; repo = "zydis"; rev = "v${version}"; - fetchSubmodules = true; - sha256 = "sha256-WSBi8HUVj/JR0/0pBoEaUKD0kOk41gSW5ZW74fn8b4k="; + hash = "sha256-/no/8FNa5LlwhZMSMao4/cwZk6GlamLjqr+isbh6tEI="; }; - nativeBuildInputs = [ - cmake + nativeBuildInputs = [ cmake ]; + buildInputs = [ zycore ]; + cmakeFlags = [ + "-DZYAN_SYSTEM_ZYCORE=ON" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" ]; + doCheck = true; + checkInputs = [ python3 ]; + checkPhase = '' + pushd ../tests + python3 ./regression.py test ../build/ZydisInfo + python3 ./regression_encoder.py \ + ../build/Zydis{Fuzz{ReEncoding,Encoder},TestEncoderAbsolute} + popd + ''; + + passthru = { inherit zycore; }; + meta = with lib; { homepage = "https://zydis.re/"; description = "Fast and lightweight x86/x86-64 disassembler library"; diff --git a/pkgs/development/libraries/zydis/zycore.nix b/pkgs/development/libraries/zydis/zycore.nix new file mode 100644 index 000000000000..c0ad668d1227 --- /dev/null +++ b/pkgs/development/libraries/zydis/zycore.nix @@ -0,0 +1,25 @@ +{ stdenv +, fetchFromGitHub +, cmake +}: + +stdenv.mkDerivation rec { + pname = "zycore"; + version = "1.4.1"; + + src = fetchFromGitHub { + owner = "zyantific"; + repo = "zycore-c"; + rev = "v${version}"; + hash = "sha256-kplUgrYecymGxz92tEU6H+NNtcN/Ao/tmmqdVo2c7HA="; + }; + + nativeBuildInputs = [ cmake ]; + + # The absolute paths set by the Nix CMake build manager confuse + # Zycore's config generation (which appends them to the package path). + cmakeFlags = [ + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DCMAKE_INSTALL_INCLUDEDIR=include" + ]; +} From 08fc58fc600807d1dbb6519263504f7fc41d8461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20H=C3=B6ner?= Date: Sun, 20 Nov 2022 21:28:18 +0100 Subject: [PATCH 2/2] zydis: add athre0z as a maintainer --- maintainers/maintainer-list.nix | 6 ++++++ pkgs/development/libraries/zydis/default.nix | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 3f534813908c..030de4b76eee 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -1330,6 +1330,12 @@ githubId = 55833; name = "Troels Henriksen"; }; + athre0z = { + email = "joel@zyantific.com"; + github = "athre0z"; + githubId = 6553158; + name = "Joel Höner"; + }; atila = { name = "Átila Saraiva"; email = "atilasaraiva@gmail.com"; diff --git a/pkgs/development/libraries/zydis/default.nix b/pkgs/development/libraries/zydis/default.nix index c1b2c760dd2d..38e94e741737 100644 --- a/pkgs/development/libraries/zydis/default.nix +++ b/pkgs/development/libraries/zydis/default.nix @@ -46,7 +46,7 @@ stdenv.mkDerivation rec { homepage = "https://zydis.re/"; description = "Fast and lightweight x86/x86-64 disassembler library"; license = licenses.mit; - maintainers = with maintainers; [ jbcrail AndersonTorres ]; + maintainers = with maintainers; [ jbcrail AndersonTorres athre0z ]; platforms = platforms.all; }; }