1{ lib, stdenv
2, fetchurl
3, python3
4, pkg-config
5, readline
6, libxslt
7, libxcrypt
8, docbook-xsl-nons
9, docbook_xml_dtd_42
10, fixDarwinDylibNames
11, wafHook
12}:
13
14stdenv.mkDerivation rec {
15 pname = "talloc";
16 version = "2.4.0";
17
18 src = fetchurl {
19 url = "mirror://samba/talloc/${pname}-${version}.tar.gz";
20 sha256 = "sha256-bfNoYsQkZu+I82BERROHDvRpNPkBbIQ4PMQAin0MRro=";
21 };
22
23 nativeBuildInputs = [
24 pkg-config
25 python3
26 wafHook
27 docbook-xsl-nons
28 docbook_xml_dtd_42
29 ] ++ lib.optionals stdenv.isDarwin [
30 fixDarwinDylibNames
31 ];
32
33 buildInputs = [
34 python3
35 readline
36 libxslt
37 libxcrypt
38 ];
39
40 # otherwise the configure script fails with
41 # PYTHONHASHSEED=1 missing! Don't use waf directly, use ./configure and make!
42 preConfigure = ''
43 export PKGCONFIG="$PKG_CONFIG"
44 export PYTHONHASHSEED=1
45 '';
46
47 wafPath = "buildtools/bin/waf";
48
49 wafConfigureFlags = [
50 "--enable-talloc-compat1"
51 "--bundled-libraries=NONE"
52 "--builtin-libraries=replace"
53 ];
54
55 # python-config from build Python gives incorrect values when cross-compiling.
56 # If python-config is not found, the build falls back to using the sysconfig
57 # module, which works correctly in all cases.
58 PYTHON_CONFIG = "/invalid";
59
60 # this must not be exported before the ConfigurePhase otherwise waf whines
61 preBuild = lib.optionalString stdenv.hostPlatform.isMusl ''
62 export NIX_CFLAGS_LINK="-no-pie -shared";
63 '';
64
65 postInstall = ''
66 ${stdenv.cc.targetPrefix}ar q $out/lib/libtalloc.a bin/default/talloc.c.[0-9]*.o
67 '';
68
69 meta = with lib; {
70 description = "Hierarchical pool based memory allocator with destructors";
71 homepage = "https://tdb.samba.org/";
72 license = licenses.gpl3;
73 platforms = platforms.all;
74 };
75}