lol
1{ lib, stdenv, fetchFromGitHub, fixDarwinDylibNames, snappy }:
2
3stdenv.mkDerivation rec {
4 pname = "leveldb";
5 version = "1.20";
6
7 src = fetchFromGitHub {
8 owner = "google";
9 repo = "leveldb";
10 rev = "v${version}";
11 sha256 = "01kxga1hv4wp94agx5vl3ybxfw5klqrdsrb6p6ywvnjmjxm8322y";
12 };
13
14 buildInputs = [ snappy ];
15
16 nativeBuildInputs = lib.optional stdenv.isDarwin fixDarwinDylibNames;
17
18 doCheck = true;
19
20 buildFlags = [ "all" ];
21
22 postPatch = lib.optionalString stdenv.hostPlatform.isStatic ''
23 # remove shared objects from "all" target
24 sed -i '/^all:/ s/$(SHARED_LIBS) $(SHARED_PROGRAMS)//' Makefile
25 '';
26
27 installPhase = ''
28 runHook preInstall
29
30 install -D -t $out/include/leveldb include/leveldb/*
31 install -D helpers/memenv/memenv.h $out/include/leveldb/helpers
32
33 install -D -t $out/lib out-{static,shared}/lib*
34 install -D -t $out/bin out-static/{leveldbutil,db_bench}
35
36 runHook postInstall
37 '';
38
39 meta = with lib; {
40 homepage = "https://github.com/google/leveldb";
41 description = "Fast and lightweight key/value database library by Google";
42 license = licenses.bsd3;
43 platforms = platforms.all;
44 };
45}