Application only works using discrete gpu (with sudo access)

New to NixOS here, I’ve installed the warp-terminal package by adding pkgs.warp-terminal to my configuration.nix file. I have NVIDIA drivers installed and working, alongside the regular intel integrated GPU drivers (set up with sync).

Here’s where it gets interesting - if i run warp-terminal as a command, it fails with the following output:

/nix/store/4xqjlfi0ffk57qb732fvbr5a0y1748pl-warp-terminal-0.2024.04.16.08.02.stable_00/opt/warpdotdev/warp-terminal/warp: /nix/store/nwsbnbj4xgfq2x45df9xg2b77953h2zz-curl-8.7.1/lib/libcurl.so.4: no version information available (required by /nix/store/4xqjlfi0ffk57qb732fvbr5a0y1748pl-warp-terminal-0.2024.04.16.08.02.stable_00/opt/warpdotdev/warp-terminal/warp)
16:03:14 [INFO] Spawning terminal server process...
16:03:14 [INFO] Running app with windowing system: Wayland
thread 'main' panicked at /home/runner/work/warp-internal/warp-internal/ui/src/windowing/winit/app.rs:164:14:
should be able to create event loop: Os(OsError { line: 80, file: "/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.15/src/platform_impl/linux/wayland/event_loop/mod.rs", error: WaylandError(Connection(NoWaylandLib)) })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
16:03:14 [INFO] Received empty message; assuming the connection has been closed.

However, if I run with sudo access sudo warp-terminal, the program runs fine with the following terminal output:

/nix/store/4xqjlfi0ffk57qb732fvbr5a0y1748pl-warp-terminal-0.2024.04.16.08.02.stable_00/opt/warpdotdev/warp-terminal/warp: /nix/store/nwsbnbj4xgfq2x45df9xg2b77953h2zz-curl-8.7.1/lib/libcurl.so.4: no version information available (required by /nix/store/4xqjlfi0ffk57qb732fvbr5a0y1748pl-warp-terminal-0.2024.04.16.08.02.stable_00/opt/warpdotdev/warp-terminal/warp)
16:07:10 [INFO] Failed to forward startup args: unknown dbus error
16:07:10 [INFO] Spawning terminal server process...
16:07:10 [INFO] Running app with windowing system: X11
/nix/store/4xqjlfi0ffk57qb732fvbr5a0y1748pl-warp-terminal-0.2024.04.16.08.02.stable_00/opt/warpdotdev/warp-terminal/warp: /nix/store/nwsbnbj4xgfq2x45df9xg2b77953h2zz-curl-8.7.1/lib/libcurl.so.4: no version information available (required by /nix/store/4xqjlfi0ffk57qb732fvbr5a0y1748pl-warp-terminal-0.2024.04.16.08.02.stable_00/opt/warpdotdev/warp-terminal/warp)
16:07:10 [INFO] Running terminal server...
16:07:10 [WARN] Unable to fetch system color scheme: InputOutput(
    Os {
        code: 2,
        kind: NotFound,
        message: "No such file or directory",
    },
)
16:07:10 [ERROR] Failed to acquire default Secret Service collection: unknown error
16:07:10 [INFO] Failed to read User from secure storage NotFound
16:07:10 [INFO] Initializing crash reporting Some("linux_stable_release") with tag "v0.2024.04.16.08.02.stable_00"...
16:07:10 [INFO] Starting warp with channel state ChannelState { channel: Stable, app_id: AppId { qualifier: "dev", organization: "warp", application_name: "Warp" }, additional_features: {}, firebase_api_key: "AIzaSyBdy3O3S9hrdayLJxJ7mriBR4qgUaUygAs", server_root_url: "https://app.warp.dev", ws_server_url: "wss://rtc.app.warp.dev/graphql", session_sharing_server_url: Some("wss://session-sharing-server-o3mgmiurkq-uk.a.run.app"), segment_write_key: "sTT9ZajzIaQ0phzLFOnqZ6VOqplJTlaJ", segment_root_url: "https://api.segment.io", releases_base_url: "https://releases.warp.dev", sentry_url: "https://0195a81da0714f55a93ee4624825f9ec@o540343.ingest.sentry.io/5658526", logfile_name: "warp.log", show_autoupdate_menu_items: true, skip_login: false } and version Some("v0.2024.04.16.08.02.stable_00")
16:07:10 [INFO] Performance metrics collector started
16:07:10 [INFO] Start to flush telemetry events to Segment
16:07:10 [INFO] Initializing app services
16:07:10 [ERROR] Failed to initialize org.freedesktop.Application D-Bus service: I/O error: No such file or directory (os error 2): No such file or directory (os error 2)
16:07:11 [INFO] Flushed telemetry events.
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
DRM kernel driver 'nvidia-drm' in use. NVK requires nouveau.
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
16:07:11 [WARN] Detected skylake derivative running on mesa i915. Clears to srgb textures will use manual shader clears.
16:07:11 [WARN] SQLite error 283 (A WAL mode database file was recovered): recovered 3 frames from WAL file /root/.local/state/warp-terminal/warp.sqlite-wal
16:07:11 [INFO] Connecting to SQLite database
16:07:11 [INFO] fetching team tester status
16:07:11 [INFO] Checking for update on channel stable_release. Update id is Fv415z3
16:07:11 [INFO] Fetching channel versions (without changelogs) from Warp server
16:07:11 [INFO] dispatching global action for root_view:open_from_restored
16:07:11 [INFO] dispatching global action for root_view:open_new
16:07:11 [WARN] Encountered error while watching for desktop settings change events: I/O error: No such file or directory (os error 2)
16:07:11 [WARN] error getting team tester status: Failed to get access token for GraphQL request. Falling back to in-memory state.
16:07:11 [INFO] Guessed window scale factor: 1
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
16:07:11 [INFO] Enabled wgpu backends: Backends(VULKAN | GL | METAL | DX12 | DX11 | BROWSER_WEBGPU)
16:07:11 [INFO] Available wgpu adapters (in priority order):
DRM kernel driver 'nvidia-drm' in use. NVK requires nouveau.
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
16:07:11 [WARN] Detected skylake derivative running on mesa i915. Clears to srgb textures will use manual shader clears.
16:07:11 [INFO] DiscreteGpu: NVIDIA RTX A2000 Laptop GPU
	Backend: Vulkan
	Driver: NVIDIA (550.78)
	Can present: true
	Supported texture format: Some(Bgra8UnormSrgb)
