about summary refs log tree commit diff
path: root/pkgs/applications/science/logic/symbiyosys/default.nix
blob: c3df8340d20c875f59d0cae3ca76e1f17e6098a9 (plain) (blame)
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
{ lib, stdenv, fetchFromGitHub
, bash, python3, yosys
, yices, boolector, z3, aiger
}:

stdenv.mkDerivation {
  pname = "symbiyosys";
  version = "2021.11.30";

  src = fetchFromGitHub {
    owner = "YosysHQ";
    repo  = "SymbiYosys";
    rev   = "b409b1179e36d2a3fff66c85b7d4e271769a2d9e";
    hash  = "sha256-S7of2upntiMkSdh4kf1RsrjriS31Eh8iEcVvG36isQg=";
  };

  buildInputs = [ ];
  patchPhase = ''
    patchShebangs .

    # Fix up Yosys imports
    substituteInPlace sbysrc/sby.py \
      --replace "##yosys-sys-path##" \
                "sys.path += [p + \"/share/yosys/python3/\" for p in [\"$out\", \"${yosys}\"]]"

    # Fix various executable references
    substituteInPlace sbysrc/sby_core.py \
      --replace '"/usr/bin/env", "bash"' '"${bash}/bin/bash"' \
      --replace ', "btormc"'             ', "${boolector}/bin/btormc"' \
      --replace ', "aigbmc"'             ', "${aiger}/bin/aigbmc"'

    substituteInPlace sbysrc/sby_core.py \
      --replace '##yosys-program-prefix##' '"${yosys}/bin/"'

    substituteInPlace sbysrc/sby.py \
      --replace '/usr/bin/env python3' '${python3}/bin/python'
  '';

  buildPhase = "true";

  installPhase = ''
    mkdir -p $out/bin $out/share/yosys/python3

    cp sbysrc/sby_*.py $out/share/yosys/python3/
    cp sbysrc/sby.py $out/bin/sby

    chmod +x $out/bin/sby
  '';

  doCheck = false; # not all provers are yet packaged...
  nativeCheckInputs = [ python3 yosys boolector yices z3 aiger ];
  checkPhase = "make test";

  meta = {
    description = "Tooling for Yosys-based verification flows";
    homepage    = "https://symbiyosys.readthedocs.io/";
    license     = lib.licenses.isc;
    maintainers = with lib.maintainers; [ thoughtpolice ];
    mainProgram = "sby";
    platforms   = lib.platforms.all;
  };
}