2017-07-17 10:10:15 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
{
|
2018-01-21 21:24:48 +01:00
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule
|
|
|
|
[ "services" "qsyncthingtray" "enable" ]
|
|
|
|
[ "services" "syncthing" "tray" ])
|
|
|
|
];
|
|
|
|
|
2017-09-26 23:40:31 +02:00
|
|
|
meta.maintainers = [ maintainers.rycee ];
|
|
|
|
|
2017-07-17 10:10:15 +02:00
|
|
|
options = {
|
|
|
|
services.syncthing = {
|
2017-07-18 13:49:02 +02:00
|
|
|
enable = mkEnableOption "Syncthing continuous file synchronization";
|
2018-01-21 21:24:48 +01:00
|
|
|
|
|
|
|
tray = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Whether to enable QSyncthingTray service.";
|
|
|
|
};
|
2017-07-17 10:10:15 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-01-30 20:15:31 +01:00
|
|
|
config = mkMerge [
|
|
|
|
(mkIf config.services.syncthing.enable {
|
2018-01-21 21:24:48 +01:00
|
|
|
systemd.user.services = {
|
|
|
|
syncthing = {
|
|
|
|
Unit = {
|
|
|
|
Description = "Syncthing - Open Source Continuous File Synchronization";
|
|
|
|
Documentation = "man:syncthing(1)";
|
|
|
|
After = [ "network.target" ];
|
|
|
|
};
|
2017-07-17 10:10:15 +02:00
|
|
|
|
2018-01-21 21:24:48 +01:00
|
|
|
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" ];
|
|
|
|
};
|
|
|
|
};
|
2017-07-18 13:49:02 +02:00
|
|
|
};
|
2018-01-30 20:15:31 +01:00
|
|
|
})
|
|
|
|
|
2018-01-21 21:24:48 +01:00
|
|
|
(mkIf config.services.syncthing.tray {
|
|
|
|
systemd.user.services = {
|
|
|
|
qsyncthingtray = {
|
|
|
|
Unit = {
|
|
|
|
Description = "QSyncthingTray";
|
2018-01-27 13:03:28 +01:00
|
|
|
After = [ "graphical-session-pre.target" "polybar.service" "taffybar.service" ];
|
2018-01-21 21:24:48 +01:00
|
|
|
PartOf = [ "graphical-session.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
Service = {
|
|
|
|
ExecStart = "${pkgs.qsyncthingtray}/bin/QSyncthingTray";
|
|
|
|
};
|
2017-07-17 10:10:15 +02:00
|
|
|
|
2018-01-21 21:24:48 +01:00
|
|
|
Install = {
|
|
|
|
WantedBy = [ "graphical-session.target" ];
|
|
|
|
};
|
|
|
|
};
|
2017-07-18 13:49:02 +02:00
|
|
|
};
|
2018-01-21 21:24:48 +01:00
|
|
|
})
|
2018-01-30 20:15:31 +01:00
|
|
|
];
|
2017-07-17 10:10:15 +02:00
|
|
|
}
|