Skip to content

Commit

Permalink
nixos/hyprland: adds programs.hyprland.withUWSM option
Browse files Browse the repository at this point in the history
Bool: controls whether Hyprland is configured with UWSM or not.

Upstream recommends using UWSM for better compatibility with systemd integration.
https://wiki.hyprland.org/Useful-Utilities/Systemd-start/
  • Loading branch information
JohnRTitor committed Nov 15, 2024
1 parent 48da44a commit 04f2239
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions nixos/modules/programs/wayland/hyprland.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ in
default = true;
};

withUWSM = lib.mkEnableOption null // {
description = ''
Launch Hyprland with the UWSM (Universal Wayland Session Manager) session manager.
This has improved systemd support and is recommended for most users.
This automatically starts appropiate targets like `graphical-session.target`,
and `wayland-session@Hyprland.target`.
::: {.note}
Some changes may need to be made to Hyprland configs depending on your setup, see
[Hyprland wiki](https://wiki.hyprland.org/Useful-Utilities/Systemd-start/#uwsm).
:::
'';
};

systemd.setPath.enable = lib.mkEnableOption null // {
default = lib.versionOlder cfg.package.version "0.41.2";
defaultText = lib.literalExpression ''lib.versionOlder cfg.package.version "0.41.2"'';
Expand All @@ -69,9 +83,6 @@ in
{
environment.systemPackages = [ cfg.package ];

# To make a Hyprland session available if a display manager like SDDM is enabled:
services.displayManager.sessionPackages = [ cfg.package ];

xdg.portal = {
enable = true;
extraPortals = [ cfg.portalPackage ];
Expand All @@ -85,6 +96,22 @@ in
};
}

(lib.mkIf (cfg.withUWSM) {
programs.uwsm.enable = true;
# Configure UWSM to launch Hyprland from a display manager like SDDM
programs.uwsm.waylandCompositors = {
hyprland = {
prettyName = "Hyprland";
comment = "Hyprland compositor managed by UWSM";
binPath = "/run/current-system/sw/bin/Hyprland";
};
};
})
(lib.mkIf (!cfg.withUWSM) {
# To make a vanilla Hyprland session available in DM
services.displayManager.sessionPackages = [ cfg.package ];
})

(import ./wayland-session.nix {
inherit lib pkgs;
enableXWayland = cfg.xwayland.enable;
Expand Down

0 comments on commit 04f2239

Please sign in to comment.