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