{ config, options, lib, pkgs, ... }: let hyprlandConf = config.modules.desktop.hyprland; device = config.modules.device; defaultApps = config.modules.desktop.defaultApplications.apps; configDir = config.nixosConfig.configDir; screenshotarea = "hyprctl keyword animation 'fadeOut,0,0,default'; grimblast --notify copysave area; hyprctl keyword animation 'fadeOut,1,4,default'"; # binds $mod + [shift +] {1..10} to [move to] workspace {1..10} workspaces = builtins.concatLists (builtins.genList ( x: let ws = let c = (x + 1) / 10; in builtins.toString (x + 1 - (c * 10)); in [ "$mod, ${ws}, exec, /etc/nixos/bin/hyprland/workspace ${toString (x + 1)}" "$mod SHIFT, ${ws}, movetoworkspace, ${toString (x + 1)}" ] ) 10); decoration = { rounding = 7; blur = { enabled = true; size = 3; passes = 1; }; drop_shadow = true; shadow_ignore_window = true; shadow_offset = "0 2"; shadow_range = 20; shadow_render_power = 3; "col.shadow" = "rgba(00000055)"; }; animations = { enabled = true; animation = [ "border, 1, 2, default" "fade, 1, 4, default" "windows, 1, 3, default, popin 80%" "workspaces, 1, 2, default, slide" ]; }; keybinds = let monocle = "dwindle:no_gaps_when_only"; in [ # Compositor commands "$mod ALTL, Q, exec, pkill Hyprland" "$mod, Q, killactive" # Layout "$mod, F, fullscreen" "$mod, Space, togglefloating" "$mod, S, togglesplit" "$mod, P, pseudo" "$mod SHIFT, grave, movetoworkspace, special" "$mod, grave, togglespecialworkspace" # Group "$mod, G, togglegroup" "$mod, TAB, changegroupactive" #Focus windows "$mod, left, movefocus, l" "$mod, right, movefocus, r" "$mod, up, movefocus, u" "$mod, down, movefocus, d" #Focus monitor "$mod SHIFT, left, focusmonitor, l" "$mod SHIFT, right, focusmonitor, r" #Exec binds "$mod, D, exec, wofi --show drun" "$mod, Return, exec, ${defaultApps.terminal.cmd}" "$mod, W, exec, ${defaultApps.browser.cmd}" "$mod ALTL, B, exec, killall -SIGUSR2 waybar" ] ++ workspaces; mousebinds = let in [ "$mod, mouse:272, movewindow" "$mod, mouse:273, resizewindow" ]; in { options.modules.desktop.hyprland = { enable = lib.mkOption { type = lib.types.bool; default = false; }; xwayland = lib.mkOption { type = lib.types.bool; default = true; }; }; config = lib.mkIf (hyprlandConf.enable) (lib.mkMerge [ { environment.variables.WLR_NO_HARDWARE_CURSORS = "1"; home.packages = [ pkgs.killall pkgs.wl-clipboard pkgs.wdisplays pkgs.swaylock pkgs.swayidle pkgs.wofi pkgs.jq pkgs.swww ]; modules.device.displayProtocol = "wayland"; xdg.portal = { enable = true; wlr = { enable = true; settings = { screencast = { chooser_type = "simple"; chooser_cmd = "${pkgs.slurp}/bin/slurp -f %o -or"; }; }; }; extraPortals = [pkgs.xdg-desktop-portal-gtk]; config.common.default = ["wlr" "gtk"]; }; home.manager.wayland.windowManager.hyprland = { enable = true; xwayland.enable = hyprlandConf.xwayland; settings = { "$mod" = "SUPER"; input = { kb_layout = "us"; follow_mouse = 1; sensitivity = 0; }; dwindle = { pseudotile = true; preserve_split = true; }; general = { gaps_in = 5; gaps_out = 10; border_size = 2; "col.active_border" = "rgba(33ccffee) rgba(00ff99ee) 45deg"; "col.inactive_border" = "rgba(595959aa)"; layout = "dwindle"; }; exec-once = [ "swww init" "swww img ${configDir}/hypr/wallpaper.png" ]; env = [ "XDG_CURRENT_DESKTOP,Hyprland" "XDG_SESSION_TYPE,wayland" "XDG_SESSION_DESKTOP,Hyprland" "GDK_BACKEND,wayland" "QT_QPA_PLATFORM,wayland" "QT_WAYLAND_DISABLE_WINDOWDECORATION,1" "QT_AUTO_SCREEN_SCALE_FACTOR,1" "SDL_VIDEODRIVER,wayland" ]; decoration = decoration; animations = animations; bind = keybinds; bindm = mousebinds; }; }; programs.waybar = { enable = true; }; home.manager.xdg.configFile."hypr/hyprpaper.conf".source = "${configDir}/hypr/hyprpaper.conf"; #Symlink waybar system.userActivationScripts.linkwaybar.text = '' if [[ ! -h "$HOME/.config/waybar" ]]; then ln -s "${configDir}/waybar" "$HOME/.config/waybar" fi ''; security.pam.services.swaylock = {}; } (lib.mkIf (device.gpu == "nvidia") { home.manager.wayland.windowManager.hyprland.settings.env = [ "GBM_BACKEND,nvidia-drm" "__GLX_VENDOR_LIBRARY_NAME,nvidia" "LIBVA_DRIVER_NAME,nvidia" "__GL_GSYNC_ALLOWED" "__GL_VRR_ALLOWED" "WLR_DRM_NO_ATOMIC,1" ]; }) (lib.mkIf (config.modules.desktop.greetd.enable) { services.greetd.settings = { default_session.command = '' ${pkgs.greetd.tuigreet}/bin/tuigreet \ --time \ --asterisks \ --user-menu \ --cmd Hyprland ''; }; environment.etc."greetd/environments".text = '' Hyprland ''; }) ]); }