1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2025-01-11 11:39:49 +01:00

syncthing: add cfg variable for convenience

This commit is contained in:
Robert Helgesson 2022-01-27 00:30:39 +01:00
parent 86248a2d5c
commit 24ed6e6d4d
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -2,7 +2,11 @@
with lib; with lib;
{ let
cfg = config.services.syncthing;
in {
meta.maintainers = [ maintainers.rycee ]; meta.maintainers = [ maintainers.rycee ];
options = { options = {
@ -52,7 +56,7 @@ with lib;
}; };
config = mkMerge [ config = mkMerge [
(mkIf config.services.syncthing.enable { (mkIf cfg.enable {
home.packages = [ (getOutput "man" pkgs.syncthing) ]; home.packages = [ (getOutput "man" pkgs.syncthing) ];
systemd.user.services = { systemd.user.services = {
@ -67,8 +71,8 @@ with lib;
Service = { Service = {
ExecStart = ExecStart =
"${pkgs.syncthing}/bin/syncthing -no-browser -no-restart -logflags=0" "${pkgs.syncthing}/bin/syncthing -no-browser -no-restart -logflags=0"
+ optionalString (config.services.syncthing.extraOptions != [ ]) + optionalString (cfg.extraOptions != [ ])
(" " + escapeShellArgs config.services.syncthing.extraOptions); (" " + escapeShellArgs cfg.extraOptions);
Restart = "on-failure"; Restart = "on-failure";
SuccessExitStatus = [ 3 4 ]; SuccessExitStatus = [ 3 4 ];
RestartForceExitStatus = [ 3 4 ]; RestartForceExitStatus = [ 3 4 ];
@ -88,49 +92,46 @@ with lib;
}; };
}) })
(mkIf (isAttrs config.services.syncthing.tray (mkIf (isAttrs cfg.tray && cfg.tray.enable) {
&& config.services.syncthing.tray.enable) { systemd.user.services = {
systemd.user.services = { ${cfg.tray.package.pname} = {
${config.services.syncthing.tray.package.pname} = { Unit = {
Unit = { Description = cfg.tray.package.pname;
Description = config.services.syncthing.tray.package.pname; Requires = [ "tray.target" ];
Requires = [ "tray.target" ]; After = [ "graphical-session-pre.target" "tray.target" ];
After = [ "graphical-session-pre.target" "tray.target" ]; PartOf = [ "graphical-session.target" ];
PartOf = [ "graphical-session.target" ];
};
Service = {
ExecStart =
"${config.services.syncthing.tray.package}/bin/${config.services.syncthing.tray.command}";
};
Install = { WantedBy = [ "graphical-session.target" ]; };
}; };
Service = {
ExecStart = "${cfg.tray.package}/bin/${cfg.tray.command}";
};
Install = { WantedBy = [ "graphical-session.target" ]; };
}; };
}) };
})
# deprecated # deprecated
(mkIf (isBool config.services.syncthing.tray (mkIf (isBool cfg.tray && cfg.tray) {
&& config.services.syncthing.tray) { systemd.user.services = {
systemd.user.services = { "syncthingtray" = {
"syncthingtray" = { Unit = {
Unit = { Description = "syncthingtray";
Description = "syncthingtray"; Requires = [ "tray.target" ];
Requires = [ "tray.target" ]; After = [ "graphical-session-pre.target" "tray.target" ];
After = [ "graphical-session-pre.target" "tray.target" ]; PartOf = [ "graphical-session.target" ];
PartOf = [ "graphical-session.target" ];
};
Service = {
ExecStart = "${pkgs.syncthingtray-minimal}/bin/syncthingtray";
};
Install = { WantedBy = [ "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."
}) ];
})
]; ];
} }