16:07:11 [INFO] IntegratedGpu: Intel(R) UHD Graphics (TGL GT1)
	Backend: Vulkan
	Driver: Intel open-source Mesa driver (Mesa 24.0.5)
	Can present: true
	Supported texture format: Some(Bgra8UnormSrgb)
16:07:11 [INFO] IntegratedGpu: Mesa Intel(R) UHD Graphics (TGL GT1)
	Backend: Gl
	Driver: Unknown
	Can present: true
	Supported texture format: Some(Rgba8UnormSrgb)
16:07:11 [INFO] Cpu: llvmpipe (LLVM 17.0.6, 256 bits)
	Backend: Vulkan
	Driver: llvmpipe (Mesa 24.0.5 (LLVM 17.0.6))
	Can present: true
	Supported texture format: Some(Bgra8UnormSrgb)
16:07:11 [INFO] Verifying adapter "NVIDIA RTX A2000 Laptop GPU" is valid...
16:07:11 [INFO] Using DiscreteGpu (NVIDIA RTX A2000 Laptop GPU) for rendering new window.
16:07:11 [WARN] redraw_frame was called 2 times before the frame was drawn
16:07:11 [INFO] window resized
16:07:11 [INFO] dispatching global action for workspace:save_app

I have to sign in again through the browser every time as well. Not sure where to begin troubleshooting. I’ve added my configuration.nix file below. What I do know is that this error has only appeared after starting to use flakes for my configuration (alongside home-manager)

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, inputs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      inputs.home-manager.nixosModules.default
    ];

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  networking.hostName = "nixos"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "Europe/Amsterdam";

  # Select internationalisation properties.
  i18n.defaultLocale = "en_US.UTF-8";

  i18n.extraLocaleSettings = {
    LC_ADDRESS = "nl_NL.UTF-8";
    LC_IDENTIFICATION = "nl_NL.UTF-8";
    LC_MEASUREMENT = "nl_NL.UTF-8";
    LC_MONETARY = "nl_NL.UTF-8";
    LC_NAME = "nl_NL.UTF-8";
    LC_NUMERIC = "nl_NL.UTF-8";
    LC_PAPER = "nl_NL.UTF-8";
    LC_TELEPHONE = "nl_NL.UTF-8";
    LC_TIME = "nl_NL.UTF-8";
  };

  # Enable the X11 windowing system.
  services.xserver.enable = true;

  # Enable the GNOME Desktop Environment.
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;
  services.xserver.desktopManager.gnome.extraGSettingsOverrides = ''
    [org.gnome.desktop.peripherals.touchpad]
    click-method='default'
  '';

  # Configure keymap in X11
  services.xserver.xkb = {
    layout = "us";
    variant = "";
  };

  # Enable CUPS to print documents.
  services.printing.enable = true;

  # Enable sound with pipewire.
  sound.enable = true;
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    #media-session.enable = true;
  };

  # Enable touchpad support (enabled default in most desktopManager).
  services.libinput.enable = true;

  # enable intel gpu
  boot.initrd.kernelModules = [ "i915" ];

  # Needs to be blacklisted for touchpad to work
  # https://discourse.nixos.org/t/touchpad-not-recognizable/19198/13
  # https://bbs.archlinux.org/viewtopic.php?id=266406
  boot.blacklistedKernelModules = [ "elan_i2c" ]; 

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.maverick = {
    isNormalUser = true;
    description = "Harsh Nagouda";
    extraGroups = [ "networkmanager" "wheel" ];
    packages = with pkgs; [
    #  thunderbird
    ];
  };

  home-manager = {
    extraSpecialArgs = { inherit inputs; };
    users = {
      "maverick" = import ./home.nix;
    };
    useGlobalPkgs = true;
  };

  #* ====================================================================
  #* === INSTALL PROGRAMS ==============================================
  #* ====================================================================

  # Install programs.
  programs.firefox.enable = true;

  # ============================================================

  #* ====================================================================
  #* === INSTALL PACKAGES ==============================================
  #* ====================================================================
  # Allow unfree packages
  nixpkgs.config = {
    allowUnfree = true;
  };

  # firmware update manager
  services.fwupd.enable = true;

  # system packages
  environment.systemPackages = with pkgs; [
    vim
    lf
    pkgs.fprintd
    pkgs.rustc
    pkgs.rustup
    pkgs.warp-terminal
    lshw
  ];

  #* ============================================================

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "23.11"; # Did you read the comment?
  

  #* ====================================================================
  #* === ENABLE PROGRAMS ===============================================
  #* ====================================================================

  # Enable Flakes
  nix.settings.experimental-features = [
	"nix-command"
	"flakes"
  ];

  # Enable fingerprint
  services.fprintd.enable = true;

  services.fprintd.tod.enable = true;

  # services.fprintd.tod.driver = pkgs.libfprint-2-tod1-vfs0090; # (If the vfs0090 Driver does not work, use the following driver)

  services.fprintd.tod.driver = pkgs.libfprint-2-tod1-goodix; # (On my device it only worked with this driver)
  
  # ============================================================

  #* ====================================================================
  #* === NVIDIA DRIVERS ===============================================
  #* ====================================================================

  # Enable OpenGL
  hardware.opengl = {
    enable = true;
    driSupport = true;
    driSupport32Bit = true;
  };

  # Load nvidia driver for Xorg and Wayland
  services.xserver.videoDrivers = ["nvidia"];

  hardware.nvidia = {

    # Modesetting is required.
    modesetting.enable = true;

    # Nvidia power management. Experimental, and can cause sleep/suspend to fail.
    # Enable this if you have graphical corruption issues or application crashes after waking
    # up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead 
    # of just the bare essentials.
    powerManagement.enable = false;

    # Fine-grained power management. Turns off GPU when not in use.
    # Experimental and only works on modern Nvidia GPUs (Turing or newer).
    powerManagement.finegrained = false;

    # Use the NVidia open source kernel module (not to be confused with the
    # independent third-party "nouveau" open source driver).
    # Support is limited to the Turing and later architectures. Full list of 
    # supported GPUs is at: 
    # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus 
    # Only available from driver 515.43.04+
    # Currently alpha-quality/buggy, so false is currently the recommended setting.
    open = false;

    # Enable the Nvidia settings menu,
	# accessible via `nvidia-settings`.
    nvidiaSettings = true;

    # Optionally, you may need to select the appropriate driver version for your specific GPU.
    package = config.boot.kernelPackages.nvidiaPackages.production;
  };

  hardware.nvidia.prime = {
		sync.enable = true; 
    
		# Make sure to use the correct Bus ID values for your system!
		intelBusId = "PCI:01:02:0";
		nvidiaBusId = "PCI:01:00:0";
	};
}

