diff --git a/pkgs/servers/samba/default.nix b/pkgs/servers/samba/default.nix index 0464943f8369..64b7c5fc7de4 100644 --- a/pkgs/servers/samba/default.nix +++ b/pkgs/servers/samba/default.nix @@ -1,5 +1,15 @@ { stdenv, fetchurl, readline, pam, openldap, kerberos, popt , iniparser, libunwind, fam, acl + +# 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" }: stdenv.mkDerivation rec { @@ -14,11 +24,14 @@ stdenv.mkDerivation rec { preConfigure = "cd source"; - # Provide a dummy smb.conf to shut up programs like smbclient and smbspool. - postInstall = '' - touch $out/lib/smb.conf - ''; - + postInstall = if configDir == "" + then "touch $out/lib/smb.conf" + else ""; + + + # Don't pass --with-private-dir=/var/samba/private + # --with-lockdir=/var/samba/lock + # the build system will try to create it. configureFlags = '' --with-pam --with-cifsmount @@ -26,6 +39,7 @@ stdenv.mkDerivation rec { --with-pam_smbpass --disable-swat --enable-shared-libs + --with-configdir=${configDir} ${if stdenv.gcc.libc != null then "--with-libiconv=${stdenv.gcc.libc}" else ""} ''; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8fc08770b091..9e1104a90c61 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4482,7 +4482,7 @@ let inherit xmpppy python makeWrapper fetchcvs; }; - samba = import ../servers/samba { + samba = makeOverridable (import ../servers/samba) { inherit stdenv fetchurl readline openldap pam kerberos popt iniparser libunwind acl fam; };