diff --git a/home/linux/gui/base/desktop/default.nix b/home/linux/gui/base/desktop/default.nix index d58dafe7..99d0ce40 100644 --- a/home/linux/gui/base/desktop/default.nix +++ b/home/linux/gui/base/desktop/default.nix @@ -6,8 +6,25 @@ { imports = [ ./anyrun.nix + ./nvidia.nix ]; + # wayland related + home.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"; + # enable native Wayland support for most Electron apps + "ELECTRON_OZONE_PLATFORM_HINT" = "auto"; + # misc + "_JAVA_AWT_WM_NONREPARENTING" = "1"; + "QT_WAYLAND_DISABLE_WINDOWDECORATION" = "1"; + "QT_QPA_PLATFORM" = "wayland"; + "SDL_VIDEODRIVER" = "wayland"; + "GDK_BACKEND" = "wayland"; + "XDG_SESSION_TYPE" = "wayland"; + }; + home.packages = with pkgs; [ swaybg # the wallpaper wl-clipboard # copying and pasting diff --git a/home/linux/gui/base/desktop/nvidia.nix b/home/linux/gui/base/desktop/nvidia.nix new file mode 100644 index 00000000..c71408a4 --- /dev/null +++ b/home/linux/gui/base/desktop/nvidia.nix @@ -0,0 +1,26 @@ +{ + config, + lib, + ... +}: +with lib; +let + cfg = config.modules.desktop.nvidia; +in +{ + options.modules.desktop.nvidia = { + enable = mkEnableOption "whether nvidia GPU is used"; + }; + + config = mkIf (cfg.enable && cfg.enable) { + home.sessionVariables = { + # for hyprland with nvidia gpu" = " ref https://wiki.hyprland.org/Nvidia/ + "LIBVA_DRIVER_NAME" = "nvidia"; + "__GLX_VENDOR_LIBRARY_NAME" = "nvidia"; + # VA-API hardware video acceleration + "NVD_BACKEND" = "direct"; + + "GBM_BACKEND" = "nvidia-drm"; + }; + }; +} diff --git a/home/linux/gui/hyprland/default.nix b/home/linux/gui/hyprland/default.nix index 3aa7e63c..3ed74b7a 100644 --- a/home/linux/gui/hyprland/default.nix +++ b/home/linux/gui/hyprland/default.nix @@ -9,10 +9,6 @@ let cfg = config.modules.desktop.hyprland; in { - imports = [ - ./options - ]; - options.modules.desktop.hyprland = { enable = mkEnableOption "hyprland compositor"; settings = lib.mkOption { @@ -38,14 +34,11 @@ in }; }; - config = mkIf cfg.enable ( - mkMerge ( - [ - { - wayland.windowManager.hyprland.settings = cfg.settings; - } - ] - ++ (import ./values args) - ) - ); + config = mkIf cfg.enable (mkMerge ([ + { + wayland.windowManager.hyprland.settings = cfg.settings; + } + (import ./hyprland.nix args) + (import ./xdg.nix args) + ])); } diff --git a/home/linux/gui/hyprland/values/hyprland.nix b/home/linux/gui/hyprland/hyprland.nix similarity index 77% rename from home/linux/gui/hyprland/values/hyprland.nix rename to home/linux/gui/hyprland/hyprland.nix index 895a56d0..b83eda47 100644 --- a/home/linux/gui/hyprland/values/hyprland.nix +++ b/home/linux/gui/hyprland/hyprland.nix @@ -36,16 +36,7 @@ in "${configPath}/windowrules.conf" ]; env = [ - "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" - # misc - "_JAVA_AWT_WM_NONREPARENTING,1" - "QT_WAYLAND_DISABLE_WINDOWDECORATION,1" - "QT_QPA_PLATFORM,wayland" - "SDL_VIDEODRIVER,wayland" - "GDK_BACKEND,wayland" - "XDG_SESSION_TYPE,wayland" + ]; }; # gammastep/wallpaper-switcher need this to be enabled. diff --git a/home/linux/gui/hyprland/options/default.nix b/home/linux/gui/hyprland/options/default.nix deleted file mode 100644 index 049dda93..00000000 --- a/home/linux/gui/hyprland/options/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ mylib, ... }: -{ - imports = mylib.scanPaths ./.; -} diff --git a/home/linux/gui/hyprland/options/nvidia.nix b/home/linux/gui/hyprland/options/nvidia.nix deleted file mode 100644 index 48e6789c..00000000 --- a/home/linux/gui/hyprland/options/nvidia.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ - config, - lib, - ... -}: -with lib; -let - cfg = config.modules.desktop.hyprland; -in -{ - options.modules.desktop.hyprland = { - nvidia = mkEnableOption "whether nvidia GPU is used"; - }; - - config = mkIf (cfg.enable && cfg.nvidia) { - wayland.windowManager.hyprland.settings.env = [ - # for hyprland with nvidia gpu, ref https://wiki.hyprland.org/Nvidia/ - "LIBVA_DRIVER_NAME,nvidia" - "__GLX_VENDOR_LIBRARY_NAME,nvidia" - # enable native Wayland support for most Electron apps - "ELECTRON_OZONE_PLATFORM_HINT,auto" - # VA-API hardware video acceleration - "NVD_BACKEND,direct" - - "GBM_BACKEND,nvidia-drm" - ]; - }; -} diff --git a/home/linux/gui/hyprland/values/default.nix b/home/linux/gui/hyprland/values/default.nix deleted file mode 100644 index 6efaa0c3..00000000 --- a/home/linux/gui/hyprland/values/default.nix +++ /dev/null @@ -1 +0,0 @@ -{ mylib, ... }@args: map (path: import path args) (mylib.scanPaths ./.) diff --git a/home/linux/gui/hyprland/values/xdg.nix b/home/linux/gui/hyprland/xdg.nix similarity index 100% rename from home/linux/gui/hyprland/values/xdg.nix rename to home/linux/gui/hyprland/xdg.nix diff --git a/home/linux/gui/niri/default.nix b/home/linux/gui/niri/default.nix index 53a6ad65..b88af749 100644 --- a/home/linux/gui/niri/default.nix +++ b/home/linux/gui/niri/default.nix @@ -209,15 +209,6 @@ in (leaf "center-focused-column" "never") ]) - # You can override environment variables for processes spawned by niri. - (plain "environment" [ - # Set a variable like this: - (leaf "QT_QPA_PLATFORM" "wayland") - - # Remove a variable by using null as the value: - # (leaf "DISPLAY" null) - ]) - (plain "cursor" [ # Change the theme and size of the cursor as well as set the # `XCURSOR_THEME` and `XCURSOR_SIZE` env variables. diff --git a/hosts/12kingdoms-shoukei/home.nix b/hosts/12kingdoms-shoukei/home.nix index 052da8bf..21f8ebde 100644 --- a/hosts/12kingdoms-shoukei/home.nix +++ b/hosts/12kingdoms-shoukei/home.nix @@ -6,12 +6,10 @@ in programs.ssh.matchBlocks."github.com".identityFile = "${config.home.homeDirectory}/.ssh/${hostName}"; - modules.desktop.hyprland = { - nvidia = false; - settings.source = [ - "${config.home.homeDirectory}/nix-config/hosts/12kingdoms-shoukei/hypr-hardware.conf" - ]; - }; + modules.desktop.nvidia.enable = false; + modules.desktop.hyprland.settings.source = [ + "${config.home.homeDirectory}/nix-config/hosts/12kingdoms-shoukei/hypr-hardware.conf" + ]; modules.desktop.niri = { settings = diff --git a/hosts/idols-ai/home.nix b/hosts/idols-ai/home.nix index 3f11c89e..0fd7e31c 100644 --- a/hosts/idols-ai/home.nix +++ b/hosts/idols-ai/home.nix @@ -2,12 +2,11 @@ { programs.ssh.matchBlocks."github.com".identityFile = "${config.home.homeDirectory}/.ssh/idols-ai"; - modules.desktop.hyprland = { - nvidia = true; - settings.source = [ - "${config.home.homeDirectory}/nix-config/hosts/idols-ai/hypr-hardware.conf" - ]; - }; + modules.desktop.nvidia.enable = true; + + modules.desktop.hyprland.settings.source = [ + "${config.home.homeDirectory}/nix-config/hosts/idols-ai/hypr-hardware.conf" + ]; modules.desktop.niri = { settings =