nix-config/modules/desktops/hyprland.nix

289 lines
7.8 KiB
Nix

#
# Hyprland Configuration
# Enable with "hyprland.enable = true;"
#
{
config,
lib,
system,
pkgs,
unstable,
hyprland,
vars,
host,
split-monitor-workspaces,
...
}: let
hyprlandconf = ''
monitor = DP-1,1920x1080@75,auto,auto
monitor = DP-3,2560x1440@144,auto,auto
monitor = ,preferred,auto,auto
source = ~/.config/hypr/mocha.conf
exec-once = waybar
exec-once = dunst
exec-once = swww init && swww img ~/.wallpapers/robot.jpg
exec-once = signal-desktop --start-in-tray
exec-once = webcord --start-minimized
env = XCURSOR_SIZE,24
env = LIBVA_DRIVER_NAME,nvidia
env = XDG_SESSION_TYPE,wayland
env = GBM_BACKEND,nvidia-drm
env = __GLX_VENDOR_LIBRARY_NAME,nvidia
env = WLR_NO_HARDWARE_CURSORS,1
env = NIXOS_OZONE_WL,1 # for any ozone-based browser & electron apps to run on wayland
env = MOZ_ENABLE_WAYLAND,1 # for firefox to run on wayland
env = MOZ_WEBRENDER,1
plugin {
split-monitor-workspaces {
count = 9
}
}
input {
kb_layout = de
kb_variant =
kb_model =
kb_options =
kb_rules =
follow_mouse = 1
touchpad {
natural_scroll = no
}
sensitivity = 0 # -1.0 - 1.0, 0 means no modification.
}
general {
gaps_in = 5
gaps_out = 5
border_size = 2
col.active_border = $teal
col.inactive_border = $tealAlpha
layout = dwindle
}
misc {
disable_hyprland_logo = true
vrr = true
vfr = true
}
decoration {
screen_shader = ~/.config/hypr/shaders/nightlight.frag
rounding = 10
blur {
enabled = true
size = 3
passes = 1
}
drop_shadow = yes
shadow_range = 4
shadow_render_power = 3
col.shadow = rgba(1a1a1aee)
}
animations {
enabled = yes
bezier = myBezier, 0.05, 0.9, 0.1, 1.05
animation = windows, 1, 7, myBezier
animation = windowsOut, 1, 7, default, popin 80%
animation = border, 1, 10, default
animation = borderangle, 1, 8, default
animation = fade, 1, 7, default
animation = workspaces, 1, 6, default
}
dwindle {
pseudotile = yes # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
preserve_split = yes # you probably want this
}
master {
new_is_master = true
}
gestures {
workspace_swipe = off
}
$mainMod = SUPER
bind = $mainMod, RETURN, exec, alacritty
bind = $mainMod, SPACE, exec, rofi -i -show drun -modi drun -show-icons
bind = SUPER_SHIFT, C, killactive,
bind = SUPER_SHIFT, Q, exit,
bind = $mainMod, V, togglefloating,
bind = $mainMod, P, pseudo, # dwindle
bind = $mainMod, J, togglesplit, # dwindle
bind = $mainMod, O, split-changemonitorsilent,next
# Move focus with mainMod + arrow keys
bind = $mainMod, left, movefocus, l
bind = $mainMod, right, movefocus, r
bind = $mainMod, up, movefocus, u
bind = $mainMod, down, movefocus, d
# Switch workspaces with mainMod + [0-9]
bind = $mainMod, 1, split-workspace, 1
bind = $mainMod, 2, split-workspace, 2
bind = $mainMod, 3, split-workspace, 3
bind = $mainMod, 4, split-workspace, 4
bind = $mainMod, 5, split-workspace, 5
bind = $mainMod, 6, split-workspace, 6
bind = $mainMod, 7, split-workspace, 7
bind = $mainMod, 8, split-workspace, 8
bind = $mainMod, 9, split-workspace, 9
bind = $mainMod, 0, split-workspace, 10
# Move active window to a workspace with mainMod + SHIFT + [0-9]
bind = $mainMod SHIFT, 1, split-movetoworkspace, 1
bind = $mainMod SHIFT, 2, split-movetoworkspace, 2
bind = $mainMod SHIFT, 3, split-movetoworkspace, 3
bind = $mainMod SHIFT, 4, split-movetoworkspace, 4
bind = $mainMod SHIFT, 5, split-movetoworkspace, 5
bind = $mainMod SHIFT, 6, split-movetoworkspace, 6
bind = $mainMod SHIFT, 7, split-movetoworkspace, 7
bind = $mainMod SHIFT, 8, split-movetoworkspace, 8
bind = $mainMod SHIFT, 9, split-movetoworkspace, 9
bind = $mainMod SHIFT, 0, split-movetoworkspace, 10
# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow
bind = SUPERSHIFT, V, exec, cliphist list | rofi -dmenu | cliphist decode | wl-copy
bind = $mainMod, L, exec, librewolf
bind = $mainMod SHIFT, L, exec, librewolf --private-window
'';
in
with lib;
with host; {
options = {
hyprland = {
enable = mkOption {
type = types.bool;
default = false;
};
};
};
config = mkIf (config.hyprland.enable) {
environment = {
systemPackages = with pkgs;
[
grim # Grab Images
slurp # Region Selector
wl-clipboard # Clipboard
wlr-randr # Monitor Settings
dunst
cliphist
rofi-wayland
swww
]
++ (with unstable; [waybar]);
# sessionVariables = {
# "NIXOS_OZONE_WL" = "1"; # for any ozone-based browser & electron apps to run on wayland
# "MOZ_ENABLE_WAYLAND" = "1"; # for firefox to run on wayland
# "MOZ_WEBRENDER" = "1";
#
# # for hyprland with nvidia gpu, ref https://wiki.hyprland.org/Nvidia/
# "LIBVA_DRIVER_NAME" = "nvidia";
# "XDG_SESSION_TYPE" = "wayland";
# "GBM_BACKEND" = "nvidia-drm";
# "__GLX_VENDOR_LIBRARY_NAME" = "nvidia";
# "WLR_NO_HARDWARE_CURSORS" = "1";
# "WLR_EGL_NO_MODIFIRES" = "1";
# };
};
programs = {
hyprland = {
# Window Manager
enable = true;
xwayland.enable = true;
enableNvidiaPatches =
if hostName == "desktop"
then true
else false;
};
};
hardware = {
opengl = {
enable = true;
};
};
xdg.portal = {
enable = true;
extraPortals = with pkgs; [xdg-desktop-portal-gtk];
};
home-manager.users.${vars.user} = {
imports = [hyprland.homeManagerModules.default];
home.file.".config/hypr/" = {
source = ../../rsc/config/hypr;
recursive = true;
};
home.file.".config/waybar" = {
source = ../../rsc/config/waybar;
recursive = true;
};
home.file.".config/dunst" = {
source = ../../rsc/config/dunst;
recursive = true;
};
home.file.".config/rofi" = {
source = ../../rsc/config/rofi;
recursive = true;
};
home.file.".wallpapers" = {
source = ../../rsc/wallpaper;
recursive = true;
};
programs.waybar.package = pkgs.waybar.overrideAttrs (oa: {
mesonFlags = (oa.mesonFlags or []) ++ ["-Dexperimental=true"];
patches =
(oa.patches or [])
++ [
(pkgs.fetchpatch {
name = "fix waybar hyprctl";
url = "https://aur.archlinux.org/cgit/aur.git/plain/hyprctl.patch?h=waybar-hyprland-git";
sha256 = "sha256-pY3+9Dhi61Jo2cPnBdmn3NUTSA8bAbtgsk2ooj4y7aQ=";
})
];
});
wayland.windowManager.hyprland = {
enable = true;
systemdIntegration = true;
extraConfig = hyprlandconf;
plugins = [
split-monitor-workspaces.packages.${pkgs.system}.split-monitor-workspaces
];
};
};
nix.settings = {
substituters = ["https://hyprland.cachix.org"];
trusted-public-keys = ["hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="];
}; # Cache
};
}