blob: 3e4a4243d04302998af66792439a8e37161edb64 [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";
37 extraBinds = let
38 binds = lib.types.submodule {
39 options = {
40 meta = lib.mkOption {
41 type = lib.types.nullOr lib.types.str;
42 description = "Additional modifier keys space seperated";
43 default = null;
44 };
45 key = lib.mkOption {
46 type = lib.types.str;
47 description = "Final key";
48 };
49 function = lib.mkOption {
50 type = lib.types.str;
51 description = "Hyprland bind function";
52 };
53 };
54 };
55 in lib.mkOption {
56 type = lib.types.listOf binds;
57 description = "Extra keybinds to add";
58 default = [ ];
59 };
60 };
61
PineaFan66e46742024-04-20 20:59:22 +010062 nvidia.enable = lib.mkEnableOption "Enable NVIDIA support";
63
Skyler Grey71b81982024-02-15 18:06:36 +000064 hyprland = {
65 enable = lib.mkEnableOption "Use hyprland as your window manager";
Skyler Grey71b81982024-02-15 18:06:36 +000066 monitors = lib.mkOption {
67 type = lib.types.listOf lib.types.str;
68 description = "List of default monitors to set";
69 default = [ ];
70 };
PineaFan2f02bca2024-04-20 21:21:44 +010071 window = {
72 rounding = lib.mkOption {
73 type = lib.types.int;
74 description = "How round the windows should be";
75 default = 7;
76 };
77 blur = lib.mkOption {
78 type = lib.types.int;
79 description = "How blurred the wallpaper under innactive windows should be";
80 default = 8;
81 };
82 };
Skyler Grey4e230892024-02-13 22:58:46 +000083 };
84 };
85
Skyler Grey4e230892024-02-13 22:58:46 +000086 config = lib.mkIf config.chimera.hyprland.enable {
Samuel Shuertdab963e2024-03-23 19:54:28 -040087 chimera.waybar.enable = lib.mkDefault true;
88
Skyler Greyb8bc97b2024-02-25 11:12:08 +000089 programs.bash.profileExtra = lib.mkIf config.chimera.shell.bash.enable (lib.mkBefore ''
90 if [ -z $WAYLAND_DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
Skyler Greyfb254d22024-03-03 13:03:22 +000091 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 +000092 fi
93 '');
94
95 programs.zsh.profileExtra = lib.mkIf config.chimera.shell.zsh.enable (lib.mkBefore ''
96 if [ -z $WAYLAND_DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
Skyler Greyfb254d22024-03-03 13:03:22 +000097 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 +000098 fi
99 '');
100
Skyler Grey4e230892024-02-13 22:58:46 +0000101 home.packages = [ pkgs.hyprpicker ];
Skyler Greya0da6b22024-02-11 22:53:41 +0000102
Skyler Grey4e230892024-02-13 22:58:46 +0000103 services.fusuma.settings.swipe = lib.mkIf config.chimera.touchpad.enable (
104 let
105 hyprctl = "${config.wayland.windowManager.hyprland.package}/bin/hyprctl";
106 jq = "${pkgs.jq}/bin/jq";
107 awk = "${pkgs.gawk}/bin/awk";
108 in
109 {
110 "3".up.command = "${hyprctl} dispatch fullscreen 0";
111 "3".down.command = "${hyprctl} dispatch fullscreen 0";
112 "4".down.command = lock;
113 "3".left.command = "${hyprctl} dispatch workspace $(${hyprctl} activeworkspace -j | ${jq} .id | ${awk} '{print $1+1}')";
114 "3".right.command = "${hyprctl} dispatch workspace $(${hyprctl} activeworkspace -j | ${jq} .id | ${awk} '{print $1-1}')";
115 }
116 );
Skyler Greya0da6b22024-02-11 22:53:41 +0000117
Skyler Grey4e230892024-02-13 22:58:46 +0000118 wayland.windowManager.hyprland = {
119 enable = true;
Skyler Greya0da6b22024-02-11 22:53:41 +0000120
Skyler Grey4e230892024-02-13 22:58:46 +0000121 xwayland.enable = true;
122 systemd.enable = true;
Skyler Greya0da6b22024-02-11 22:53:41 +0000123
Skyler Grey4e230892024-02-13 22:58:46 +0000124 settings =
125 let
126 mod = "SUPER";
127 terminal = "${pkgs.kitty}/bin/kitty";
Samuel Shuert004d0752024-03-02 11:57:09 -0500128 menu = (if config.chimera.runner.anyrun.enable then "${inputs.anyrun.packages.${system}.anyrun}/bin/anyrun" else "");
PineaFan2f02bca2024-04-20 21:21:44 +0100129 screenshot = "${pkgs.grim}/bin/grim -g \"$(${pkgs.slurp}/bin/slurp -d)\" - | ${pkgs.wl-clipboard}/bin/wl-copy";
Skyler Grey4e230892024-02-13 22:58:46 +0000130 in
131 {
132 misc = {
133 disable_hyprland_logo = true;
134 disable_splash_rendering = true;
135 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000136
Skyler Greye3e18d32024-02-17 11:33:17 +0000137 exec-once = [
Samuel Shuert659b5642024-02-23 20:47:43 +0000138 "${pkgs.hyprpaper}/bin/hyprpaper"
139 "hyprctl setcursor ${config.chimera.theme.cursor.name} ${builtins.toString config.chimera.theme.cursor.size}"
Samuel Shuertdab963e2024-03-23 19:54:28 -0400140 "${pkgs.waybar}/bin/waybar"
Samuel Shuert659b5642024-02-23 20:47:43 +0000141 ];
Skyler Greya0da6b22024-02-11 22:53:41 +0000142
Skyler Grey4e230892024-02-13 22:58:46 +0000143 monitor = config.chimera.hyprland.monitors ++ [ ",preferred,auto,1" ];
Skyler Greya0da6b22024-02-11 22:53:41 +0000144
Skyler Greyabaa6072024-02-15 19:07:00 +0000145 general = {
146 border_size = 1;
147 "col.active_border" = "rgba(${config.chimera.theme.colors.Surface0.hex}FF)";
148 "col.inactive_border" = "rgba(${config.chimera.theme.colors.Surface0.hex}FF)";
149 };
150
Skyler Grey4e230892024-02-13 22:58:46 +0000151 decoration = {
PineaFan2f02bca2024-04-20 21:21:44 +0100152 rounding = config.chimera.hyprland.window.rounding;
Skyler Greyabaa6072024-02-15 19:07:00 +0000153 drop_shadow = false;
PineaFan2f02bca2024-04-20 21:21:44 +0100154 blur.size = config.chimera.hyprland.window.blur;
Skyler Grey4e230892024-02-13 22:58:46 +0000155 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000156
Skyler Grey4e230892024-02-13 22:58:46 +0000157 input = {
Skyler Grey71b81982024-02-15 18:06:36 +0000158 kb_layout = config.chimera.input.keyboard.layout;
Skyler Greyec50d242024-02-15 23:09:46 +0000159 kb_variant =
160 lib.mkIf (config.chimera.input.keyboard.variant != null)
161 config.chimera.input.keyboard.variant;
Skyler Grey5e344982024-02-15 18:59:45 +0000162 natural_scroll = config.chimera.input.mouse.scrolling.natural;
163
164 numlock_by_default = true;
Skyler Greya0da6b22024-02-11 22:53:41 +0000165
Skyler Grey4e230892024-02-13 22:58:46 +0000166 touchpad = {
Skyler Grey5e344982024-02-15 18:59:45 +0000167 natural_scroll = config.chimera.input.touchpad.scrolling.natural;
Skyler Grey4e230892024-02-13 22:58:46 +0000168 };
169 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000170
Skyler Grey4e230892024-02-13 22:58:46 +0000171 xwayland = {
172 force_zero_scaling = true;
173 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000174
Skyler Grey4e230892024-02-13 22:58:46 +0000175 dwindle = {
176 pseudotile = true;
177 smart_split = true;
178 };
179
180 master = {
181 allow_small_split = true;
182 new_is_master = true;
183 };
184
185 windowrulev2 = [ "opacity 1.0 0.85,title:(.*)" ];
186
187 bind =
188 [
189 "${mod}, Q, killactive"
190 "${mod}, SPACE, togglefloating"
191 "${mod}, RETURN, exec, ${terminal}"
192 "${mod}, down, movefocus, d"
193 "${mod}, up, movefocus, u"
194 "${mod}, right, movefocus, r"
195 "${mod}, left, movefocus, l"
196 "${mod}, L, exec, ${lock}"
PineaFan2f02bca2024-04-20 21:21:44 +0100197 "${mod}, R, exec, ${screenshot}"
198 ", Print, exec, ${screenshot}"
Skyler Greya0da6b22024-02-11 22:53:41 +0000199 ]
Samuel Shuert004d0752024-03-02 11:57:09 -0500200 ++ (if config.chimera.runner.enable then [ "${mod}, D, exec, ${menu}" ] else [])
PineaFan2f02bca2024-04-20 21:21:44 +0100201 ++ (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 +0000202 ++ (builtins.concatLists (
203 builtins.genList
204 (
205 x:
206 let
207 ws =
208 let
209 c = (x + 1) / 10;
210 in
211 builtins.toString (x + 1 - (c * 10));
212 in
213 [
214 "${mod}, ${ws}, workspace, ${toString (x + 1)}"
215 "${mod} SHIFT, ${ws}, movetoworkspace, ${toString (x + 1)}"
216 ]
217 )
218 10
PineaFan2f02bca2024-04-20 21:21:44 +0100219 ))
220 ++ (builtins.map (item: "SUPER_${item.meta}, ${item.key}, ${item.function}") config.chimera.input.keybinds.extraBinds);
Skyler Greya0da6b22024-02-11 22:53:41 +0000221
Skyler Grey4e230892024-02-13 22:58:46 +0000222 bindm = [
223 "${mod}, mouse:272, movewindow"
224 "${mod}, mouse:273, resizewindow"
225 ];
PineaFan66e46742024-04-20 20:59:22 +0100226
227 env = lib.mkIf config.chimera.nvidia.enable [
228 "LIBVA_DRIVER_NAME,nvidia"
229 "XDG_SESSION_TYPE,wayland"
230 "GBM_BACKEND,nvidia-drm"
231 "__GLX_VENDOR_LIBRARY_NAME,nvidia"
232 "WLR_NO_HARDWARE_CURSORS,1"
PineaFan2f02bca2024-04-20 21:21:44 +0100233 ];
Skyler Grey4e230892024-02-13 22:58:46 +0000234 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000235 };
236 };
Skyler Grey4e230892024-02-13 22:58:46 +0000237}