1{ stdenv, fetchFromGitHub }:
2
3stdenv.mkDerivation rec {
4 name = "lmdb-${version}";
5 version = "0.9.21";
6
7 src = fetchFromGitHub {
8 owner = "LMDB";
9 repo = "lmdb";
10 rev = "LMDB_${version}";
11 sha256 = "026a6himvg3y4ssnccdbgr3c2pq3w2d47nayn05v512875z4f2w3";
12 };
13
14 postUnpack = "sourceRoot=\${sourceRoot}/libraries/liblmdb";
15
16 outputs = [ "bin" "out" "dev" ];
17
18 makeFlags = [ "prefix=$(out)" "CC=cc" ]
19 ++ stdenv.lib.optional stdenv.isDarwin "LDFLAGS=-Wl,-install_name,$(out)/lib/liblmdb.so";
20
21 doCheck = true;
22 checkPhase = "make test";
23
24 postInstall = ''
25 moveToOutput bin "$bin"
26 moveToOutput "lib/*.a" REMOVE # until someone needs it
27 ''
28 # add lmdb.pc (dynamic only)
29 + ''
30 mkdir -p "$dev/lib/pkgconfig"
31 cat > "$dev/lib/pkgconfig/lmdb.pc" <<EOF
32 Name: lmdb
33 Description: ${meta.description}
34 Version: ${version}
35
36 Cflags: -I$dev/include
37 Libs: -L$out/lib -llmdb
38 EOF
39 '';
40
41 meta = with stdenv.lib; {
42 description = "Lightning memory-mapped database";
43 longDescription = ''
44 LMDB is an ultra-fast, ultra-compact key-value embedded data store
45 developed by Symas for the OpenLDAP Project. It uses memory-mapped files,
46 so it has the read performance of a pure in-memory database while still
47 offering the persistence of standard disk-based databases, and is only
48 limited to the size of the virtual address space.
49 '';
50 homepage = http://symas.com/mdb/;
51 maintainers = with maintainers; [ jb55 vcunat ];
52 license = licenses.openldap;
53 platforms = platforms.all;
54 };
55}