Not sure if relevant, but adding my home.nix file as well:

{ config, pkgs, ... }:

{
  home.username = "maverick";
  home.homeDirectory = "/home/maverick";

  # This value determines the Home Manager release that your configuration is
  # compatible with. This helps avoid breakage when a new Home Manager release
  # introduces backwards incompatible changes.
  #
  # You should not change this value, even if you update Home Manager. If you do
  # want to update the value, then make sure to first check the Home Manager
  # release notes.
  home.stateVersion = "23.11"; # Please read the comment before changing.

  # The home.packages option allows you to install Nix packages into your
  # environment.
  home.packages = [
    pkgs.google-chrome
    pkgs.virtualenv
    pkgs.conda
    pkgs.bitwarden
    pkgs.vscode
    pkgs.zoxide
    pkgs.tree
  ];


  home.file = {
  };

  home.sessionVariables = {
    # EDITOR = "emacs";
  };

  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;
}

I’ve also added my configuration structure tree below:

├── flake.lock
├── flake.nix
├── hosts
│   └── default
│       ├── configuration.nix
│       ├── hardware-configuration.nix
│       └── home.nix

Welcome to NixOS :wave:

My guess is that the program is not compiled with Wayland support by default, but when you run it with sudo it runs it inside XWayland somehow.

