1{ config
2, lib
3, pkgs
4, ...
5}:
6with lib; let
7 cfg = config.programs.hyprland;
8
9 defaultHyprlandPackage = pkgs.hyprland.override {
10 enableXWayland = cfg.xwayland.enable;
11 hidpiXWayland = cfg.xwayland.hidpi;
12 nvidiaPatches = cfg.nvidiaPatches;
13 };
14in
15{
16 options.programs.hyprland = {
17 enable = mkEnableOption null // {
18 description = mdDoc ''
19 Hyprland, the dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
20
21 You can manually launch Hyprland by executing {command}`Hyprland` on a TTY.
22
23 A configuration file will be generated in {file}`~/.config/hypr/hyprland.conf`.
24 See <https://wiki.hyprland.org> for more information.
25 '';
26 };
27
28 package = mkOption {
29 type = types.path;
30 default = defaultHyprlandPackage;
31 defaultText = literalExpression ''
32 pkgs.hyprland.override {
33 enableXWayland = config.programs.hyprland.xwayland.enable;
34 hidpiXWayland = config.programs.hyprland.xwayland.hidpi;
35 nvidiaPatches = config.programs.hyprland.nvidiaPatches;
36 }
37 '';
38 example = literalExpression "<Hyprland flake>.packages.<system>.default";
39 description = mdDoc ''
40 The Hyprland package to use.
41 Setting this option will make {option}`programs.hyprland.xwayland` and
42 {option}`programs.hyprland.nvidiaPatches` not work.
43 '';
44 };
45
46 xwayland = {
47 enable = mkEnableOption (mdDoc "XWayland") // { default = true; };
48 hidpi = mkEnableOption null // {
49 description = mdDoc ''
50 Enable HiDPI XWayland, based on [XWayland MR 733](https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/733).
51 See <https://wiki.hyprland.org/Nix/Options-Overrides/#xwayland-hidpi> for more info.
52 '';
53 };
54 };
55
56 nvidiaPatches = mkEnableOption (mdDoc "patching wlroots for better Nvidia support");
57 };
58
59 config = mkIf cfg.enable {
60 environment.systemPackages = [ cfg.package ];
61
62 fonts.enableDefaultFonts = mkDefault true;
63 hardware.opengl.enable = mkDefault true;
64
65 programs = {
66 dconf.enable = mkDefault true;
67 xwayland.enable = mkDefault cfg.xwayland.enable;
68 };
69
70 security.polkit.enable = true;
71
72 services.xserver.displayManager.sessionPackages = [ cfg.package ];
73
74 xdg.portal = {
75 enable = mkDefault true;
76 extraPortals = [
77 pkgs.xdg-desktop-portal-hyprland
78 ];
79 };
80 };
81}