From ecbabde0bd229525dabb0078b7727db1c28c176f Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sat, 15 Jun 2024 01:40:26 -0400 Subject: [PATCH] feat(hypr): update config with latest variables from hyprland --- modules/hyprland/default.nix | 72 ++++++++++++++++++++---------------- modules/hyprland/inputs.nix | 39 +++++++++++++------ modules/hyprland/style.nix | 2 +- modules/nvidia.nix | 6 ++- 4 files changed, 73 insertions(+), 46 deletions(-) diff --git a/modules/hyprland/default.nix b/modules/hyprland/default.nix index f8f2fb04..ce97f9cf 100644 --- a/modules/hyprland/default.nix +++ b/modules/hyprland/default.nix @@ -8,8 +8,15 @@ inherit (lib) concatStringsSep optionals; inherit (config.vars) mainUser; - cfg = config.home-manager.users.${mainUser}.wayland.windowManager.hyprland; isTouchscreen = config.hardware.sensor.iio.enable; + cfg = + config + .home-manager + .users + .${mainUser} + .wayland + .windowManager + .hyprland; in { # SYSTEM CONFIG imports = [ @@ -19,11 +26,6 @@ in { ./security.nix ]; - environment.sessionVariables = { - GTK_USE_PORTAL = "1"; - NIXOS_OZONE_WL = "1"; - }; - services = { dbus.enable = true; gvfs.enable = true; @@ -31,12 +33,14 @@ in { xserver.wacom.enable = isTouchscreen; }; - programs.hyprland = let - inherit (hyprland.packages.${pkgs.system}) xdg-desktop-portal-hyprland; - in { + programs.hyprland = { enable = true; package = cfg.finalPackage; - portalPackage = xdg-desktop-portal-hyprland; + portalPackage = + hyprland + .packages + .${pkgs.system} + .xdg-desktop-portal-hyprland; }; xdg.portal = { @@ -51,7 +55,10 @@ in { "hyprland" "gtk" ]; - "org.freedesktop.impl.portal.FileChooser" = ["kde"]; + + "org.freedesktop.impl.portal.FileChooser" = [ + "kde" + ]; }; }; @@ -66,27 +73,35 @@ in { wayland.windowManager.hyprland = { enable = true; - package = hyprland.packages.${pkgs.system}.default; + package = + hyprland + .packages + .${pkgs.system} + .default; systemd.variables = ["-all"]; settings = { - env = let - gset = pkgs.gsettings-desktop-schemas; + envd = let + mkGSchemas = pkg: "${pkg}/share/gsettings-schemas/${pkg.name}"; in [ + "GTK_USE_PORTAL, 1" + "NIXOS_OZONE_WL, 1" + "ELECTRON_OZONE_PLATFORM_HINT, auto" + "XDG_DATA_DIRS, ${concatStringsSep ":" [ - "${gset}/share/gsettings-schemas/${gset.name}" - "${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}" + (mkGSchemas pkgs.gsettings-desktop-schemas) + (mkGSchemas pkgs.gtk3) "$XDG_DATA_DIRS" ]}" ] ++ (optionals config.nvidia.enable [ "LIBVA_DRIVER_NAME, nvidia" + "NVD_BACKEND, direct" "XDG_SESSION_TYPE, wayland" "GBM_BACKEND, nvidia-drm" "__GLX_VENDOR_LIBRARY_NAME, nvidia" - "WLR_NO_HARDWARE_CURSORS, 1" ]); xwayland.force_zero_scaling = true; @@ -113,26 +128,20 @@ in { ]) ]; - gestures = { - workspace_swipe = true; - workspace_swipe_fingers = 3; - workspace_swipe_cancel_ratio = 0.15; - }; - "$mainMod" = "SUPER"; bind = [ # Defaults - "$mainMod, F, fullscreen" - "$mainMod, C, killactive, " - "$mainMod SHIFT, SPACE, togglefloating, " - "$mainMod, J, layoutmsg, togglesplit" + "$mainMod, F, fullscreen" + "$mainMod, C, killactive" + "$mainMod SHIFT, SPACE, togglefloating" + "$mainMod, J, layoutmsg, togglesplit" ## Move focus with arrow keys - "$mainMod, left, movefocus, l" + "$mainMod, left, movefocus, l" "$mainMod, right, movefocus, r" - "$mainMod, up, movefocus, u" - "$mainMod, down, movefocus, d" + "$mainMod, up, movefocus, u" + "$mainMod, down, movefocus, d" ## Move to specific workspaces "$mainMod, 1, workspace, 1" @@ -158,7 +167,7 @@ in { "$mainMod SHIFT, 9, movetoworkspace, 9" "$mainMod SHIFT, 0, movetoworkspace, 10" - ",XF86AudioMute, exec, pactl set-sink-mute @DEFAULT_SINK@ toggle" + ",XF86AudioMute, exec, pactl set-sink-mute @DEFAULT_SINK@ toggle" ",XF86AudioMicMute, exec, pactl set-source-mute @DEFAULT_SOURCE@ toggle" ]; @@ -176,6 +185,7 @@ in { misc = { disable_hyprland_logo = true; disable_splash_rendering = true; + initial_workspace_tracking = 2; # persistent (all children too) vfr = true; }; diff --git a/modules/hyprland/inputs.nix b/modules/hyprland/inputs.nix index d3fc965b..8c035eb9 100644 --- a/modules/hyprland/inputs.nix +++ b/modules/hyprland/inputs.nix @@ -1,9 +1,4 @@ -{ - lib, - osConfig, - ... -}: let - inherit (lib) optionals; +{osConfig, ...}: let inherit (osConfig.services.xserver) xkb; inherit (osConfig.vars) mainMonitor; @@ -11,7 +6,7 @@ "logitech-g502-x" "logitech-g502-hero-gaming-mouse" ]; - nagaConf = name: { + mkConf = name: { inherit name; sensitivity = 0; accel_profile = "flat"; @@ -19,29 +14,49 @@ in { wayland.windowManager.hyprland = { settings = { - device = map (d: (nagaConf d)) miceNames; + device = map (d: (mkConf d)) miceNames; + + cursor = { + no_hardware_cursors = osConfig.nvidia.enable; + hide_on_touch = true; + default_monitor = + if mainMonitor != null + then mainMonitor + else ""; + }; input = { + # Keyboard kb_layout = xkb.layout; kb_variant = xkb.variant; + numlock_by_default = true; + repeat_rate = 100; + + # Mouse follow_mouse = true; + # Touchpad touchpad = { natural_scroll = true; disable_while_typing = false; + drag_lock = true; + tap-and-drag = true; }; }; + gestures = { + workspace_swipe = true; + workspace_swipe_fingers = 3; + workspace_swipe_touch = true; + workspace_swipe_cancel_ratio = 0.15; + }; + bind = [ ",XF86AudioPlay, exec, playerctl play-pause" ",XF86AudioStop, exec, playerctl stop" ",XF86AudioNext, exec, playerctl next" ",XF86AudioPrev, exec, playerctl previous" ]; - - exec-once = - optionals (! isNull mainMonitor) - ["hyprctl dispatch focusmonitor ${mainMonitor}"]; }; }; } diff --git a/modules/hyprland/style.nix b/modules/hyprland/style.nix index 568a1a10..478c97a2 100644 --- a/modules/hyprland/style.nix +++ b/modules/hyprland/style.nix @@ -8,7 +8,7 @@ in { wayland.windowManager.hyprland = { settings = { - env = ["XCURSOR_SIZE, 24"]; + envd = ["XCURSOR_SIZE, 24"]; exec-once = [ "hyprctl setcursor Dracula-cursors 24" diff --git a/modules/nvidia.nix b/modules/nvidia.nix index 6dedeac5..15045643 100644 --- a/modules/nvidia.nix +++ b/modules/nvidia.nix @@ -60,7 +60,7 @@ in { finegrained = false; }; - open = cfg.enableWayland; + open = false; package = if !cfg.enableWayland @@ -87,6 +87,8 @@ in { vdpauinfo ]); - boot.kernelModules = optionals cfg.enableCUDA ["nvidia-uvm"]; + boot.kernelModules = + optionals cfg.enableCUDA ["nvidia-uvm"] + ++ ["nvidia" "nvidia-drm"]; }; }