syncthing: make syncthing tray package configurable (#1257)

Also sets the default syncthing tray package to
https://github.com/Martchus/syncthingtray instead of
https://github.com/sieren/QSyncthingTray, which indirectly fixes #603
This commit is contained in:
Nick Hu 2021-05-18 15:43:17 +01:00 committed by GitHub
parent f9e45390de
commit 3612ca58e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 133 additions and 23 deletions

View file

@ -2000,6 +2000,27 @@ in
login shells.
'';
}
{
time = "2021-05-18T12:22:42+00:00";
condition = config.services.syncthing != {};
message = ''
Setting 'services.syncthing.tray' as a boolean will be deprecated in
the future.
This is to make the syncthing tray package configurable, with
`services.syncthing.tray.package`, following QSyncthingTray becoming
no longer actively maintained. The default syncthing tray package has
also changed to https://github.com/Martchus/syncthingtray. To
continue as before, set `services.syncthing.tray.enable`.
See
https://github.com/nix-community/home-manager/pulls/1257
for discussion.
'';
}
];
};
}

View file

@ -10,9 +10,34 @@ with lib;
enable = mkEnableOption "Syncthing continuous file synchronization";
tray = mkOption {
type = types.bool;
default = false;
description = "Whether to enable QSyncthingTray service.";
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.";
};
};
};
@ -43,28 +68,57 @@ with lib;
};
})
(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" ];
};
(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" ];
};
Service = {
Environment = "PATH=${config.home.profileDirectory}/bin";
ExecStart = "${pkgs.qsyncthingtray}/bin/QSyncthingTray";
};
Service = {
ExecStart =
"${config.services.syncthing.tray.package}/bin/${config.services.syncthing.tray.command}";
};
Install = { WantedBy = [ "graphical-session.target" ]; };
Install = { WantedBy = [ "graphical-session.target" ]; };
};
};
};
})
})
# 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";
};
Install = { WantedBy = [ "graphical-session.target" ]; };
};
};
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."
];
})
];
}

View file

@ -114,6 +114,7 @@ import nmt {
./modules/services/polybar
./modules/services/redshift-gammastep
./modules/services/sxhkd
./modules/services/syncthing
./modules/services/window-managers/i3
./modules/services/window-managers/sway
./modules/services/wlsunset

View file

@ -0,0 +1,4 @@
{
syncthing-tray = ./tray.nix;
syncthing-tray-as-bool-triggers-warning = ./tray-as-bool-triggers-warning.nix;
}

View file

@ -0,0 +1,17 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
services.syncthing.tray = true;
test.asserts.warnings.expected = [
"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."
];
nmt.script = ''
assertFileExists home-files/.config/systemd/user/syncthingtray.service
'';
};
}

View file

@ -0,0 +1,13 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
services.syncthing.tray.enable = true;
nmt.script = ''
assertFileExists home-files/.config/systemd/user/syncthingtray.service
'';
};
}