aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/development/compilers/bluespec/default.nix
blob: 09e76d63235c9dbcf9c66c5961a89a2814e926b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{ stdenv
, fetchFromGitHub
, fetchpatch
, autoconf
, automake
, fontconfig
, gmp
, gperf
, libX11
, libpoly
, perl
, pkgconfig
, verilog
, xorg
, zlib
, ghc
}:

let
  # yices wants a libgmp.a and fails otherwise
  gmpStatic = gmp.override { withStatic = true; };

  ghcWithPackages = ghc.withPackages (g: (with g; [old-time regex-compat syb]));
in stdenv.mkDerivation rec {
  pname = "bluespec";
  version = "unstable-2020.02.09";

  src = fetchFromGitHub {
    owner  = "B-Lang-org";
    repo   = "bsc";
    rev    = "05c8afb08078e437c635b9c708124b428ac51b3d";
    sha256 = "06yhpkz7wga1a0p9031cfjqbzw7205bj2jxgdghhfzmllaiphniy";
    fetchSubmodules = true;
  };

  enableParallelBuilding = true;

  buildInputs = [
    zlib
    gmpStatic gperf libpoly # yices
    libX11 # tcltk
    xorg.libXft
    fontconfig
  ];

  nativeBuildInputs = [
    automake autoconf
    perl
    pkgconfig
    ghcWithPackages
  ];

  checkInputs = [
    verilog
  ];

  patches = [
    # drop stp support https://github.com/B-Lang-org/bsc/pull/31
    (fetchpatch {
      url = "https://github.com/flokli/bsc/commit/0bd48ecc2561541dc1368918863c0b2f4915006f.patch";
      sha256 = "0bam9anld33zfi9d4gs502g94w49zhl5iqmbs2d1p5i19aqpy38l";
    })
  ];

  preBuild = ''
    patchShebangs \
      src/Verilog/copy_module.pl \
      src/comp/update-build-version.sh \
      src/comp/update-build-system.sh \
      src/comp/wrapper.sh

    substituteInPlace src/comp/Makefile \
      --replace 'BINDDIR' 'BINDIR' \
      --replace 'install-bsc install-bluetcl' 'install-bsc install-bluetcl $(UTILEXES) install-utils'
  '';

  makeFlags = [
    "NOGIT=1" # https://github.com/B-Lang-org/bsc/issues/12
    "LDCONFIG=ldconfig" # https://github.com/B-Lang-org/bsc/pull/43
  ];

  installPhase = "mv inst $out";

  doCheck = true;

  meta = {
    description = "Toolchain for the Bluespec Hardware Definition Language";
    homepage    = "https://github.com/B-Lang-org/bsc";
    license     = stdenv.lib.licenses.bsd3;
    platforms = [ "x86_64-linux" ];
    # darwin fails at https://github.com/B-Lang-org/bsc/pull/35#issuecomment-583731562
    # aarch64 fails, as GHC fails with "ghc: could not execute: opt"
    maintainers = with stdenv.lib.maintainers; [ flokli thoughtpolice ];
  };
}