@@ -0,0 +1,52 @@
1+{ stdenv, fetchFromGitHub, cmake, ninja, pkgconfig, python3Packages
2+, boost, rapidjson, qtbase, qtsvg, igraph, spdlog, wrapQtAppsHook
3+, llvmPackages ? null
4+}:
5+
6+stdenv.mkDerivation rec {
7+ version = "2.0.0";
8+ pname = "hal-hardware-analyzer";
9+
10+ src = fetchFromGitHub {
11+ owner = "emsec";
12+ repo = "hal";
13+ rev = "v${version}";
14+ sha256 = "11xmqxnryksl645wmm1d69k1b5zwvxxf0admk4iblzaa3ggf7cv1";
15+ };
16+ # make sure bundled dependencies don't get in the way - install also otherwise
17+ # copies them in full to the output, bloating the package
18+ postPatch = ''
19+ rm -rf deps/*/*
20+ substituteInPlace cmake/detect_dependencies.cmake \
21+ --replace 'spdlog 1.4.2 EXACT' 'spdlog 1.4.2 REQUIRED'
22+ '';
23+
24+ nativeBuildInputs = [ cmake ninja pkgconfig ];
25+ buildInputs = [ qtbase qtsvg boost rapidjson igraph spdlog wrapQtAppsHook ]
26+ ++ (with python3Packages; [ python pybind11 ])
27+ ++ stdenv.lib.optional stdenv.cc.isClang llvmPackages.openmp;
28+
29+ cmakeFlags = with stdenv.lib.versions; [
30+ "-DHAL_VERSION_RETURN=${version}"
31+ "-DHAL_VERSION_MAJOR=${major version}"
32+ "-DHAL_VERSION_MINOR=${minor version}"
33+ "-DHAL_VERSION_PATCH=${patch version}"
34+ "-DHAL_VERSION_TWEAK=0"
35+ "-DHAL_VERSION_ADDITIONAL_COMMITS=0"
36+ "-DHAL_VERSION_DIRTY=false"
37+ "-DHAL_VERSION_BROKEN=false"
38+ "-DENABLE_INSTALL_LDCONFIG=off"
39+ "-DBUILD_ALL_PLUGINS=on"
40+ ];
41+ # needed for macos build - this is why we use wrapQtAppsHook instead of
42+ # the qt mkDerivation - the latter forcibly overrides this.
43+ cmakeBuildType = "MinSizeRel";
44+
45+ meta = {
46+ description = "A comprehensive reverse engineering and manipulation framework for gate-level netlists";
47+ homepage = "https://github.com/emsec/hal";
48+ license = stdenv.lib.licenses.mit;
49+ platforms = with stdenv.lib.platforms; unix;
50+ maintainers = with stdenv.lib.maintainers; [ ris ];
51+ };
52+}