1{ lib, stdenv
2, fetchurl
3, pkg-config
4, wafHook
5, buildPackages
6, python3
7, readline
8, libxslt
9, libxcrypt
10, docbook-xsl-nons
11, docbook_xml_dtd_45
12}:
13
14stdenv.mkDerivation rec {
15 pname = "tdb";
16 version = "1.4.10";
17
18 src = fetchurl {
19 url = "mirror://samba/tdb/${pname}-${version}.tar.gz";
20 hash = "sha256-AjOOM8FsIcnilXHO9SPnaytwhjYlT28wxs8ZXUjGLa8=";
21 };
22
23 nativeBuildInputs = [
24 python3
25 pkg-config
26 wafHook
27 libxslt
28 docbook-xsl-nons
29 docbook_xml_dtd_45
30 ];
31
32 buildInputs = [
33 python3
34 readline # required to build python
35 libxcrypt
36 ];
37
38 # otherwise the configure script fails with
39 # PYTHONHASHSEED=1 missing! Don't use waf directly, use ./configure and make!
40 preConfigure = ''
41 export PKGCONFIG="$PKG_CONFIG"
42 export PYTHONHASHSEED=1
43 '';
44
45 wafPath = "buildtools/bin/waf";
46
47 wafConfigureFlags = [
48 "--bundled-libraries=NONE"
49 "--builtin-libraries=replace"
50 ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
51 "--cross-compile"
52 "--cross-execute=${stdenv.hostPlatform.emulator buildPackages}"
53 ];
54
55 postFixup = if stdenv.isDarwin
56 then ''install_name_tool -id $out/lib/libtdb.dylib $out/lib/libtdb.dylib''
57 else null;
58
59 # python-config from build Python gives incorrect values when cross-compiling.
60 # If python-config is not found, the build falls back to using the sysconfig
61 # module, which works correctly in all cases.
62 PYTHON_CONFIG = "/invalid";
63
64 meta = with lib; {
65 description = "Trivial database";
66 longDescription = ''
67 TDB is a Trivial Database. In concept, it is very much like GDBM,
68 and BSD's DB except that it allows multiple simultaneous writers
69 and uses locking internally to keep writers from trampling on each
70 other. TDB is also extremely small.
71 '';
72 homepage = "https://tdb.samba.org/";
73 license = licenses.lgpl3Plus;
74 platforms = platforms.all;
75 };
76}