2017-07-17 10:10:15 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
{
|
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 {
|
2021-05-18 16:43:17 +02:00
|
|
|
type = with types;
|
|
|
|
either bool (submodule {
|
|
|
|
options = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Whether to enable a syncthing tray service.";
|
|
|
|
};
|
|
|
|
|
|
|
|
command = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "syncthingtray";
|
|
|
|
defaultText = literalExample "syncthingtray";
|
|
|
|
example = literalExample "qsyncthingtray";
|
|
|
|
description = "Syncthing tray command to use.";
|
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.syncthingtray-minimal;
|
|
|
|
defaultText = literalExample "pkgs.syncthingtray-minimal";
|
|
|
|
example = literalExample "pkgs.qsyncthingtray";
|
|
|
|
description = "Syncthing tray package to use.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
default = { enable = false; };
|
|
|
|
description = "Syncthing tray service configuration.";
|
2018-01-21 21:24:48 +01:00
|
|
|
};
|
2017-07-17 10:10:15 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-01-30 20:15:31 +01:00
|
|
|
config = mkMerge [
|
|
|
|
(mkIf config.services.syncthing.enable {
|
2020-03-22 21:13:05 +01:00
|
|
|
home.packages = [ (getOutput "man" pkgs.syncthing) ];
|
|
|
|
|
2018-01-21 21:24:48 +01:00
|
|
|
systemd.user.services = {
|
|
|
|
syncthing = {
|
|
|
|
Unit = {
|
2020-02-02 00:39:17 +01:00
|
|
|
Description =
|
|
|
|
"Syncthing - Open Source Continuous File Synchronization";
|
2018-01-21 21:24:48 +01:00
|
|
|
Documentation = "man:syncthing(1)";
|
|
|
|
After = [ "network.target" ];
|
|
|
|
};
|
2017-07-17 10:10:15 +02:00
|
|
|
|
2018-01-21 21:24:48 +01:00
|
|
|
Service = {
|
2020-02-02 00:39:17 +01:00
|
|
|
ExecStart =
|
|
|
|
"${pkgs.syncthing}/bin/syncthing -no-browser -no-restart -logflags=0";
|
2018-01-21 21:24:48 +01:00
|
|
|
Restart = "on-failure";
|
|
|
|
SuccessExitStatus = [ 3 4 ];
|
|
|
|
RestartForceExitStatus = [ 3 4 ];
|
|
|
|
};
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
Install = { WantedBy = [ "default.target" ]; };
|
2018-01-21 21:24:48 +01:00
|
|
|
};
|
2017-07-18 13:49:02 +02:00
|
|
|
};
|
2018-01-30 20:15:31 +01:00
|
|
|
})
|
|
|
|
|
2021-05-18 16:43:17 +02:00
|
|
|
(mkIf (isAttrs config.services.syncthing.tray
|
|
|
|
&& config.services.syncthing.tray.enable) {
|
|
|
|
systemd.user.services = {
|
|
|
|
${config.services.syncthing.tray.package.pname} = {
|
|
|
|
Unit = {
|
|
|
|
Description = config.services.syncthing.tray.package.pname;
|
|
|
|
After = [
|
|
|
|
"graphical-session-pre.target"
|
|
|
|
"polybar.service"
|
|
|
|
"taffybar.service"
|
|
|
|
"stalonetray.service"
|
|
|
|
];
|
|
|
|
PartOf = [ "graphical-session.target" ];
|
|
|
|
};
|
2018-01-21 21:24:48 +01:00
|
|
|
|
2021-05-18 16:43:17 +02:00
|
|
|
Service = {
|
|
|
|
ExecStart =
|
|
|
|
"${config.services.syncthing.tray.package}/bin/${config.services.syncthing.tray.command}";
|
|
|
|
};
|
|
|
|
|
|
|
|
Install = { WantedBy = [ "graphical-session.target" ]; };
|
2018-01-21 21:24:48 +01:00
|
|
|
};
|
2021-05-18 16:43:17 +02:00
|
|
|
};
|
|
|
|
})
|
|
|
|
|
|
|
|
# deprecated
|
|
|
|
(mkIf (isBool config.services.syncthing.tray
|
|
|
|
&& config.services.syncthing.tray) {
|
|
|
|
systemd.user.services = {
|
|
|
|
"syncthingtray" = {
|
|
|
|
Unit = {
|
|
|
|
Description = "syncthingtray";
|
|
|
|
After = [
|
|
|
|
"graphical-session-pre.target"
|
|
|
|
"polybar.service"
|
|
|
|
"taffybar.service"
|
|
|
|
"stalonetray.service"
|
|
|
|
];
|
|
|
|
PartOf = [ "graphical-session.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
Service = {
|
|
|
|
ExecStart = "${pkgs.syncthingtray-minimal}/bin/syncthingtray";
|
|
|
|
};
|
2017-07-17 10:10:15 +02:00
|
|
|
|
2021-05-18 16:43:17 +02:00
|
|
|
Install = { WantedBy = [ "graphical-session.target" ]; };
|
|
|
|
};
|
2018-01-21 21:24:48 +01:00
|
|
|
};
|
2021-05-18 16:43:17 +02:00
|
|
|
warnings = [
|
|
|
|
"Specifying 'services.syncthing.tray' as a boolean is deprecated, set 'services.syncthing.tray.enable' instead. See https://github.com/nix-community/home-manager/pull/1257."
|
|
|
|
];
|
|
|
|
})
|
2018-01-30 20:15:31 +01:00
|
|
|
];
|
2017-07-17 10:10:15 +02:00
|
|
|
}
|