Skip to content

Commit

Permalink
home-manager/desktop: init systemd.service
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Jan 3, 2025
1 parent 9583c57 commit fac9192
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
19 changes: 19 additions & 0 deletions modules/home-manager/desktop/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ in
enable = lib.mkEnableOption "desktop config" // {
default = osConfig.nixos.desktop.enable or false;
};
systemd.service = {
# Use exponential restart
# https://enotty.pipebreaker.pl/posts/2024/01/how-systemd-exponential-restart-delay-works/
RestartSec = lib.mkOption {
type = lib.types.str;
description = "How long to wait between restarts.";
default = "250ms";
};
RestartSteps = lib.mkOption {
type = lib.types.int;
description = "Number of steps to take to increase the interval of auto-restarts.";
default = 5;
};
RestartMaxDelaySec = lib.mkOption {
type = lib.types.str;
description = "Longest time to sleep before restarting a service as the interval goes up.";
default = "5s";
};
};
default = {
browser = lib.mkOption {
type = lib.types.str;
Expand Down
6 changes: 1 addition & 5 deletions modules/home-manager/desktop/wayland/kanshi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ in

systemd.user.services.kanshi = {
Service = {
# Use exponential restart
# https://enotty.pipebreaker.pl/posts/2024/01/how-systemd-exponential-restart-delay-works/
RestartSec = "250ms";
RestartSteps = 5;
RestartMaxDelaySec = 5;
inherit (config.home-manager.desktop.systemd.service) RestartSec RestartSteps RestartMaxDelaySec;
};
};
};
Expand Down
6 changes: 1 addition & 5 deletions modules/home-manager/desktop/wayland/swayidle.nix
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,9 @@ in
];
};

# Add some time before restart, to avoid the following error:
# swayidle.service: Start request repeated too quickly.
systemd.user.services.swayidle = {
Service = {
# Use exponential restart
RestartSteps = 5;
RestartMaxDelaySec = 10;
inherit (config.home-manager.desktop.systemd.service) RestartSec RestartSteps RestartMaxDelaySec;
};
};
};
Expand Down
6 changes: 1 addition & 5 deletions modules/home-manager/desktop/wayland/waybar.nix
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,7 @@ in

systemd.user.services.waybar = {
Service = {
# Use exponential restart
# https://enotty.pipebreaker.pl/posts/2024/01/how-systemd-exponential-restart-delay-works/
RestartSec = "250ms";
RestartSteps = 5;
RestartMaxDelaySec = 5;
inherit (config.home-manager.desktop.systemd.service) RestartSec RestartSteps RestartMaxDelaySec;
};
};
};
Expand Down

0 comments on commit fac9192

Please sign in to comment.