@@ -23,6 +23,18 @@ let
23 RestartForceExitStatus="3 4";
23 RestartForceExitStatus="3 4";
27+ description = "Syncthing Inotify File Watcher service";
28+ after = [ "network.target" "syncthing.service" ];
29+ requires = [ "syncthing.service" ];
33+ SuccessExitStatus = "2";
34+ RestartForceExitStatus = "3";
35+ Restart = "on-failure";
@@ -39,6 +51,12 @@ in
39 available on http://127.0.0.1:8384/.
51 available on http://127.0.0.1:8384/.
54+ useInotify = mkOption {
57+ description = "Provide syncthing-inotify as a service.";
42 systemService = mkOption {
60 systemService = mkOption {
43 type = types.bool;
61 type = types.bool;
44 default = true;
62 default = true;
@@ -112,27 +130,40 @@ in
112 config.ids.gids.syncthing;
130 config.ids.gids.syncthing;
115− environment.systemPackages = [ cfg.package ];
117− systemd.services = mkIf cfg.systemService {
133+ systemd.services = {
118− syncthing = header // {
134+ syncthing = mkIf cfg.systemService (header // {
135+ wants = mkIf cfg.useInotify [ "syncthing-inotify.service" ];
136+ wantedBy = [ "multi-user.target" ];
137+ serviceConfig = service // {
140+ PermissionsStartOnly = true;
141+ ExecStart = "${cfg.package}/bin/syncthing -no-browser -home=${cfg.dataDir}";
145+ syncthing-inotify = mkIf (cfg.systemService && cfg.useInotify) (iNotifyHeader // {
119 wantedBy = [ "multi-user.target" ];
146 wantedBy = [ "multi-user.target" ];
120− serviceConfig = service // {
147+ serviceConfig = iNotifyService // {
121 User = cfg.user;
148 User = cfg.user;
123− PermissionsStartOnly = true;
124− ExecStart = "${cfg.package}/bin/syncthing -no-browser -home=${cfg.dataDir}";
149+ ExecStart = "${pkgs.syncthing-inotify.bin}/bin/syncthing-inotify -home=${cfg.dataDir} -logflags=0";
129− systemd.user.services.syncthing =
154+ systemd.user.services = {
130− header // {
155+ syncthing = header // {
131− wantedBy = [ "default.target" ];
132 serviceConfig = service // {
156 serviceConfig = service // {
133 ExecStart = "${cfg.package}/bin/syncthing -no-browser";
157 ExecStart = "${cfg.package}/bin/syncthing -no-browser";
161+ syncthing-inotify = mkIf cfg.useInotify (iNotifyHeader // {
162+ serviceConfig = iNotifyService // {
163+ ExecStart = "${pkgs.syncthing-inotify.bin}/bin/syncthing-inotify -logflags=0";