summary refs log tree commit diff
path: root/pkgs/development/compilers/cryptol/1.8.x.nix
blob: 4cf00ad3806d28350ac8da9f0b81c587c0f28c90 (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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
{ stdenv, requireFile, gmp4, ncurses, zlib, clang_33, makeWrapper }:

let
  name    = "cryptol-${version}-${rev}";
  version = "1.8.27";
  rev     = "1";
  lss-ver = "lss-0.2d";
  jss-ver = "jss-0.4";

  libPath = stdenv.lib.makeLibraryPath
    [ stdenv.gcc.libc
      stdenv.gcc.gcc
      gmp4
      ncurses
      zlib
    ] + ":${stdenv.gcc.gcc}/lib64";

  cryptol-bin =
    if stdenv.system == "i686-linux"
    then requireFile {
      url    = "http://cryptol.net";
      name   = "${name}-i386-centos6-linux.tar.gz";
      sha256 = "131jkj3nh29rwwq5w5sfdf5jrb3c7ayjp4709v1zh84q4d6b35nf";
    }
    else requireFile {
      url    = "http://cryptol.net";
      name   = "${name}-x86_64-centos6-linux.tar.gz";
      sha256 = "1dmkns8s6r2d6pvh176w8k3891frik6hmcr2ibghk4l6qr6gwarx";
    };

  lss-bin =
    if stdenv.system == "i686-linux"
    then requireFile {
      url    = "http://cryptol.net";
      name   = "${lss-ver}-centos6-32.tar.gz";
      sha256 = "015ssw3v523wwzkma0qbpj3jnyzckab5q00ypdz0gr3kjcxn5rxg";
    }
    else requireFile {
      url    = "http://cryptol.net";
      name   = "${lss-ver}-centos6-64.tar.gz";
      sha256 = "1zjy4xi8v3m6g8ydm9q6dgzg5xn0xc3a4zsll5plbhngprgwxcxm";
    };

  jss-bin =
    if stdenv.system == "i686-linux"
    then requireFile {
      url    = "http://cryptol.net";
      name   = "${jss-ver}-centos5-32.tar.gz";
      sha256 = "1rlj14fbh9k3yvals8jsarczwl51fh6zjaic0pnhpc9s4p0pnjbr";
    }
    else requireFile {
      url    = "http://cryptol.net";
      name   = "${jss-ver}-centos5-64.tar.gz";
      sha256 = "0smarm2pi3jz4c8jas9gwcbghc6vc375vrwxbdj1mqx4awlhnz1n";
    };

in
stdenv.mkDerivation rec {
  inherit name version cryptol-bin jss-bin lss-bin;

  src = [ cryptol-bin lss-bin jss-bin ];
  buildInputs = [ makeWrapper ];

  unpackPhase = ''
    tar xf ${cryptol-bin}
    tar xf ${lss-bin}
    tar xf ${jss-bin}
  '';

  installPhase = ''
    mkdir -p $out/share $out/libexec

    # Move Cryptol
    mv cryptol-${version}/bin $out
    mv cryptol-${version}/lib $out
    mv cryptol-${version}/man $out/share
    rm -f $out/bin/cryptol-2

    # Move JSS
    # Create a wrapper for jss to keep the .jar out of the way
    mv ${jss-ver}/bin/jss $out/libexec
    mv ${jss-ver}/bin/galois.jar $out/libexec
    makeWrapper $out/libexec/jss $out/bin/jss --run "cd $out/libexec"
    mv ${jss-ver}/doc/jss.1 $out/share/man/man1

    # Move LSS
    mv ${lss-ver}/bin/lss $out/bin
    mv ${lss-ver}/sym-api $out/include

    # Create a convenient 'lss-clang' wrapper pointing to a valid Clang verison
    ln -s ${clang_33}/bin/clang $out/bin/lss-clang

    # Hack around lack of libtinfo in NixOS
    ln -s ${ncurses}/lib/libncursesw.so.5.9 $out/lib/libtinfo.so.5
    ln -s ${stdenv.gcc.libc}/lib/libpthread-2.19.so $out/lib/libpthread.so.0
  '';

  fixupPhase = ''
    for x in bin/cryptol bin/edif2verilog bin/copy-iverilog bin/symbolic_netlist bin/jaig bin/vvp-galois bin/lss libexec/jss; do
      patchelf --interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" \
        --set-rpath "$out/lib:${libPath}" $out/$x
      patchelf --shrink-rpath $out/$x
    done
  '';

  phases = "unpackPhase installPhase fixupPhase";

  meta = {
    description = "Cryptol: The Language of Cryptography";
    homepage    = "https://cryptol.net";
    license     = stdenv.lib.licenses.unfree;
    platforms   = stdenv.lib.platforms.linux;
    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
    hydraPlatforms = stdenv.lib.platforms.none;
    broken = true;
  };
}