@@ -91,6 +91,26 @@ in
9191 '';
9292 };
9393
94+ enableNmbd = mkOption {
95+ type = types.bool;
96+ default = true;
97+ description = ''
98+ Whether to enable Samba's nmbd, which replies to NetBIOS over IP name
99+ service requests. It also participates in the browsing protocols
100+ which make up the Windows "Network Neighborhood" view.
101+ '';
102+ };
103+
104+ enableWinbindd = mkOption {
105+ type = types.bool;
106+ default = true;
107+ description = ''
108+ Whether to enable Samba's winbindd, which provides a number of services
109+ to the Name Service Switch capability found in most modern C libraries,
110+ to arbitrary applications via PAM and ntlm_auth and to Samba itself.
111+ '';
112+ };
113+
94114 package = mkOption {
95115 type = types.package;
96116 default = pkgs.samba;
@@ -185,7 +205,12 @@ in
185205 ###### implementation
186206
187207 config = mkMerge
188− [ { # Always provide a smb.conf to shut up programs like smbclient and smbspool.
208+ [ { assertions =
209+ [ { assertion = cfg.nsswins -> cfg.enableWinbindd;
210+ message = "If samba.nsswins is enabled, then samba.enableWinbindd must also be enabled";
211+ }
212+ ];
213+ # Always provide a smb.conf to shut up programs like smbclient and smbspool.
189214 environment.etc = singleton
190215 { source =
191216 if cfg.enable then configFile
@@ -194,7 +219,7 @@ in
194219 };
195220 }
196221
197− (mkIf config.services.samba.enable {
222+ (mkIf cfg.enable {
198223
199224 system.nssModules = optional cfg.nsswins samba;
200225
@@ -207,9 +232,9 @@ in
207232 };
208233
209234 services = {
210− "samba-nmbd" = daemonService "nmbd" "-F";
211235 "samba-smbd" = daemonService "smbd" "-F";
212− "samba-winbindd" = daemonService "winbindd" "-F";
236+ "samba-nmbd" = mkIf cfg.enableNmbd (daemonService "nmbd" "-F");
237+ "samba-winbindd" = mkIf cfg.enableWinbindd (daemonService "winbindd" "-F");
213238 "samba-setup" = {
214239 description = "Samba Setup Task";
215240 script = setupScript;