lol
1{ stdenv, fetchFromGitHub, automake, autoconf, libtool
2
3# Optional Dependencies
4, lz4 ? null, snappy ? null, zlib ? null, bzip2 ? null, db ? null
5, gperftools ? null, leveldb ? null
6}:
7
8with stdenv.lib;
9let
10 mkFlag = trueStr: falseStr: cond: name: val: "--"
11 + (if cond then trueStr else falseStr)
12 + name
13 + optionalString (val != null && cond != false) "=${val}";
14 mkEnable = mkFlag "enable-" "disable-";
15 mkWith = mkFlag "with-" "without-";
16 mkOther = mkFlag "" "" true;
17
18 shouldUsePkg = pkg: if pkg != null && any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
19
20 optLz4 = shouldUsePkg lz4;
21 optSnappy = shouldUsePkg snappy;
22 optZlib = shouldUsePkg zlib;
23 optBzip2 = shouldUsePkg bzip2;
24 optDb = shouldUsePkg db;
25 optGperftools = shouldUsePkg gperftools;
26 optLeveldb = shouldUsePkg leveldb;
27in
28stdenv.mkDerivation rec {
29 name = "wiredtiger-${version}";
30 version = "2.6.1";
31
32 src = fetchFromGitHub {
33 repo = "wiredtiger";
34 owner = "wiredtiger";
35 rev = version;
36 sha256 = "1nj319w3hvkq3za2dz9m0p1w683gycdb392v1jb910bhzpsq30pd";
37 };
38
39 nativeBuildInputs = [ automake autoconf libtool ];
40 buildInputs = [ optLz4 optSnappy optZlib optBzip2 optDb optGperftools optLeveldb ];
41
42 configureFlags = [
43 (mkWith false "attach" null)
44 (mkWith true "builtins" "")
45 (mkEnable (optBzip2 != null) "bzip2" null)
46 (mkEnable false "diagnostic" null)
47 (mkEnable false "java" null)
48 (mkEnable (optLeveldb != null) "leveldb" null)
49 (mkEnable false "python" null)
50 (mkEnable (optSnappy != null) "snappy" null)
51 (mkEnable (optLz4 != null) "lz4" null)
52 (mkEnable (optGperftools != null) "tcmalloc" null)
53 (mkEnable (optZlib != null) "zlib" null)
54 (mkWith (optDb != null) "berkeleydb" optDb)
55 (mkWith false "helium" null)
56 ];
57
58 preConfigure = ''
59 ./autogen.sh
60 '';
61
62 prePatch = stdenv.lib.optionalString stdenv.isDarwin ''
63 substituteInPlace api/leveldb/leveldb_wt.h --replace \
64 '#include "wiredtiger.h"' \
65 ''$'#include "wiredtiger.h"\n#include "pthread.h"'
66 '';
67
68 meta = {
69 homepage = http://wiredtiger.com/;
70 description = "";
71 license = licenses.gpl2;
72 platforms = intersectLists platforms.unix platforms.x86_64;
73 maintainers = with maintainers; [ wkennington ];
74 };
75}