Sway nvidia nouveau mesa

I want to switch to Sway
is it possible to implement proprietary drivers or will I have to use nouveau with mesa
Help me change the configuration correctly so that one of the options works correctly. Thanks
GeForce GTX 1050 Ti
edited: but I don’t really want to use --unsupported-gpu

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    nixpkgs-24.url = "github:NixOS/nixpkgs?ref=nixos-24.05";
    alejandra.url = "github:kamadorueda/alejandra/3.1.0";
    prismlauncher.url = "github:PrismLauncher/PrismLauncher";
    nix-colors.url = "github:misterio77/nix-colors";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    spicetify-nix = {
      url = "github:gerg-l/spicetify-nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = {
    self,
    nixpkgs,
    nixpkgs-24,
    home-manager,
    ...
  } @ inputs: let
    user = "q";
    host = "NixOS";
    system = "x86_64-linux";
    pkgs = import nixpkgs {
      config.allowUnfree = true;
    };
    _24-05 = import nixpkgs-24 {
      config.allowUnfree = true;
    };
  in {
    nixosConfigurations.${host} = nixpkgs.lib.nixosSystem {
      modules = [
        ({
          config,
          pkgs,
          lib,
          ...
        }: {
          xdg.portal = {
            enable = true;
            xdgOpenUsePortal = true;
            wlr.enable = true;
            config = {
              common.default = ["*"];
            };
            extraPortals = with pkgs; [
              xdg-desktop-portal
              xdg-desktop-portal-gtk
              xdg-desktop-portal-wlr
            ];
          };

          boot = {
            consoleLogLevel = 3;
            tmp.cleanOnBoot = true;
            plymouth.enable = true;
            loader = {
              timeout = 2;
              systemd-boot.enable = true;
              efi.canTouchEfiVariables = true;
            };
            extraModprobeConfig = ''
              options nvidia-drm modeset=1
            '';
            kernelParams = [
              "nvidia.NVreg_CheckPCIConfigSpace=0"
              "nvidia.NVreg_EnablePCIeGen3=1"
              "nvidia.NVreg_UsePageAttributeTable=1"
              "nvidia.NVreg_PreserveVideoMemoryAllocations=1"
              "nvidia_drm.modeset=1"
            ];
            kernelModules = [
              "nvidia"
              "nvidia_modeset"
              "nvidia_uvm"
              "nvidia_drm"
            ];
            #blacklistedKernelModules = ["nouveau"];
            kernelPackages = pkgs.linuxPackages_zen;
          };

          hardware = {
            graphics = {
              enable = true;
              extraPackages = with pkgs; [
                glxinfo # Test utilities for OpenGL
                libdrm # Direct Rendering Manager library and headers
                libglvnd # The GL Vendor-Neutral Dispatch library
                libva # An implementation for VA-API (Video Acceleration API)
                libva-utils # A collection of utilities and examples for VA-API
                libvdpau # Library to use the Video Decode and Presentation API for Unix (VDPAU)
                libvdpau-va-gl # VDPAU driver with OpenGL/VAAPI backend
                mesa # Open source 3D graphics library
                mesa.drivers # Open source 3D graphics library drivers
                nvidia-vaapi-driver # A VA-API implementation using NVIDIA's NVDEC
                vaapiVdpau # VDPAU driver for the VA-API library
                vdpauinfo # Tool to query VDPAU abilities of the system
                vulkan-extension-layer # Layers providing Vulkan features when native support is unavailable
                vulkan-loader # LunarG Vulkan loader
                vulkan-tools # Khronos official Vulkan Tools and Utilities
                vulkan-tools-lunarg # LunarG Vulkan Tools and Utilities
                vulkan-validation-layers # Official Vulkan validation layers
              ];
            };

            nvidia = {
              modesetting.enable = true; # Enable kernel modesetting
              powerManagement.enable = true; # Enable NVIDIA power management
              open = true; # Do not use open source driver
              nvidiaSettings = true; # Enable nvidia-settings GUI tool
              package = config.boot.kernelPackages.nvidiaPackages.beta; # NVIDIA driver version
            };
            enableRedistributableFirmware = true; # Enable redistributable firmware for hardware devices
          };

          nixpkgs = {
            hostPlatform = "x86_64-linux";
            overlays = [
            ];
            config = {
              allowUnfree = true;
              allowBroken = true;
              cudaSupport = true;
              allowInsecure = false;
              packageOverrides = pkgs: {};
              permittedInsecurePackages = [
              ];
            };
          };

          services = {
            ollama = {
              enable = true;
              acceleration = "cuda";
            };

          nix = {
            settings = {
              experimental-features = ["nix-command" "flakes"];
              auto-optimise-store = true;
              allowed-users = ["${user}"];
              warn-dirty = true;
              substituters = ["https://nix-gaming.cachix.org"];
              trusted-public-keys = [
                "nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4="
              ];
            };
          };
          system.stateVersion = config.system.nixos.release;
        })
        home-manager.nixosModules.home-manager
        {
          home-manager = {
            extraSpecialArgs = {inherit _24-05;};
            useGlobalPkgs = true;
            useUserPackages = true;
            users.${user} = {
              stable,
              config,
              pkgs,
              lib,
              ...
            }: {
              imports = [
                inputs.spicetify-nix.homeManagerModules.default
              ];
              home = {
                username = "${user}";
                homeDirectory = "/home/${user}";
                stateVersion = "25.05";
                sessionVariables = {
                  MOZ_ENABLE_WAYLAND = "1";
                  NIXOS_OZONE_WL = "1";
                  __GL_GSYNC_ALLOWED = "0";
                  GDK_BACKEND = "wayland";
                  WLR_DRM_NO_ATOMIC = "1";
                  WLR_BACKEND = "auto";
                  WLR_RENDERER = "auto";
                  LIBVA_DRIVER_NAME = "nvidia";
                  GBM_BACKEND = "nvidia";
                  WLR_NO_HARDWARE_CURSORS = "1";
                  SDL_VIDEODRIVER = "wayland";
                  __GLX_VENDOR_LIBRARY_NAME = "nvidia";
                  __GLX_RENDERER = "nvidia";
                  TERMINAL = "kitty";
                  _JAVA_AWT_WM_NONEREPARENTING = "1";
                  DISABLE_QT5_COMPAT = "0";
                  QT_AUTO_SCREEN_SCALE_FACTOR = "1";
                  QT_QPA_PLATFORMTHEME = "qt5ct";
                  QT_STYLE_OVERRIDE = "kvantum";
                  WINEARCH = "win64";
                  WINEPREFIX = "$HOME/.wine";
                  XDG_SESSION_TYPE = "wayland";
                  XDG_SESSION_DESKTOP = "sway";
                  XDG_CURRENT_DESKTOP = "sway";
                  GTK_THEME = "Adwaita-dark";
                };

              qt = {
                enable = true;
              };

              wayland.windowManager.sway = {
                enable = true;
                xwayland = true;
                systemd.enable = true;
                wrapperFeatures.gtk = true;
                package = pkgs.sway;
                extraOptions = [
                ];
                config = rec {
                  modifier = "Mod4";
                  terminal = "kitty";
                  startup = [
                    {command = "firefox";}
                  ];
                  input = {
                    "type:keyboard" = {
                      xkb_layout = "us,ru";
                      xkb_options = "grp:alt_shift_toggle";
                    };
                  };
                };
              };
            };
          };
        }
        ./hardware-configuration.nix
      ];
    };
  };
}

Why? That’s what the flag is for.

I think it will work unstable, won’t it?

I don’t understand your response.

1 Like

I just use a translator, I’m saying that using --unsupported-gpu might be unstable.

Yeah, because sway doesn’t support proprietary nvidia drivers. Use the flag, if it doesn’t work for you, then let us know what the issue is.

1 Like

Last I checked, there were still issues with XWayland applications in SwayWM on NVIDIA proprietary, and you might experience issues with flickering or broken rendering since I don’t believe SwayWM has full support for explicit sync everywhere yet. Regardless, even if there were no known issues, I believe you would still need to pass the --unsupported-gpu flag, as the SwayWM developers are unwilling to consider proprietary closed-source graphics drivers “supported”, since it is difficult to debug issues with them. Unfortunately, NVIDIA support on Linux is in somewhat rough shape and will probably continue to be for a few more years. I would not recommend using SwayWM with the NVIDIA proprietary driver.

1 Like