diff options
Diffstat (limited to 'home-manager/modules/services/syncthing.nix')
-rw-r--r-- | home-manager/modules/services/syncthing.nix | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/home-manager/modules/services/syncthing.nix b/home-manager/modules/services/syncthing.nix new file mode 100644 index 00000000000..2ef10540164 --- /dev/null +++ b/home-manager/modules/services/syncthing.nix @@ -0,0 +1,68 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + meta.maintainers = [ maintainers.rycee ]; + + options = { + services.syncthing = { + enable = mkEnableOption "Syncthing continuous file synchronization"; + + tray = mkOption { + type = types.bool; + default = false; + description = "Whether to enable QSyncthingTray service."; + }; + }; + }; + + config = mkMerge [ + (mkIf config.services.syncthing.enable { + systemd.user.services = { + syncthing = { + Unit = { + Description = + "Syncthing - Open Source Continuous File Synchronization"; + Documentation = "man:syncthing(1)"; + After = [ "network.target" ]; + }; + + Service = { + ExecStart = + "${pkgs.syncthing}/bin/syncthing -no-browser -no-restart -logflags=0"; + Restart = "on-failure"; + SuccessExitStatus = [ 3 4 ]; + RestartForceExitStatus = [ 3 4 ]; + }; + + Install = { WantedBy = [ "default.target" ]; }; + }; + }; + }) + + (mkIf config.services.syncthing.tray { + systemd.user.services = { + qsyncthingtray = { + Unit = { + Description = "QSyncthingTray"; + After = [ + "graphical-session-pre.target" + "polybar.service" + "taffybar.service" + "stalonetray.service" + ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + Environment = "PATH=${config.home.profileDirectory}/bin"; + ExecStart = "${pkgs.qsyncthingtray}/bin/QSyncthingTray"; + }; + + Install = { WantedBy = [ "graphical-session.target" ]; }; + }; + }; + }) + ]; +} |