about summary refs log tree commit diff
path: root/pkgs/servers/samba/4.x.nix
blob: 7ee1c78ceebb57319c075efc359ba45c03b33de7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
{ stdenv, fetchurl, python, pkgconfig, perl, libxslt, docbook_xsl
, docbook_xml_dtd_42, docbook_xml_dtd_45, readline, talloc, ntdb, tdb, tevent
, ldb, popt, iniparser, pythonPackages, libbsd, nss_wrapper, socket_wrapper
, uid_wrapper, libarchive

# source3/wscript optionals
, kerberos ? null
, openldap ? null
, cups ? null
, pam ? null
, avahi ? null
, acl ? null
, libaio ? null
, fam ? null
, ceph ? null
, glusterfs ? null

# buildtools/wafsamba/wscript optionals
, libiconv ? null
, gettext ? null

# source4/lib/tls/wscript optionals
, gnutls ? null
, libgcrypt ? null
, libgpgerror ? null

# other optionals
, zlib ? null
, ncurses ? null
, libcap ? null
, libunwind ? null
, dbus ? null
, libibverbs ? null
, librdmacm ? null
, systemd ? null
}:

stdenv.mkDerivation rec {
  name = "samba-4.2.0";

  src = fetchurl {
    url = "mirror://samba/pub/samba/stable/${name}.tar.gz";
    sha256 = "03s9pjdgq6nlv2lcnlmxlhhj8m5drgv6z4xy9zkgwwd92mw0b9k6";
  };

  patches = [
    ./4.x-no-persistent-install.patch
    ./4.x-heimdal-compat.patch
    ./4.x-fix-ctdb-deps.patch
  ];

  buildInputs = [
    python pkgconfig perl libxslt docbook_xsl docbook_xml_dtd_42
    docbook_xml_dtd_45 readline talloc ntdb tdb tevent ldb popt iniparser
    pythonPackages.subunit libbsd nss_wrapper socket_wrapper uid_wrapper
    libarchive

    kerberos openldap cups pam avahi acl libaio fam ceph glusterfs

    libiconv gettext

    gnutls libgcrypt libgpgerror

    zlib ncurses libcap libunwind dbus libibverbs librdmacm systemd
  ];

  postPatch = ''
    # Removes absolute paths in scripts
    sed -i 's,/sbin/,,g' ctdb/config/functions

    # Fix the XML Catalog Paths
    sed -i "s,\(XML_CATALOG_FILES=\"\),\1$XML_CATALOG_FILES ,g" buildtools/wafsamba/wafsamba.py
  '';

  enableParallelBuilding = true;

  configureFlags = [
    # source3/wscript options
    "--with-static-modules=NONE"
    "--with-shared-modules=ALL"
    "--with-winbind"
  ] ++ (if kerberos != null then [ "--with-ads" ] else [ "--without-ads" ])
    ++ (if openldap != null then [ "--with-ldap" ] else [ "--without-ldap" ])
    ++ (if cups != null then [ "--enable-cups" ] else [ "--disable-cups" ])
    ++ (if pam != null then [ "--with-pam" "--with-pam_smbpass" ]
        else [ "--without-pam" "--without-pam_smbpass" ]) ++ [
    "--with-quotas"
    "--with-sendfile-support"
    "--with-utmp"
    "--enable-pthreadpool"
  ] ++ (if avahi != null then [ "--enable-avahi" ] else [ "--disable-avahi" ]) ++ [
    "--with-iconv"
  ] ++ (if acl != null then [ "--with-acl-support" ] else [ "--without-acl-support" ]) ++ [
    "--with-dnsupdate"
    "--with-syslog"
    "--with-automount"
  ] ++ (if libaio != null then [ "--with-aio-support" ] else [ "--without-aio-support" ])
    ++ (if fam != null then [ "--with-fam" ] else [ "--without-fam" ]) ++ [
    "--with-cluster-support"
  ] ++ (if ceph != null then [ "--with-libcephfs=${ceph}" ] else [ ])
    ++ (if glusterfs != null then [ "--enable-glusterfs" ] else [ "--disable-glusterfs" ]) ++ [

    # dynconfig/wscript options
    "--enable-fhs"
    "--sysconfdir=/etc"
    "--localstatedir=/var"

    # buildtools/wafsamba/wscript options
    "--bundled-libraries=${if kerberos != null && kerberos.implementation == "heimdal" then "NONE" else "com_err"}"
    "--private-libraries=NONE"
    "--builtin-libraries=replace"
  ] ++ (if libiconv != null then [ "--with-libiconv=${libiconv}" ] else [ ])
    ++ (if gettext != null then [ "--with-gettext=${gettext}" ] else [ "--without-gettext" ]) ++ [

    # source4/lib/tls/wscript options
  ] ++ (if gnutls != null && libgcrypt != null && libgpgerror != null
        then [ "--enable-gnutls" ] else [ "--disable-gnutls" ]) ++ [

    # wscript options
  ] ++ stdenv.lib.optional (kerberos != null && kerberos.implementation == "krb5") "--with-system-mitkrb5"
    ++ stdenv.lib.optional (kerberos == null) "--without-ad-dc" ++ [

    # ctdb/wscript
    "--enable-infiniband"
    "--enable-pmda"
  ];

  stripAllList = [ "bin" "sbin" ];

  postInstall = ''
    # Remove unecessary components
    rm -r $out/{lib,share}/ctdb-tests
    rm $out/bin/ctdb_run{_cluster,}_tests
  '';

  postFixup = ''
    export SAMBA_LIBS="$(find $out -type f -name \*.so -exec dirname {} \; | sort | uniq)"
    read -r -d "" SCRIPT << EOF
    [ -z "\$SAMBA_LIBS" ] && exit 1;
    BIN='{}';
    OLD_LIBS="\$(patchelf --print-rpath "\$BIN" 2>/dev/null | tr ':' '\n')";
    ALL_LIBS="\$(echo -e "\$SAMBA_LIBS\n\$OLD_LIBS" | sort | uniq | tr '\n' ':')";
    patchelf --set-rpath "\$ALL_LIBS" "\$BIN" 2>/dev/null || exit $?;
    patchelf --shrink-rpath "\$BIN";
    EOF
    find $out -type f -exec $SHELL -c "$SCRIPT" \;
  '';

  meta = with stdenv.lib; {
    homepage = http://www.samba.org/;
    description = "The standard Windows interoperability suite of programs for Linux and Unix";
    license = licenses.gpl3;
    maintainers = with maintainers; [ wkennington ];
    platforms = platforms.unix;
  };
}