git.iko.soy/typeable/nixpkgs
on master help sign in
syncthing service: add syncthing-inotify (#17320)
commitadeab67bd80c7dc2d94152f3231c5940ae10a337 authorjokogr <ioannis.koutras@gmail.com> dateSat 6 Aug 2016, 18:20 (10 years ago) parentf126b1a
1 file changed+43−12
nixos/modules/services/networking/syncthing.nix+43−12
nixos/modules/services/networking/syncthing.nix+43−12
@@ -23,6 +23,18 @@ let
2323 RestartForceExitStatus="3 4";
2424 };
2525
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+
2638in
2739
2840{
@@ -39,6 +51,12 @@ in
3951 available on http://127.0.0.1:8384/.
4052 '';
4153
54+ useInotify = mkOption {
55+ type = types.bool;
56+ default = false;
57+ description = "Provide syncthing-inotify as a service.";
58+ };
59+
4260 systemService = mkOption {
4361 type = types.bool;
4462 default = true;
@@ -112,27 +130,40 @@ in
112130 config.ids.gids.syncthing;
113131 };
114132
115− environment.systemPackages = [ cfg.package ];
116−
117− systemd.services = mkIf cfg.systemService {
118− syncthing = header // {
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 // {
119146 wantedBy = [ "multi-user.target" ];
120− serviceConfig = service // {
147+ serviceConfig = iNotifyService // {
121148 User = cfg.user;
122− Group = cfg.group;
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";
125150 };
126− };
151+ });
127152 };
128153
129− systemd.user.services.syncthing =
130− header // {
131− wantedBy = [ "default.target" ];
154+ systemd.user.services = {
155+ syncthing = header // {
132156 serviceConfig = service // {
133157 ExecStart = "${cfg.package}/bin/syncthing -no-browser";
134158 };
135159 };
136160
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+
137168 };
138169}