From 04f223946ce67184dfe8d0a0c66b76f6fb91ab3c Mon Sep 17 00:00:00 2001 From: John Titor <50095635+JohnRTitor@users.noreply.github.com> Date: Thu, 14 Nov 2024 23:55:22 +0530 Subject: [PATCH] nixos/hyprland: adds programs.hyprland.withUWSM option 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/ --- nixos/modules/programs/wayland/hyprland.nix | 33 +++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/nixos/modules/programs/wayland/hyprland.nix b/nixos/modules/programs/wayland/hyprland.nix index 2a1948d522945..d00f2a188d6d5 100644 --- a/nixos/modules/programs/wayland/hyprland.nix +++ b/nixos/modules/programs/wayland/hyprland.nix @@ -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"''; @@ -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 ]; @@ -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;