fix(hyprland): make services more reliable

nixos
Moritz Böhme 2023-04-30 18:35:46 +02:00
parent 35ddc6a33c
commit 6fad257d5b
Signed by: moritz
GPG Key ID: 970C6E89EB0547A9
1 changed files with 36 additions and 25 deletions

View File

@ -44,6 +44,7 @@ in
wayland.windowManager.hyprland = { wayland.windowManager.hyprland = {
enable = true; enable = true;
package = hyprland; package = hyprland;
recommendedEnvironment = true;
extraConfig = import ./config.nix args; extraConfig = import ./config.nix args;
}; };
}; };
@ -59,7 +60,7 @@ in
# start using systemd service # start using systemd service
systemd = { systemd = {
enable = true; enable = true;
target = "hyprland-session.target"; target = "graphical-session.target";
}; };
settings = { settings = {
@ -87,11 +88,11 @@ in
events = [ events = [
{ {
event = "before-sleep"; event = "before-sleep";
command = "${pkgs.swaylock-effects}/bin/swaylock -fF"; command = "${pkgs.swaylock}/bin/swaylock -fF";
} }
{ {
event = "lock"; event = "lock";
command = "${pkgs.swaylock-effects}/bin/swaylock -fF"; command = "${pkgs.swaylock}/bin/swaylock -fF";
} }
]; ];
timeouts = [ timeouts = [
@ -105,10 +106,8 @@ in
command = "${pkgs.systemd}/bin/loginctl lock-session"; command = "${pkgs.systemd}/bin/loginctl lock-session";
} }
]; ];
systemdTarget = "hyprland-session.target";
}; };
# start swayidle as part of hyprland, not sway
systemd.user.services.swayidle.Install.WantedBy = lib.mkForce [ "hyprland-session.target" ];
}; };
# adds pam module for swaylock # adds pam module for swaylock
@ -116,27 +115,28 @@ in
# start hyprpaper daemon using systemd unit (to set wallpaper) # start hyprpaper daemon using systemd unit (to set wallpaper)
systemd.user.services.hyprpaper = { systemd.user.services.hyprpaper =
enable = true;
path = [ pkgs.hyprpaper ];
wantedBy = [ "hyprland-session.target" ];
after = [ "hyprland-session.target" ];
script = "hyprpaper";
};
# set hyprpaper conf (for setting initial background)
home-manager.users.moritz.xdg.configFile."hypr/hyprpaper.conf" = {
text =
let let
setWallpaper = wallpaper: '' wallpaper = "/home/moritz/.config/wallpapers/a_short_walk.png";
config = pkgs.writeTextFile {
name = "hyprpaper.conf";
text = ''
preload = ${wallpaper} preload = ${wallpaper}
wallpaper = ,${wallpaper} wallpaper = ,${wallpaper}
''; '';
in
setWallpaper "/home/moritz/.config/wallpapers/a_short_walk.png";
onChange = "${pkgs.systemd}/bin/systemctl restart --user hyprpaper.service";
}; };
in
{
enable = true;
partOf = [ "graphical-session.target" ];
wantedBy = [ "graphical-session.target" ];
after = [ "graphical-session.target" ];
serviceConfig = {
ExecStart = "${pkgs.hyprpaper}/bin/hyprpaper -c ${config}";
RestartSec = "1s";
Restart = "on-failure";
};
};
# only consider graphical-session.target started when hyprland-sesstion.target is reached # only consider graphical-session.target started when hyprland-sesstion.target is reached
systemd.user.targets.hyprland-session = { systemd.user.targets.hyprland-session = {
@ -144,6 +144,17 @@ in
before = [ "graphical-session.target" ]; before = [ "graphical-session.target" ];
}; };
systemd.user.services.xdg-desktop-portal-hyprland = {
after = [ "hyprland-session.target" ];
wantedBy = [ "hyprland-session.target" ];
};
home-manager.users.moritz.systemd.user.services.nextcloud-client = {
Service = {
RestartSec = "1s";
Restart = "on-failure";
};
};
# add user packages for wayland and hyprland in particular # add user packages for wayland and hyprland in particular
users.users.moritz.packages = with pkgs; [ users.users.moritz.packages = with pkgs; [
@ -206,7 +217,7 @@ in
# dekstop portal (for screensharing) # dekstop portal (for screensharing)
xdg.portal = { xdg.portal = {
enable = true; enable = true;
wlr.enable = true; wlr.enable = mkForce false;
extraPortals = [ pkgs.xdg-desktop-portal-hyprland ]; extraPortals = [ pkgs.xdg-desktop-portal-hyprland ];
}; };
}; };