1{ lib, pkgs, config, ... }:
2
3with lib;
4let
5 cfg = config.modules.desktop;
6
7 mkConfig = input: monitor: pkgs.writeText "hyprland.conf" ''
8 debug {
9 error_position=1
10 }
11
12 general {
13 allow_tearing=true
14 }
15
16 input {
17 touchpad {
18 clickfinger_behavior=true
19 scroll_factor=0.180000
20 tap-and-drag=false
21 tap-to-click=false
22 }
23 kb_options=ctrl:nocaps,lv3:ralt_switch
24 kb_layout=${cfg.hyprland.input.kb_layout}
25 kb_model=${cfg.hyprland.input.kb_model}
26 kb_variant=${cfg.hyprland.input.kb_variant}
27 sensitivity=${toString cfg.hyprland.input.sensitivity}
28 accel_profile = "flat"
29 }
30
31 misc {
32 disable_hyprland_logo=true
33 disable_splash_rendering=true
34 vrr=1
35 }
36
37 render {
38 direct_scanout=1
39 expand_undersized_textures=false
40 cm_fs_passthrough=1
41 cm_enabled=true
42 }
43
44 experimental {
45 xx_color_management_v4=true
46 }
47
48 cursor {
49 sync_gsettings_theme=false
50 }
51
52 ecosystem {
53 no_update_news = true
54 no_donation_nag = true
55 }
56
57 ${concatMapStringsSep "\n" (x: "monitor=${x}") cfg.hyprland.monitor}
58 monitor=, preferred, auto, 1
59 '';
60in {
61 options.modules.desktop.hyprland = {
62 enable = mkOption {
63 default = cfg.enable;
64 example = true;
65 description = "Whether to enable Hyprland";
66 type = types.bool;
67 };
68
69 input = mkOption {
70 default = { };
71 type = types.submodule {
72 options = {
73 sensitivity = mkOption {
74 default = 0.0;
75 type = types.float;
76 };
77 kb_model = mkOption {
78 default = "apple";
79 type = types.str;
80 };
81 kb_variant = mkOption {
82 default = "mac";
83 type = types.str;
84 };
85 kb_layout = mkOption {
86 default = "gb";
87 type = types.str;
88 };
89 };
90 };
91 };
92
93 monitor = mkOption {
94 description = "Monitor configuration";
95 default = [ ];
96 type = lib.types.listOf lib.types.str;
97 };
98
99 configFile = mkOption {
100 default = mkConfig cfg.hyprland.input cfg.hyprland.monitor;
101 };
102 };
103
104 config = mkIf cfg.hyprland.enable {
105 programs = {
106 hyprlock.enable = true;
107 hyprland = {
108 enable = true;
109 withUWSM = true;
110 xwayland.enable = true;
111 };
112 };
113
114 security.pam.services.hyprlock = {};
115
116 xdg.portal = {
117 enable = true;
118 xdgOpenUsePortal = true;
119 extraPortals = with pkgs; [
120 xdg-desktop-portal-hyprland
121 xdg-desktop-portal-gtk
122 ];
123 };
124
125 environment.etc."hypr/hyprland.conf".source = cfg.hyprland.configFile;
126 };
127}