python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / development / compilers / bluespec / default.nix
blobd6accbdbf1fc35f8bebc4bf16511094eea7b539b
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , fetchurl
5 , autoconf
6 , automake
7 , fontconfig
8 , libX11
9 , perl
10 , flex
11 , bison
12 , pkg-config
13 , tcl
14 , tk
15 , xorg
16 , yices
17 , zlib
18 , ghc
19 , gmp-static
20 , verilog
21 , asciidoctor
22 , tex
23 , which
26 let
27   ghcWithPackages = ghc.withPackages (g: (with g; [ old-time regex-compat syb split ]));
29 in stdenv.mkDerivation rec {
30   pname = "bluespec";
31   version = "2022.01";
33   src = fetchFromGitHub {
34     owner = "B-Lang-org";
35     repo = "bsc";
36     rev = version;
37     sha256 = "sha256-ivTua3MLa8akma3MGkhsqwSdwswYX916kywKdlj7TqY=";
38   };
40   yices-src = fetchurl {
41     url = "https://github.com/B-Lang-org/bsc/releases/download/${version}/yices-src-for-bsc-${version}.tar.gz";
42     sha256 = "sha256-ey5yIIVFZyG4EnYGqbIJqmxK1rZ70FWM0Jz+2hIoGXE=";
43   };
45   enableParallelBuilding = true;
47   outputs = [ "out" "doc" ];
49   # https://github.com/B-Lang-org/bsc/pull/278
50   patches = [ ./libstp_stub_makefile.patch ];
52   postUnpack = ''
53     mkdir -p $sourceRoot/src/vendor/yices/v2.6/yices2
54     tar -C $sourceRoot/src/vendor/yices/v2.6/yices2 -xf ${yices-src}
55     chmod -R +rwX $sourceRoot/src/vendor/yices/v2.6/yices2
56   '';
58   preBuild = ''
59     patchShebangs \
60       src/Verilog/copy_module.pl \
61       src/comp/update-build-version.sh \
62       src/comp/update-build-system.sh \
63       src/comp/wrapper.sh
65     substituteInPlace src/comp/Makefile \
66       --replace 'BINDDIR' 'BINDIR' \
67       --replace 'install-bsc install-bluetcl' 'install-bsc install-bluetcl $(UTILEXES) install-utils'
69     # allow running bsc to bootstrap
70     export LD_LIBRARY_PATH=$PWD/inst/lib/SAT
71   '';
73   buildInputs = yices.buildInputs ++ [
74     fontconfig
75     libX11 # tcltk
76     tcl
77     tk
78     which
79     xorg.libXft
80     zlib
81   ];
83   nativeBuildInputs = [
84     automake
85     autoconf
86     asciidoctor
87     bison
88     flex
89     ghcWithPackages
90     perl
91     pkg-config
92     tex
93   ];
95   makeFlags = [
96     "release"
97     "NO_DEPS_CHECKS=1" # skip the subrepo check (this deriviation uses yices.src instead of the subrepo)
98     "NOGIT=1" # https://github.com/B-Lang-org/bsc/issues/12
99     "LDCONFIG=ldconfig" # https://github.com/B-Lang-org/bsc/pull/43
100     "STP_STUB=1"
101   ];
103   doCheck = true;
105   checkInputs = [
106     gmp-static
107     verilog
108   ];
110   checkTarget = "check-smoke";
112   installPhase = ''
113     mkdir -p $out
114     mv inst/bin $out
115     mv inst/lib $out
117     # fragile, I know..
118     mkdir -p $doc/share/doc/bsc
119     mv inst/README $doc/share/doc/bsc
120     mv inst/ReleaseNotes.* $doc/share/doc/bsc
121     mv inst/doc/*.pdf $doc/share/doc/bsc
122   '';
124   meta = {
125     description = "Toolchain for the Bluespec Hardware Definition Language";
126     homepage = "https://github.com/B-Lang-org/bsc";
127     license = lib.licenses.bsd3;
128     platforms = [ "x86_64-linux" ];
129     mainProgram = "bsc";
130     # darwin fails at https://github.com/B-Lang-org/bsc/pull/35#issuecomment-583731562
131     # aarch64 fails, as GHC fails with "ghc: could not execute: opt"
132     maintainers = with lib.maintainers; [ jcumming thoughtpolice ];
133   };