2017-07-17 08:10:15 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
{
|
2017-09-26 21:40:31 +00:00
|
|
|
meta.maintainers = [ maintainers.rycee ];
|
|
|
|
|
2017-07-17 08:10:15 +00:00
|
|
|
options = {
|
|
|
|
services.syncthing = {
|
2017-07-18 11:49:02 +00:00
|
|
|
enable = mkEnableOption "Syncthing continuous file synchronization";
|
2018-01-21 20:24:48 +00:00
|
|
|
|
|
|
|
tray = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Whether to enable QSyncthingTray service.";
|
|
|
|
};
|
2017-07-17 08:10:15 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-01-30 19:15:31 +00:00
|
|
|
config = mkMerge [
|
|
|
|
(mkIf config.services.syncthing.enable {
|
2018-01-21 20:24:48 +00:00
|
|
|
systemd.user.services = {
|
|
|
|
syncthing = {
|
|
|
|
Unit = {
|
2020-02-01 23:39:17 +00:00
|
|
|
Description =
|
|
|
|
"Syncthing - Open Source Continuous File Synchronization";
|
2018-01-21 20:24:48 +00:00
|
|
|
Documentation = "man:syncthing(1)";
|
|
|
|
After = [ "network.target" ];
|
|
|
|
};
|
2017-07-17 08:10:15 +00:00
|
|
|
|
2018-01-21 20:24:48 +00:00
|
|
|
Service = {
|
2020-02-01 23:39:17 +00:00
|
|
|
ExecStart =
|
|
|
|
"${pkgs.syncthing}/bin/syncthing -no-browser -no-restart -logflags=0";
|
2018-01-21 20:24:48 +00:00
|
|
|
Restart = "on-failure";
|
|
|
|
SuccessExitStatus = [ 3 4 ];
|
|
|
|
RestartForceExitStatus = [ 3 4 ];
|
|
|
|
};
|
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
Install = { WantedBy = [ "default.target" ]; };
|
2018-01-21 20:24:48 +00:00
|
|
|
};
|
2017-07-18 11:49:02 +00:00
|
|
|
};
|
2018-01-30 19:15:31 +00:00
|
|
|
})
|
|
|
|
|
2018-01-21 20:24:48 +00:00
|
|
|
(mkIf config.services.syncthing.tray {
|
|
|
|
systemd.user.services = {
|
|
|
|
qsyncthingtray = {
|
|
|
|
Unit = {
|
|
|
|
Description = "QSyncthingTray";
|
2020-02-01 23:39:17 +00:00
|
|
|
After = [
|
|
|
|
"graphical-session-pre.target"
|
|
|
|
"polybar.service"
|
|
|
|
"taffybar.service"
|
|
|
|
"stalonetray.service"
|
|
|
|
];
|
2018-01-21 20:24:48 +00:00
|
|
|
PartOf = [ "graphical-session.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
Service = {
|
2018-07-29 16:15:50 +00:00
|
|
|
Environment = "PATH=${config.home.profileDirectory}/bin";
|
2018-01-21 20:24:48 +00:00
|
|
|
ExecStart = "${pkgs.qsyncthingtray}/bin/QSyncthingTray";
|
|
|
|
};
|
2017-07-17 08:10:15 +00:00
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
Install = { WantedBy = [ "graphical-session.target" ]; };
|
2018-01-21 20:24:48 +00:00
|
|
|
};
|
2017-07-18 11:49:02 +00:00
|
|
|
};
|
2018-01-21 20:24:48 +00:00
|
|
|
})
|
2018-01-30 19:15:31 +00:00
|
|
|
];
|
2017-07-17 08:10:15 +00:00
|
|
|
}
|