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:
parent
f9e45390de
commit
3612ca58e8
|
@ -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.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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."
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
4
tests/modules/services/syncthing/default.nix
Normal file
4
tests/modules/services/syncthing/default.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
syncthing-tray = ./tray.nix;
|
||||
syncthing-tray-as-bool-triggers-warning = ./tray-as-bool-triggers-warning.nix;
|
||||
}
|
|
@ -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
|
||||
'';
|
||||
};
|
||||
}
|
13
tests/modules/services/syncthing/tray.nix
Normal file
13
tests/modules/services/syncthing/tray.nix
Normal 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
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue