mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 11:36:05 +01:00
The service fails on Home Manager switch every now and then. This commit add explicit stop and restart settings to it. This also adds some additional parameters used in the upstream service definition.
56 lines
1.3 KiB
Nix
56 lines
1.3 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
|
|
cfg = config.services.nextcloud-client;
|
|
|
|
in
|
|
{
|
|
options = {
|
|
services.nextcloud-client = {
|
|
enable = lib.mkEnableOption "Nextcloud Client";
|
|
|
|
package = lib.mkPackageOption pkgs "nextcloud-client" { };
|
|
|
|
startInBackground = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
description = "Whether to start the Nextcloud client in the background.";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
assertions = [
|
|
(lib.hm.assertions.assertPlatform "services.nextcloud-client" pkgs lib.platforms.linux)
|
|
];
|
|
|
|
systemd.user.services.nextcloud-client = {
|
|
Unit = {
|
|
Description = "Nextcloud Client";
|
|
After = [ "graphical-session.target" ];
|
|
PartOf = [ "graphical-session.target" ];
|
|
};
|
|
|
|
Service = {
|
|
Environment = [ "PATH=${config.home.profileDirectory}/bin" ];
|
|
ExecStart =
|
|
"${cfg.package}/bin/nextcloud" + (lib.optionalString cfg.startInBackground " --background");
|
|
ExecStop = "${cfg.package}/bin/nextcloud --quit";
|
|
KillMode = "process";
|
|
Restart = "on-failure";
|
|
RestartSec = "5s";
|
|
NoNewPrivileges = true;
|
|
RestrictRealtime = true;
|
|
};
|
|
|
|
Install = {
|
|
WantedBy = [ "graphical-session.target" ];
|
|
};
|
|
};
|
|
};
|
|
}
|