anvil-editor: init at 0.4
[NixPkgs.git] / pkgs / applications / science / electronics / hal-hardware-analyzer / default.nix
blobe8c15c35f2f918ab9d0784d0e91c39fb28c494d1
1 { lib
2 , stdenv
3 , boost
4 , cmake
5 , fetchFromGitHub
6 , fetchpatch
7 , graphviz
8 , igraph
9 , llvmPackages
10 , ninja
11 , nlohmann_json
12 , pkg-config
13 , python3Packages
14 , qtbase
15 , qtsvg
16 , quazip
17 , rapidjson
18 , spdlog
19 , verilator
20 , wrapQtAppsHook
21 , z3
24 stdenv.mkDerivation rec {
25   version = "4.4.1";
26   pname = "hal-hardware-analyzer";
28   src = fetchFromGitHub {
29     owner = "emsec";
30     repo = "hal";
31     rev = "v${version}";
32     sha256 = "sha256-8kmYeqsmqR7tY044rZb3KuEAVGv37IObX6k1qjXWG0A=";
33   };
35   patches = [
36     (fetchpatch {
37       name = "de-vendor-nlohmann-json.patch";
38       # https://github.com/emsec/hal/pull/596
39       url = "https://github.com/emsec/hal/commit/f8337d554d80cfa2588512696696fd4c878dd7a3.patch";
40       hash = "sha256-QjgvcduwbFccC807JFOevlTfO3KiL9T3HSqYmh3sXAQ=";
41     })
42     (fetchpatch {
43       name = "fix-vendored-igraph-regression.patch";
44       # https://github.com/emsec/hal/pull/596
45       url = "https://github.com/emsec/hal/commit/fe1fe74719ab4fef873a22e2b28cce0c57d570e0.patch";
46       hash = "sha256-bjbW4pr04pP0TCuSdzPcV8h6LbLWMvdGSf61RL9Ju6E=";
47     })
48     ./4.4.1-newer-spdlog-fmt-compat.patch
49   ];
51   # make sure bundled dependencies don't get in the way - install also otherwise
52   # copies them in full to the output, bloating the package
53   postPatch = ''
54     shopt -s extglob
55     rm -rf deps/!(abc|sanitizers-cmake|subprocess)/*
56     shopt -u extglob
57   '';
59   nativeBuildInputs = [
60     cmake
61     ninja
62     pkg-config
63     wrapQtAppsHook
64   ];
65   buildInputs = [
66     qtbase
67     qtsvg
68     boost
69     rapidjson
70     igraph
71     nlohmann_json
72     spdlog
73     graphviz
74     verilator
75     z3
76     quazip
77   ]
78   ++ (with python3Packages; [ python pybind11 ])
79   ++ lib.optional stdenv.cc.isClang llvmPackages.openmp
80   ;
82   cmakeFlags = with lib.versions; [
83     "-DHAL_VERSION_RETURN=${version}"
84     "-DHAL_VERSION_MAJOR=${major version}"
85     "-DHAL_VERSION_MINOR=${minor version}"
86     "-DHAL_VERSION_PATCH=${patch version}"
87     "-DHAL_VERSION_TWEAK=0"
88     "-DHAL_VERSION_ADDITIONAL_COMMITS=0"
89     "-DHAL_VERSION_DIRTY=false"
90     "-DHAL_VERSION_BROKEN=false"
91     "-DENABLE_INSTALL_LDCONFIG=off"
92     "-DUSE_VENDORED_PYBIND11=off"
93     "-DUSE_VENDORED_SPDLOG=off"
94     "-DUSE_VENDORED_QUAZIP=off"
95     "-DUSE_VENDORED_IGRAPH=off"
96     "-DUSE_VENDORED_NLOHMANN_JSON=off"
97     "-DBUILD_ALL_PLUGINS=on"
98   ];
99   # needed for macos build - this is why we use wrapQtAppsHook instead of
100   # the qt mkDerivation - the latter forcibly overrides this.
101   cmakeBuildType = "MinSizeRel";
103   # https://github.com/emsec/hal/issues/598
104   NIX_CFLAGS_COMPILE = lib.optional stdenv.hostPlatform.isAarch64 "-flax-vector-conversions";
106   # some plugins depend on other plugins and need to be able to load them
107   postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
108     find $out/lib/hal_plugins -name '*.so*' | while read -r f ; do
109       patchelf --set-rpath "$(patchelf --print-rpath "$f"):$out/lib/hal_plugins" "$f"
110     done
111   '';
113   meta = with lib; {
114     description = "Comprehensive reverse engineering and manipulation framework for gate-level netlists";
115     mainProgram = "hal";
116     homepage = "https://github.com/emsec/hal";
117     license = licenses.mit;
118     platforms = platforms.unix;
119     maintainers = with maintainers; [ ris shamilton ];
120   };