anchor.diff:    # This may include nss_ldap, needed for samba if it has to use ldap.
     nssModulesPath = config.system.nssModules.path;
   
  -  daemonJob = appName: args:
  -    { name = "samba-${appName}";
  -      description = "Samba Service daemon ${appName}";
  -
  -      startOn = "started samba";
  -      stopOn = "stopping samba";
  +  daemonService = appName: args:
  +    { description = "Samba Service daemon ${appName}";
  +
  +      wantedBy = [ "samba.target" ];
  +      partOf = [ "samba.target" ];
   
         environment = {
           LD_LIBRARY_PATH = nssModulesPath;
  
positive.code:         LOCALE_ARCHIVE = "/run/current-system/sw/lib/locale/locale-archive";
        };
  
        daemonType = "fork";
  
        exec = "${samba}/sbin/${appName} ${args}";
      };
  
  in
  
negative.code:           };
  
  
          boot.systemd = {
            targets.samba = {
              description = "Samba server";
              requires = [ "samba-setup.service" ];
              after = [ "samba-setup.service" "network.target" ];
              wantedBy = [ "multi-user.target" ];
            };
  
            services = {
              "samba-nmbd" = daemonService "nmbd" "-F";
              "samba-smbd" = daemonService "smbd" "-F";
              "samba-winbindd" = daemonService "winbindd" "-F";
              "samba-setup" = {
                description = "Samba setup task";
                script = setupScript;
                unitConfig.RequiresMountsFor = "/home/smbd /var/samba /var/log/samba";
              };
            };
          };
  
        })
      ];
  
  