anchor.diff:          config.ids.gids.syncthing;
       };
   
  -    environment.systemPackages = [ cfg.package ];
  +    systemd.services = {
  +      syncthing = mkIf cfg.systemService (header // {
  +          wants = mkIf cfg.useInotify [ "syncthing-inotify.service" ];
  +          wantedBy = [ "multi-user.target" ];
  +          serviceConfig = service // {
  +            User = cfg.user;
  +            Group = cfg.group;
  +            PermissionsStartOnly = true;
  +            ExecStart = "${cfg.package}/bin/syncthing -no-browser -home=${cfg.dataDir}";
  +          };
  +      });
   
  -    systemd.services = mkIf cfg.systemService {
  -      syncthing = header // {
  +      syncthing-inotify = mkIf (cfg.systemService && cfg.useInotify) (iNotifyHeader // {
           wantedBy = [ "multi-user.target" ];
  -        serviceConfig = service // {
  +        serviceConfig = iNotifyService // {
             User = cfg.user;
  -          Group = cfg.group;
  -          PermissionsStartOnly = true;
  -          ExecStart = "${cfg.package}/bin/syncthing -no-browser -home=${cfg.dataDir}";
  +          ExecStart = "${pkgs.syncthing-inotify.bin}/bin/syncthing-inotify -home=${cfg.dataDir} -logflags=0";
           };
  -      };
  +      });
       };
   
  -    systemd.user.services.syncthing =
  -      header // {
  -        wantedBy = [ "default.target" ];
  +    systemd.user.services = {
  +      syncthing = header // {
           serviceConfig = service // {
             ExecStart = "${cfg.package}/bin/syncthing -no-browser";
           };
         };
   
  +      syncthing-inotify = mkIf cfg.useInotify (iNotifyHeader // {
  +        serviceConfig = iNotifyService // {
  +          ExecStart = "${pkgs.syncthing-inotify.bin}/bin/syncthing-inotify -logflags=0";
  +        };
  +      });
  +    };
  +
     };
   }
  
positive.code:         to Dropbox and Bittorrent Sync. Initial interface will be
          available on http://127.0.0.1:8384/.
        '';
  
        systemService = mkOption {
          type = types.bool;
  
negative.code:     RestartForceExitStatus="3 4";
    };
  
    iNotifyHeader = {
      description = "Syncthing Inotify File Watcher service";
      after = [ "network.target" "syncthing.service" ];
      requires = [ "syncthing.service" ];
    };
  
    iNotifyService = {
      SuccessExitStatus = "2";
      RestartForceExitStatus = "3";
      Restart = "on-failure";
    };
  
  in
  
  {
  