Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 perl,
6 flex,
7 bison,
8 python3,
9 autoconf,
10 which,
11 help2man,
12 makeWrapper,
13 systemc,
14 git,
15 numactl,
16 coreutils,
17 gdb,
18}:
19
20stdenv.mkDerivation rec {
21 pname = "verilator";
22 version = "5.038";
23
24 # Verilator gets the version from this environment variable
25 # if it can't do git describe while building.
26 VERILATOR_SRC_VERSION = "v${version}";
27
28 src = fetchFromGitHub {
29 owner = "verilator";
30 repo = "verilator";
31 rev = "v${version}";
32 hash = "sha256-uPGVE7y3zm+5ZydGjd1+/kIjW+a5u6d+YzjUSE4KnCY=";
33 };
34
35 enableParallelBuilding = true;
36 buildInputs = [
37 perl
38 systemc
39 (python3.withPackages (
40 pp: with pp; [
41 distro
42 ]
43 ))
44 # ccache
45 ];
46 nativeBuildInputs = [
47 makeWrapper
48 flex
49 bison
50 autoconf
51 help2man
52 git
53 ]
54 ++ lib.optionals stdenv.hostPlatform.isLinux [
55 gdb
56 ];
57
58 nativeCheckInputs = [
59 which
60 coreutils
61 # cmake
62 python3
63 ]
64 ++ lib.optionals stdenv.hostPlatform.isLinux [
65 numactl
66 ];
67
68 doCheck = true;
69 checkTarget = "test";
70
71 preConfigure = "autoconf";
72
73 postPatch = ''
74 patchShebangs bin/* src/* nodist/* docs/bin/* examples/xml_py/* \
75 test_regress/{driver.py,t/*.{pl,pf}} \
76 test_regress/t/t_a1_first_cc.py \
77 test_regress/t/t_a2_first_sc.py \
78 ci/* ci/docker/run/* ci/docker/run/hooks/* ci/docker/buildenv/build.sh
79 # verilator --gdbbt uses /bin/echo to test if gdb works.
80 substituteInPlace bin/verilator --replace-fail "/bin/echo" "${coreutils}/bin/echo"
81 '';
82 # grep '^#!/' -R . | grep -v /nix/store | less
83 # (in nix-shell after patchPhase)
84
85 # This is needed to ensure that the check phase can find the verilator_bin_dbg.
86 preCheck = ''
87 export PATH=$PWD/bin:$PATH
88 '';
89
90 env = {
91 SYSTEMC_INCLUDE = "${lib.getDev systemc}/include";
92 SYSTEMC_LIBDIR = "${lib.getLib systemc}/lib";
93 };
94
95 meta = with lib; {
96 description = "Fast and robust (System)Verilog simulator/compiler and linter";
97 homepage = "https://www.veripool.org/verilator";
98 license = with licenses; [
99 lgpl3Only
100 artistic2
101 ];
102 platforms = platforms.unix;
103 maintainers = with maintainers; [
104 thoughtpolice
105 amiloradovsky
106 ];
107 };
108}