blob: 4aa178d95065de659bb9249671907e29bb550673 [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
35 nvidia.enable = lib.mkEnableOption "Enable NVIDIA support";
36
Skyler Grey71b81982024-02-15 18:06:36 +000037 hyprland = {
38 enable = lib.mkEnableOption "Use hyprland as your window manager";
Skyler Grey71b81982024-02-15 18:06:36 +000039 monitors = lib.mkOption {
40 type = lib.types.listOf lib.types.str;
41 description = "List of default monitors to set";
42 default = [ ];
43 };
Skyler Grey4e230892024-02-13 22:58:46 +000044 };
45 };
46
Skyler Grey4e230892024-02-13 22:58:46 +000047 config = lib.mkIf config.chimera.hyprland.enable {
Samuel Shuertdab963e2024-03-23 19:54:28 -040048 chimera.waybar.enable = lib.mkDefault true;
49
Skyler Greyb8bc97b2024-02-25 11:12:08 +000050 programs.bash.profileExtra = lib.mkIf config.chimera.shell.bash.enable (lib.mkBefore ''
51 if [ -z $WAYLAND_DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
Skyler Greyfb254d22024-03-03 13:03:22 +000052 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 +000053 fi
54 '');
55
56 programs.zsh.profileExtra = lib.mkIf config.chimera.shell.zsh.enable (lib.mkBefore ''
57 if [ -z $WAYLAND_DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
Skyler Greyfb254d22024-03-03 13:03:22 +000058 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 +000059 fi
60 '');
61
Skyler Grey4e230892024-02-13 22:58:46 +000062 home.packages = [ pkgs.hyprpicker ];
Skyler Greya0da6b22024-02-11 22:53:41 +000063
Skyler Grey4e230892024-02-13 22:58:46 +000064 services.fusuma.settings.swipe = lib.mkIf config.chimera.touchpad.enable (
65 let
66 hyprctl = "${config.wayland.windowManager.hyprland.package}/bin/hyprctl";
67 jq = "${pkgs.jq}/bin/jq";
68 awk = "${pkgs.gawk}/bin/awk";
69 in
70 {
71 "3".up.command = "${hyprctl} dispatch fullscreen 0";
72 "3".down.command = "${hyprctl} dispatch fullscreen 0";
73 "4".down.command = lock;
74 "3".left.command = "${hyprctl} dispatch workspace $(${hyprctl} activeworkspace -j | ${jq} .id | ${awk} '{print $1+1}')";
75 "3".right.command = "${hyprctl} dispatch workspace $(${hyprctl} activeworkspace -j | ${jq} .id | ${awk} '{print $1-1}')";
76 }
77 );
Skyler Greya0da6b22024-02-11 22:53:41 +000078
Skyler Grey4e230892024-02-13 22:58:46 +000079 wayland.windowManager.hyprland = {
80 enable = true;
Skyler Greya0da6b22024-02-11 22:53:41 +000081
Skyler Grey4e230892024-02-13 22:58:46 +000082 xwayland.enable = true;
83 systemd.enable = true;
Skyler Greya0da6b22024-02-11 22:53:41 +000084
Skyler Grey4e230892024-02-13 22:58:46 +000085 settings =
86 let
87 mod = "SUPER";
88 terminal = "${pkgs.kitty}/bin/kitty";
Samuel Shuert004d0752024-03-02 11:57:09 -050089 menu = (if config.chimera.runner.anyrun.enable then "${inputs.anyrun.packages.${system}.anyrun}/bin/anyrun" else "");
Skyler Grey4e230892024-02-13 22:58:46 +000090 in
91 {
92 misc = {
93 disable_hyprland_logo = true;
94 disable_splash_rendering = true;
95 };
Skyler Greya0da6b22024-02-11 22:53:41 +000096
Skyler Greye3e18d32024-02-17 11:33:17 +000097 exec-once = [
Samuel Shuert659b5642024-02-23 20:47:43 +000098 "${pkgs.hyprpaper}/bin/hyprpaper"
99 "hyprctl setcursor ${config.chimera.theme.cursor.name} ${builtins.toString config.chimera.theme.cursor.size}"
Samuel Shuertdab963e2024-03-23 19:54:28 -0400100 "${pkgs.waybar}/bin/waybar"
Samuel Shuert659b5642024-02-23 20:47:43 +0000101 ];
Skyler Greya0da6b22024-02-11 22:53:41 +0000102
Skyler Grey4e230892024-02-13 22:58:46 +0000103 monitor = config.chimera.hyprland.monitors ++ [ ",preferred,auto,1" ];
Skyler Greya0da6b22024-02-11 22:53:41 +0000104
Skyler Greyabaa6072024-02-15 19:07:00 +0000105 general = {
106 border_size = 1;
107 "col.active_border" = "rgba(${config.chimera.theme.colors.Surface0.hex}FF)";
108 "col.inactive_border" = "rgba(${config.chimera.theme.colors.Surface0.hex}FF)";
109 };
110
Skyler Grey4e230892024-02-13 22:58:46 +0000111 decoration = {
112 rounding = 7;
Skyler Greyabaa6072024-02-15 19:07:00 +0000113 drop_shadow = false;
Skyler Grey4e230892024-02-13 22:58:46 +0000114 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000115
Skyler Grey4e230892024-02-13 22:58:46 +0000116 input = {
Skyler Grey71b81982024-02-15 18:06:36 +0000117 kb_layout = config.chimera.input.keyboard.layout;
Skyler Greyec50d242024-02-15 23:09:46 +0000118 kb_variant =
119 lib.mkIf (config.chimera.input.keyboard.variant != null)
120 config.chimera.input.keyboard.variant;
Skyler Grey5e344982024-02-15 18:59:45 +0000121 natural_scroll = config.chimera.input.mouse.scrolling.natural;
122
123 numlock_by_default = true;
Skyler Greya0da6b22024-02-11 22:53:41 +0000124
Skyler Grey4e230892024-02-13 22:58:46 +0000125 touchpad = {
Skyler Grey5e344982024-02-15 18:59:45 +0000126 natural_scroll = config.chimera.input.touchpad.scrolling.natural;
Skyler Grey4e230892024-02-13 22:58:46 +0000127 };
128 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000129
Skyler Grey4e230892024-02-13 22:58:46 +0000130 xwayland = {
131 force_zero_scaling = true;
132 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000133
Skyler Grey4e230892024-02-13 22:58:46 +0000134 dwindle = {
135 pseudotile = true;
136 smart_split = true;
137 };
138
139 master = {
140 allow_small_split = true;
141 new_is_master = true;
142 };
143
144 windowrulev2 = [ "opacity 1.0 0.85,title:(.*)" ];
145
146 bind =
147 [
148 "${mod}, Q, killactive"
149 "${mod}, SPACE, togglefloating"
150 "${mod}, RETURN, exec, ${terminal}"
151 "${mod}, down, movefocus, d"
152 "${mod}, up, movefocus, u"
153 "${mod}, right, movefocus, r"
154 "${mod}, left, movefocus, l"
155 "${mod}, L, exec, ${lock}"
Skyler Greya0da6b22024-02-11 22:53:41 +0000156 ]
Samuel Shuert004d0752024-03-02 11:57:09 -0500157 ++ (if config.chimera.runner.enable then [ "${mod}, D, exec, ${menu}" ] else [])
Skyler Grey4e230892024-02-13 22:58:46 +0000158 ++ (builtins.concatLists (
159 builtins.genList
160 (
161 x:
162 let
163 ws =
164 let
165 c = (x + 1) / 10;
166 in
167 builtins.toString (x + 1 - (c * 10));
168 in
169 [
170 "${mod}, ${ws}, workspace, ${toString (x + 1)}"
171 "${mod} SHIFT, ${ws}, movetoworkspace, ${toString (x + 1)}"
172 ]
173 )
174 10
175 ));
Skyler Greya0da6b22024-02-11 22:53:41 +0000176
Skyler Grey4e230892024-02-13 22:58:46 +0000177 bindm = [
178 "${mod}, mouse:272, movewindow"
179 "${mod}, mouse:273, resizewindow"
180 ];
PineaFan66e46742024-04-20 20:59:22 +0100181
182 env = lib.mkIf config.chimera.nvidia.enable [
183 "LIBVA_DRIVER_NAME,nvidia"
184 "XDG_SESSION_TYPE,wayland"
185 "GBM_BACKEND,nvidia-drm"
186 "__GLX_VENDOR_LIBRARY_NAME,nvidia"
187 "WLR_NO_HARDWARE_CURSORS,1"
188 ]
Skyler Grey4e230892024-02-13 22:58:46 +0000189 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000190 };
191 };
Skyler Grey4e230892024-02-13 22:58:46 +0000192}