You should try enabling it and see if it works without sudo:

# system packages
  environment.systemPackages = with pkgs; [
    vim
    lf
    pkgs.fprintd
    pkgs.rustc
    pkgs.rustup
-   pkgs.warp-terminal
+   (pkgs.warp-terminal.override { waylandSupport = true; })
    lshw
  ];

Edit: If you’re using NixOS 23.11 then this probably won’t work as Wayland support was only recently added for the unstable branch. In this case, you need to open an issue on GitHub and ping the maintainer to backport the change (if possible).

Else, you can add Wayland support, yourself, using overlays:

# untested, but should work
  nixpkgs.overlays = [
    (final: prev: {
      warp-terminal = prev.warp-terminal.overrideAttrs (old: {
        nativeBuildInputs = old.nativeBuildInputs ++ pkgs.makeWrapper;
        buildInputs = old.buildInputs ++ pkgs.wayland;
        installPhase = old.installPhase ++ ''
          wrapProgram $out/bin/warp-terminal --set WARP_ENABLE_WAYLAND 1
        '' ++ ''
          runHook postInstall
        '';
      });
    })
  ];

  environment.systemPackages = with pkgs; [
    warp-terminal
  ];

Also, as a tip, when you use with pkgs; before the list, you don’t need to prefix the packages with pkgs anymore.

# system packages
  environment.systemPackages = with pkgs; [
    vim
    lf
-   pkgs.fprintd
-   pkgs.rustc
-   pkgs.rustup
-   pkgs.warp-terminal
+   fprintd
+   rustc
+   rustup
+   warp-terminal
    lshw
  ];

Thanks for the package tip!

I tried the fix you mentioned, with no avail unfortunately.

However, I took your hint about Xwayland and simply selected ‘Wayland on Xorg’ during login, and the program works as expected.

Thanks for the pointers!

1 Like