summary refs log tree commit diff
path: root/pkgs/applications/science/logic/z3/default.nix
blob: a213f6da37ed0103a9838201e9202c6036ad8065 (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
{ stdenv, fetchurl, python, unzip }:

stdenv.mkDerivation rec {
  name = "z3-${version}";
  version = "4.3.2";
  src = fetchurl {
    url    = "http://download-codeplex.sec.s-msft.com/Download/SourceControlFileDownload.ashx\?ProjectName\=z3\&changeSetId\=cee7dd39444c9060186df79c2a2c7f8845de415b";
    name   = "${name}.zip";
    sha256 = "0hagy7xm0m52jd6vlrbizkj24mn6c49hkb3r5p66wilvp15ivpbn";
  };

  buildInputs = [ python unzip ];
  enableParallelBuilding = true;

  # The zip file doesn't unpack a directory, just the code itself.
  unpackPhase = "mkdir ${name} && cd ${name} && unzip $src";

  configurePhase = ''
    python scripts/mk_make.py --prefix=$out
    cd build
  '';

  # z3's install phase is stupid because it tries to calculate the
  # python package store location itself, meaning it'll attempt to
  # write files into the nix store, and fail.
  soext = if stdenv.system == "x86_64-darwin" then ".dylib" else ".so";
  installPhase = ''
    mkdir -p $out/bin $out/lib/${python.libPrefix}/site-packages $out/include
    cp ../src/api/z3.h        $out/include
    cp ../src/api/z3_api.h    $out/include
    cp ../src/api/z3_v1.h     $out/include
    cp ../src/api/z3_macros.h $out/include
    cp ../src/api/c++/z3++.h  $out/include
    cp z3                     $out/bin
    cp libz3${soext}          $out/lib
    cp libz3${soext}          $out/lib/${python.libPrefix}/site-packages
    cp z3*.pyc                $out/lib/${python.libPrefix}/site-packages
  '';

  meta = {
    description = "A high-performance theorem prover and SMT solver";
    homepage    = "http://z3.codeplex.com";
    license     = stdenv.lib.licenses.msrla;
    platforms   = stdenv.lib.platforms.unix;
    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
  };
}