about summary refs log tree commit diff
path: root/pkgs/applications/misc/webthree-umbrella/default.nix
blob: 2354c1377f9638b6d986c28b09aea4f0a13c4562 (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
118
119
120
121
122
123
124
125
126
127
{ stdenv
, fetchgit
, cmake
, boost
, gmp
, jsoncpp
, leveldb
, cryptopp
, libcpuid
, miniupnpc
, libjson_rpc_cpp
, curl
, libmicrohttpd
, mesa

, withOpenCL ? false
, opencl-headers ? null
, ocl-icd ? null

, withGUI ? false
, qtwebengine ? null
, qtbase ? null
, qtdeclarative ? null

, withProfiling ? false
, gperftools ? null

, withEVMJIT ? false
, llvm ? null
, zlib ? null
, ncurses ? null

, extraCmakeFlags ? []
}:

assert withOpenCL -> (opencl-headers != null) && (ocl-icd != null);
assert withGUI -> (qtwebengine != null) && (qtbase != null) && (qtdeclarative != null);
assert withProfiling -> (gperftools != null);
assert withEVMJIT -> (llvm != null) && (zlib != null) && (ncurses != null);

stdenv.mkDerivation rec {
  name = "cpp-ethereum-${version}";
  version = "1.2.9";

  src = fetchgit {
    url = https://github.com/ethereum/webthree-umbrella.git;
    rev = "850479b159a0bfa316fd261ab96b0a043acd766c";
    sha256 = "0k8w8gqzy71x77p0p85r38gfdnzrlzk2yvb3ablml9ppg4qb4ch5";
  };

  cmakeFlags = with stdenv.lib; concatStringsSep " " (flatten [
    "-DGUI=${toString withGUI}"
    "-DETHASHCL=${toString withOpenCL}"
    "-DPROFILING=${toString withProfiling}"
    "-DEVMJIT=${toString withEVMJIT}"
    (optional withOpenCL [
      "-DCMAKE_INCLUDE_PATH=${opencl-headers}/include"
      "-DCMAKE_LIBRARY_PATH=${ocl-icd}/lib"
    ])
    (optional withEVMJIT "-DCMAKE_PREFIX_PATH=${llvm}")
    extraCmakeFlags
  ]);

  configurePhase = ''
    export BOOST_INCLUDEDIR=${boost.dev}/include
    export BOOST_LIBRARYDIR=${boost.out}/lib

    mkdir -p Build/Install
    pushd Build

    cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd)/Install $cmakeFlags
  '';

  buildInputs = with stdenv.lib; [
    cmake
    boost
    gmp
    jsoncpp
    leveldb
    cryptopp
    libcpuid
    miniupnpc
    libjson_rpc_cpp
    curl
    libmicrohttpd
    mesa
    (optional withOpenCL [
      opencl-headers
      ocl-icd
    ])
    (optional withGUI [
      qtwebengine
      qtbase
      qtdeclarative
    ])
    (optional withProfiling gperftools)
    (optional withEVMJIT [
      llvm
      zlib
      ncurses
    ])
  ];

  runPath = with stdenv.lib; (makeLibraryPath (flatten [ stdenv.cc.cc buildInputs ]));

  installPhase = ''
    make install

    mkdir -p $out

    for f in Install/lib/*.so* $(find Install/bin -executable -type f); do
      patchelf --set-rpath $runPath:$out/lib $f
    done

    cp -r Install/* $out
  '';

  dontStrip = true;

  meta = with stdenv.lib; {
    decription = "Umbrella project for the Ethereum C++ implementation";
    homepage = https://github.com/ethereum/webthree-umbrella.git;
    license = licenses.gpl3;
    maintainers = with maintainers; [ artuuge ];
    platforms = platforms.linux;
  };
}