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.3.3";
17
18 src = fetchurl {
19 url = "mirror://samba/talloc/${pname}-${version}.tar.gz";
20 sha256 = "sha256-a+lbI2i9CvHEzXqIFG62zuoY5Gw//JMwv2JitA0diqo=";
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 wafPath = "buildtools/bin/waf";
41
42 wafConfigureFlags = [
43 "--enable-talloc-compat1"
44 "--bundled-libraries=NONE"
45 "--builtin-libraries=replace"
46 ];
47
48 # python-config from build Python gives incorrect values when cross-compiling.
49 # If python-config is not found, the build falls back to using the sysconfig
50 # module, which works correctly in all cases.
51 PYTHON_CONFIG = "/invalid";
52
53 # this must not be exported before the ConfigurePhase otherwise waf whines
54 preBuild = lib.optionalString stdenv.hostPlatform.isMusl ''
55 export NIX_CFLAGS_LINK="-no-pie -shared";
56 '';
57
58 postInstall = ''
59 ${stdenv.cc.targetPrefix}ar q $out/lib/libtalloc.a bin/default/talloc.c.[0-9]*.o
60 '';
61
62 meta = with lib; {
63 description = "Hierarchical pool based memory allocator with destructors";
64 homepage = "https://tdb.samba.org/";
65 license = licenses.gpl3;
66 platforms = platforms.all;
67 };
68}