summary refs log tree commit diff
path: root/pkgs/servers/samba/default.nix
blob: 699f2c96ec0bc2005b2a6ffee5586fc372a89ffc (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
{ stdenv, fetchurl, readline, pam, openldap, popt, iniparser, libunwind, fam
, acl, cups
, useKerberos ? false, kerberos ? null, winbind ? true

# Eg. smbclient and smbspool require a smb.conf file.
# If you set configDir to "" an empty configuration file
# $out/lib/smb.conf is is created for you.
#
# configDir defaults to "/etc/samba" so that smbpassword picks up
# the location of its passwd db files from the system configuration file
# /etc/samba/smb.conf. That's why nixos touches /etc/samba/smb.conf even if you
# don't enable the samba upstart service.
, configDir ? "/etc/samba"

}:

let

 useWith = flag: option: if flag then "--with-"+option else "";
 
in

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

  src = fetchurl {
    url = "http://us3.samba.org/samba/ftp/stable/${name}.tar.gz";
    sha256 = "15i7i0agcsrsq23d8pmbw5n9mbb76djiwjwgni9xijpd0ql3y7ik";
  };

  buildInputs = [ readline pam openldap popt iniparser libunwind fam acl cups ]
    ++ stdenv.lib.optional useKerberos kerberos;

  enableParallelBuilding = true;

  preConfigure = "cd source3";

  configureFlags = ''
    --with-pam
    --with-cifsmount
    --with-aio-support
    --with-pam_smbpass
    --disable-swat
    --with-configdir=${configDir}
    --with-fhs
    --localstatedir=/var
    ${useWith winbind "winbind"}
    ${if stdenv.gcc.libc != null then "--with-libiconv=${stdenv.gcc.libc}" else ""}
  '';

  # Need to use a DESTDIR because `make install' tries to write in /var and /etc.
  installFlags = "DESTDIR=$(TMPDIR)/inst";

  postInstall =
    ''
      mkdir -p $out
      mv $TMPDIR/inst/$out/* $out/
  
      mkdir -pv $out/lib/cups/backend
      ln -sv ../../../bin/smbspool $out/lib/cups/backend/smb
      mkdir -pv $out/etc/openldap/schema
      cp ../examples/LDAP/samba.schema $out/etc/openldap/schema
    '' # */
    + stdenv.lib.optionalString (configDir == "") "touch $out/lib/smb.conf";
}