mirror of
https://github.com/nix-community/home-manager
synced 2024-12-23 10:19:48 +01:00
syncthing: add cfg
variable for convenience
This commit is contained in:
parent
86248a2d5c
commit
24ed6e6d4d
1 changed files with 43 additions and 42 deletions
|
@ -2,7 +2,11 @@
|
|||
|
||||
with lib;
|
||||
|
||||
{
|
||||
let
|
||||
|
||||
cfg = config.services.syncthing;
|
||||
|
||||
in {
|
||||
meta.maintainers = [ maintainers.rycee ];
|
||||
|
||||
options = {
|
||||
|
@ -52,7 +56,7 @@ with lib;
|
|||
};
|
||||
|
||||
config = mkMerge [
|
||||
(mkIf config.services.syncthing.enable {
|
||||
(mkIf cfg.enable {
|
||||
home.packages = [ (getOutput "man" pkgs.syncthing) ];
|
||||
|
||||
systemd.user.services = {
|
||||
|
@ -67,8 +71,8 @@ with lib;
|
|||
Service = {
|
||||
ExecStart =
|
||||
"${pkgs.syncthing}/bin/syncthing -no-browser -no-restart -logflags=0"
|
||||
+ optionalString (config.services.syncthing.extraOptions != [ ])
|
||||
(" " + escapeShellArgs config.services.syncthing.extraOptions);
|
||||
+ optionalString (cfg.extraOptions != [ ])
|
||||
(" " + escapeShellArgs cfg.extraOptions);
|
||||
Restart = "on-failure";
|
||||
SuccessExitStatus = [ 3 4 ];
|
||||
RestartForceExitStatus = [ 3 4 ];
|
||||
|
@ -88,49 +92,46 @@ with lib;
|
|||
};
|
||||
})
|
||||
|
||||
(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;
|
||||
Requires = [ "tray.target" ];
|
||||
After = [ "graphical-session-pre.target" "tray.target" ];
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
ExecStart =
|
||||
"${config.services.syncthing.tray.package}/bin/${config.services.syncthing.tray.command}";
|
||||
};
|
||||
|
||||
Install = { WantedBy = [ "graphical-session.target" ]; };
|
||||
(mkIf (isAttrs cfg.tray && cfg.tray.enable) {
|
||||
systemd.user.services = {
|
||||
${cfg.tray.package.pname} = {
|
||||
Unit = {
|
||||
Description = cfg.tray.package.pname;
|
||||
Requires = [ "tray.target" ];
|
||||
After = [ "graphical-session-pre.target" "tray.target" ];
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
ExecStart = "${cfg.tray.package}/bin/${cfg.tray.command}";
|
||||
};
|
||||
|
||||
Install = { WantedBy = [ "graphical-session.target" ]; };
|
||||
};
|
||||
})
|
||||
};
|
||||
})
|
||||
|
||||
# deprecated
|
||||
(mkIf (isBool config.services.syncthing.tray
|
||||
&& config.services.syncthing.tray) {
|
||||
systemd.user.services = {
|
||||
"syncthingtray" = {
|
||||
Unit = {
|
||||
Description = "syncthingtray";
|
||||
Requires = [ "tray.target" ];
|
||||
After = [ "graphical-session-pre.target" "tray.target" ];
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
ExecStart = "${pkgs.syncthingtray-minimal}/bin/syncthingtray";
|
||||
};
|
||||
|
||||
Install = { WantedBy = [ "graphical-session.target" ]; };
|
||||
(mkIf (isBool cfg.tray && cfg.tray) {
|
||||
systemd.user.services = {
|
||||
"syncthingtray" = {
|
||||
Unit = {
|
||||
Description = "syncthingtray";
|
||||
Requires = [ "tray.target" ];
|
||||
After = [ "graphical-session-pre.target" "tray.target" ];
|
||||
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."
|
||||
];
|
||||
})
|
||||
};
|
||||
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."
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue