blob: 6f7008809d2e0da70b59b0ffc1cc21fd1c89743d [file] [log] [blame]
Skyler Grey4e230892024-02-13 22:58:46 +00001{
2 pkgs,
3 config,
4 inputs,
5 system,
6 lib,
7 ...
8}:
9let
Skyler Greya0da6b22024-02-11 22:53:41 +000010 lock = "${pkgs.waylock}/bin/waylock";
Skyler Grey4e230892024-02-13 22:58:46 +000011in
12{
Skyler Grey71b81982024-02-15 18:06:36 +000013 options.chimera = {
Skyler Grey5e344982024-02-15 18:59:45 +000014 input.mouse.scrolling.natural = lib.mkEnableOption "Enable natural scrolling";
15 input.touchpad.scrolling.natural = lib.mkOption {
16 type = lib.types.bool;
17 description = "Enable natural scrolling";
18 default = config.chimera.input.mouse.scrolling.natural;
19 };
Skyler Grey71b81982024-02-15 18:06:36 +000020 input.keyboard = {
21 layout = lib.mkOption {
22 type = lib.types.str;
23 description = "Keyboard layouts, comma seperated";
24 example = "us,de";
25 default = "us";
26 };
27 variant = lib.mkOption {
28 type = lib.types.nullOr lib.types.str;
29 description = "Keyboard layout variants, comma seperated";
30 example = "dvorak";
31 default = null;
32 };
33 };
PineaFan66e46742024-04-20 20:59:22 +010034
PineaFan2f02bca2024-04-20 21:21:44 +010035 input.keybinds = {
36 alternativeSearch.enable = lib.mkEnableOption "Use alt + space or SUPER + D to open search";
PineaFand1a8b742024-04-23 21:09:26 +010037 volumeStep = lib.mkOption {
38 type = lib.types.int;
39 description = "Amount to increase volume by when media keys are pressed in %";
40 example = "5";
41 default = 5;
42 };
PineaFan2f02bca2024-04-20 21:21:44 +010043 extraBinds = let
44 binds = lib.types.submodule {
45 options = {
46 meta = lib.mkOption {
47 type = lib.types.nullOr lib.types.str;
48 description = "Additional modifier keys space seperated";
49 default = null;
50 };
51 key = lib.mkOption {
52 type = lib.types.str;
53 description = "Final key";
54 };
55 function = lib.mkOption {
56 type = lib.types.str;
57 description = "Hyprland bind function";
58 };
59 };
60 };
61 in lib.mkOption {
62 type = lib.types.listOf binds;
63 description = "Extra keybinds to add";
64 default = [ ];
65 };
66 };
PineaFan4c21b842024-04-23 21:09:59 +010067 startupApplications = lib.mkOption {
68 type = lib.types.listOf lib.types.str;
69 description = "List of commands to run on hyprland start";
70 default = [ ];
71 };
PineaFan2f02bca2024-04-20 21:21:44 +010072
PineaFan66e46742024-04-20 20:59:22 +010073 nvidia.enable = lib.mkEnableOption "Enable NVIDIA support";
74
Skyler Grey71b81982024-02-15 18:06:36 +000075 hyprland = {
76 enable = lib.mkEnableOption "Use hyprland as your window manager";
Skyler Grey71b81982024-02-15 18:06:36 +000077 monitors = lib.mkOption {
78 type = lib.types.listOf lib.types.str;
79 description = "List of default monitors to set";
80 default = [ ];
81 };
PineaFan2f02bca2024-04-20 21:21:44 +010082 window = {
83 rounding = lib.mkOption {
84 type = lib.types.int;
85 description = "How round the windows should be";
86 default = 7;
87 };
88 blur = lib.mkOption {
89 type = lib.types.int;
90 description = "How blurred the wallpaper under innactive windows should be";
91 default = 8;
92 };
93 };
Skyler Grey4e230892024-02-13 22:58:46 +000094 };
95 };
96
Skyler Grey4e230892024-02-13 22:58:46 +000097 config = lib.mkIf config.chimera.hyprland.enable {
Samuel Shuertdab963e2024-03-23 19:54:28 -040098 chimera.waybar.enable = lib.mkDefault true;
99
Skyler Greyb8bc97b2024-02-25 11:12:08 +0000100 programs.bash.profileExtra = lib.mkIf config.chimera.shell.bash.enable (lib.mkBefore ''
101 if [ -z $WAYLAND_DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
Skyler Greyfb254d22024-03-03 13:03:22 +0000102 exec ${pkgs.systemd}/bin/systemd-cat -t hyprland ${pkgs.dbus}/bin/dbus-run-session ${config.wayland.windowManager.hyprland.package}/bin/Hyprland
Skyler Greyb8bc97b2024-02-25 11:12:08 +0000103 fi
104 '');
105
106 programs.zsh.profileExtra = lib.mkIf config.chimera.shell.zsh.enable (lib.mkBefore ''
107 if [ -z $WAYLAND_DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
Skyler Greyfb254d22024-03-03 13:03:22 +0000108 exec ${pkgs.systemd}/bin/systemd-cat -t hyprland ${pkgs.dbus}/bin/dbus-run-session ${config.wayland.windowManager.hyprland.package}/bin/Hyprland
Skyler Greyb8bc97b2024-02-25 11:12:08 +0000109 fi
110 '');
111
Skyler Grey4e230892024-02-13 22:58:46 +0000112 home.packages = [ pkgs.hyprpicker ];
Skyler Greya0da6b22024-02-11 22:53:41 +0000113
Skyler Grey4e230892024-02-13 22:58:46 +0000114 services.fusuma.settings.swipe = lib.mkIf config.chimera.touchpad.enable (
115 let
116 hyprctl = "${config.wayland.windowManager.hyprland.package}/bin/hyprctl";
117 jq = "${pkgs.jq}/bin/jq";
118 awk = "${pkgs.gawk}/bin/awk";
119 in
120 {
121 "3".up.command = "${hyprctl} dispatch fullscreen 0";
122 "3".down.command = "${hyprctl} dispatch fullscreen 0";
123 "4".down.command = lock;
124 "3".left.command = "${hyprctl} dispatch workspace $(${hyprctl} activeworkspace -j | ${jq} .id | ${awk} '{print $1+1}')";
125 "3".right.command = "${hyprctl} dispatch workspace $(${hyprctl} activeworkspace -j | ${jq} .id | ${awk} '{print $1-1}')";
126 }
127 );
Skyler Greya0da6b22024-02-11 22:53:41 +0000128
Skyler Grey4e230892024-02-13 22:58:46 +0000129 wayland.windowManager.hyprland = {
130 enable = true;
Skyler Greya0da6b22024-02-11 22:53:41 +0000131
Skyler Grey4e230892024-02-13 22:58:46 +0000132 xwayland.enable = true;
133 systemd.enable = true;
Skyler Greya0da6b22024-02-11 22:53:41 +0000134
Skyler Grey4e230892024-02-13 22:58:46 +0000135 settings =
136 let
137 mod = "SUPER";
138 terminal = "${pkgs.kitty}/bin/kitty";
Samuel Shuert004d0752024-03-02 11:57:09 -0500139 menu = (if config.chimera.runner.anyrun.enable then "${inputs.anyrun.packages.${system}.anyrun}/bin/anyrun" else "");
PineaFan2f02bca2024-04-20 21:21:44 +0100140 screenshot = "${pkgs.grim}/bin/grim -g \"$(${pkgs.slurp}/bin/slurp -d)\" - | ${pkgs.wl-clipboard}/bin/wl-copy";
Skyler Grey4e230892024-02-13 22:58:46 +0000141 in
142 {
143 misc = {
144 disable_hyprland_logo = true;
145 disable_splash_rendering = true;
146 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000147
Skyler Greye3e18d32024-02-17 11:33:17 +0000148 exec-once = [
Samuel Shuert659b5642024-02-23 20:47:43 +0000149 "${pkgs.hyprpaper}/bin/hyprpaper"
150 "hyprctl setcursor ${config.chimera.theme.cursor.name} ${builtins.toString config.chimera.theme.cursor.size}"
Samuel Shuertdab963e2024-03-23 19:54:28 -0400151 "${pkgs.waybar}/bin/waybar"
PineaFan4c21b842024-04-23 21:09:59 +0100152 ] ++ config.chimera.startupApplications;
Skyler Greya0da6b22024-02-11 22:53:41 +0000153
Skyler Grey4e230892024-02-13 22:58:46 +0000154 monitor = config.chimera.hyprland.monitors ++ [ ",preferred,auto,1" ];
Skyler Greya0da6b22024-02-11 22:53:41 +0000155
Skyler Greyabaa6072024-02-15 19:07:00 +0000156 general = {
157 border_size = 1;
158 "col.active_border" = "rgba(${config.chimera.theme.colors.Surface0.hex}FF)";
159 "col.inactive_border" = "rgba(${config.chimera.theme.colors.Surface0.hex}FF)";
160 };
161
Skyler Grey4e230892024-02-13 22:58:46 +0000162 decoration = {
PineaFan2f02bca2024-04-20 21:21:44 +0100163 rounding = config.chimera.hyprland.window.rounding;
Skyler Greyabaa6072024-02-15 19:07:00 +0000164 drop_shadow = false;
PineaFan2f02bca2024-04-20 21:21:44 +0100165 blur.size = config.chimera.hyprland.window.blur;
Skyler Grey4e230892024-02-13 22:58:46 +0000166 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000167
Skyler Grey4e230892024-02-13 22:58:46 +0000168 input = {
Skyler Grey71b81982024-02-15 18:06:36 +0000169 kb_layout = config.chimera.input.keyboard.layout;
Skyler Greyec50d242024-02-15 23:09:46 +0000170 kb_variant =
171 lib.mkIf (config.chimera.input.keyboard.variant != null)
172 config.chimera.input.keyboard.variant;
Skyler Grey5e344982024-02-15 18:59:45 +0000173 natural_scroll = config.chimera.input.mouse.scrolling.natural;
174
175 numlock_by_default = true;
Skyler Greya0da6b22024-02-11 22:53:41 +0000176
Skyler Grey4e230892024-02-13 22:58:46 +0000177 touchpad = {
Skyler Grey5e344982024-02-15 18:59:45 +0000178 natural_scroll = config.chimera.input.touchpad.scrolling.natural;
Skyler Grey4e230892024-02-13 22:58:46 +0000179 };
180 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000181
Skyler Grey4e230892024-02-13 22:58:46 +0000182 xwayland = {
183 force_zero_scaling = true;
184 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000185
Skyler Grey4e230892024-02-13 22:58:46 +0000186 dwindle = {
187 pseudotile = true;
188 smart_split = true;
189 };
190
191 master = {
192 allow_small_split = true;
193 new_is_master = true;
194 };
195
196 windowrulev2 = [ "opacity 1.0 0.85,title:(.*)" ];
197
198 bind =
199 [
200 "${mod}, Q, killactive"
201 "${mod}, SPACE, togglefloating"
202 "${mod}, RETURN, exec, ${terminal}"
203 "${mod}, down, movefocus, d"
204 "${mod}, up, movefocus, u"
205 "${mod}, right, movefocus, r"
206 "${mod}, left, movefocus, l"
207 "${mod}, L, exec, ${lock}"
PineaFan2f02bca2024-04-20 21:21:44 +0100208 "${mod}, R, exec, ${screenshot}"
209 ", Print, exec, ${screenshot}"
Skyler Greya0da6b22024-02-11 22:53:41 +0000210 ]
Samuel Shuert004d0752024-03-02 11:57:09 -0500211 ++ (if config.chimera.runner.enable then [ "${mod}, D, exec, ${menu}" ] else [])
PineaFan2f02bca2024-04-20 21:21:44 +0100212 ++ (if lib.and config.chimera.input.keybinds.alternativeSearch.enable config.chimera.runner.enable then [ "ALT, SPACE, exec, ${menu}" ] else [])
Skyler Grey4e230892024-02-13 22:58:46 +0000213 ++ (builtins.concatLists (
214 builtins.genList
215 (
216 x:
217 let
218 ws =
219 let
220 c = (x + 1) / 10;
221 in
222 builtins.toString (x + 1 - (c * 10));
223 in
224 [
225 "${mod}, ${ws}, workspace, ${toString (x + 1)}"
226 "${mod} SHIFT, ${ws}, movetoworkspace, ${toString (x + 1)}"
227 ]
228 )
229 10
PineaFan2f02bca2024-04-20 21:21:44 +0100230 ))
PineaFand1a8b742024-04-23 21:09:26 +0100231 ++ (builtins.map (item: "SUPER${if isNull item.meta then "" else "_${item.meta}"}, ${item.key}, ${item.function}") config.chimera.input.keybinds.extraBinds)
232 ++ [
233 # Volume controls
234 ", XF86AudioRaiseVolume, exec, ${pkgs.pamixer}/bin/pamixer -i ${toString config.chimera.input.keybinds.volumeStep}"
235 ", XF86AudioLowerVolume, exec, ${pkgs.pamixer}/bin/pamixer -d ${toString config.chimera.input.keybinds.volumeStep}"
236 ", XF86AudioMute, exec, ${pkgs.pamixer}/bin/pamixer -t"
237 # Pause and play
238 ", XF86AudioPlay, exec, ${pkgs.playerctl}/bin/playerctl play-pause"
239 # Next and previous
240 ", XF86AudioNext, exec, ${pkgs.playerctl}/bin/playerctl next"
241 ", XF86AudioPrev, exec, ${pkgs.playerctl}/bin/playerctl previous"
242 ];
Skyler Greya0da6b22024-02-11 22:53:41 +0000243
Skyler Grey4e230892024-02-13 22:58:46 +0000244 bindm = [
245 "${mod}, mouse:272, movewindow"
246 "${mod}, mouse:273, resizewindow"
247 ];
PineaFan66e46742024-04-20 20:59:22 +0100248
249 env = lib.mkIf config.chimera.nvidia.enable [
250 "LIBVA_DRIVER_NAME,nvidia"
251 "XDG_SESSION_TYPE,wayland"
252 "GBM_BACKEND,nvidia-drm"
253 "__GLX_VENDOR_LIBRARY_NAME,nvidia"
254 "WLR_NO_HARDWARE_CURSORS,1"
PineaFan2f02bca2024-04-20 21:21:44 +0100255 ];
Skyler Grey4e230892024-02-13 22:58:46 +0000256 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000257 };
258 };
Skyler Grey4e230892024-02-13 22:58:46 +0000259}