1{ config
2, lib
3, pkgs
4, ...
5}:
6with lib; let
7 cfg = config.programs.hyprland;
8
9 finalPortalPackage = cfg.portalPackage.override {
10 hyprland = cfg.finalPackage;
11 };
12in
13{
14 options.programs.hyprland = {
15 enable = mkEnableOption null // {
16 description = mdDoc ''
17 Hyprland, the dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
18
19 You can manually launch Hyprland by executing {command}`Hyprland` on a TTY.
20
21 A configuration file will be generated in {file}`~/.config/hypr/hyprland.conf`.
22 See <https://wiki.hyprland.org> for more information.
23 '';
24 };
25
26 package = mkPackageOptionMD pkgs "hyprland" { };
27
28 finalPackage = mkOption {
29 type = types.package;
30 readOnly = true;
31 default = cfg.package.override {
32 enableXWayland = cfg.xwayland.enable;
33 enableNvidiaPatches = cfg.enableNvidiaPatches;
34 };
35 defaultText = literalExpression
36 "`programs.hyprland.package` with applied configuration";
37 description = mdDoc ''
38 The Hyprland package after applying configuration.
39 '';
40 };
41
42 portalPackage = mkPackageOptionMD pkgs "xdg-desktop-portal-hyprland" { };
43
44 xwayland.enable = mkEnableOption (mdDoc "XWayland") // { default = true; };
45
46 enableNvidiaPatches = mkEnableOption (mdDoc "patching wlroots for better Nvidia support");
47 };
48
49 config = mkIf cfg.enable {
50 environment.systemPackages = [ cfg.finalPackage ];
51
52 fonts.enableDefaultPackages = mkDefault true;
53 hardware.opengl.enable = mkDefault true;
54
55 programs = {
56 dconf.enable = mkDefault true;
57 xwayland.enable = mkDefault cfg.xwayland.enable;
58 };
59
60 security.polkit.enable = true;
61
62 services.xserver.displayManager.sessionPackages = [ cfg.finalPackage ];
63
64 xdg.portal = {
65 enable = mkDefault true;
66 extraPortals = [ finalPortalPackage ];
67 };
68 };
69
70 imports = with lib; [
71 (mkRemovedOptionModule
72 [ "programs" "hyprland" "xwayland" "hidpi" ]
73 "XWayland patches are deprecated. Refer to https://wiki.hyprland.org/Configuring/XWayland"
74 )
75 (mkRenamedOptionModule
76 [ "programs" "hyprland" "nvidiaPatches" ]
77 [ "programs" "hyprland" "enableNvidiaPatches" ]
78 )
79 ];
80}