syncthing service: add syncthing-inotify (#17320)

authored by

jokogr and committed by
Franz Pletz
adeab67b f126b1a7

+42 -11
+42 -11
nixos/modules/services/networking/syncthing.nix
··· 23 RestartForceExitStatus="3 4"; 24 }; 25 26 in 27 28 { ··· 38 to Dropbox and Bittorrent Sync. Initial interface will be 39 available on http://127.0.0.1:8384/. 40 ''; 41 42 systemService = mkOption { 43 type = types.bool; ··· 112 config.ids.gids.syncthing; 113 }; 114 115 - environment.systemPackages = [ cfg.package ]; 116 117 - systemd.services = mkIf cfg.systemService { 118 - syncthing = header // { 119 wantedBy = [ "multi-user.target" ]; 120 - serviceConfig = service // { 121 User = cfg.user; 122 - Group = cfg.group; 123 - PermissionsStartOnly = true; 124 - ExecStart = "${cfg.package}/bin/syncthing -no-browser -home=${cfg.dataDir}"; 125 }; 126 - }; 127 }; 128 129 - systemd.user.services.syncthing = 130 - header // { 131 - wantedBy = [ "default.target" ]; 132 serviceConfig = service // { 133 ExecStart = "${cfg.package}/bin/syncthing -no-browser"; 134 }; 135 }; 136 137 }; 138 }
··· 23 RestartForceExitStatus="3 4"; 24 }; 25 26 + iNotifyHeader = { 27 + description = "Syncthing Inotify File Watcher service"; 28 + after = [ "network.target" "syncthing.service" ]; 29 + requires = [ "syncthing.service" ]; 30 + }; 31 + 32 + iNotifyService = { 33 + SuccessExitStatus = "2"; 34 + RestartForceExitStatus = "3"; 35 + Restart = "on-failure"; 36 + }; 37 + 38 in 39 40 { ··· 50 to Dropbox and Bittorrent Sync. Initial interface will be 51 available on http://127.0.0.1:8384/. 52 ''; 53 + 54 + useInotify = mkOption { 55 + type = types.bool; 56 + default = false; 57 + description = "Provide syncthing-inotify as a service."; 58 + }; 59 60 systemService = mkOption { 61 type = types.bool; ··· 130 config.ids.gids.syncthing; 131 }; 132 133 + systemd.services = { 134 + syncthing = mkIf cfg.systemService (header // { 135 + wants = mkIf cfg.useInotify [ "syncthing-inotify.service" ]; 136 + wantedBy = [ "multi-user.target" ]; 137 + serviceConfig = service // { 138 + User = cfg.user; 139 + Group = cfg.group; 140 + PermissionsStartOnly = true; 141 + ExecStart = "${cfg.package}/bin/syncthing -no-browser -home=${cfg.dataDir}"; 142 + }; 143 + }); 144 145 + syncthing-inotify = mkIf (cfg.systemService && cfg.useInotify) (iNotifyHeader // { 146 wantedBy = [ "multi-user.target" ]; 147 + serviceConfig = iNotifyService // { 148 User = cfg.user; 149 + ExecStart = "${pkgs.syncthing-inotify.bin}/bin/syncthing-inotify -home=${cfg.dataDir} -logflags=0"; 150 }; 151 + }); 152 }; 153 154 + systemd.user.services = { 155 + syncthing = header // { 156 serviceConfig = service // { 157 ExecStart = "${cfg.package}/bin/syncthing -no-browser"; 158 }; 159 }; 160 + 161 + syncthing-inotify = mkIf cfg.useInotify (iNotifyHeader // { 162 + serviceConfig = iNotifyService // { 163 + ExecStart = "${pkgs.syncthing-inotify.bin}/bin/syncthing-inotify -logflags=0"; 164 + }; 165 + }); 166 + }; 167 168 }; 169 }