Running GUI applications on non-NixOS

Hi,

I am using Nix on Ubuntu. I am trying to run GUI apps installed via Nix. For this example: vscode

I am managing my profiles with home-manager.

home.nix:

{ config, pkgs, ... }:

{
  # Home Manager needs a bit of information about you and the paths it should
  # manage.
  home.username = "vandy";
  home.homeDirectory = "/home/vandy";
  
  # Enable Graphical Services
  xsession.enable = true;
  xsession.windowManager.command = "…";
  
  nixGL.packages = import <nixgl> { inherit pkgs; };
  nixGL.defaultWrapper = "mesa";  # Default wrapper for general use
  nixGL.offloadWrapper = "nvidiaPrime";  # Wrapper for NVIDIA GPU offloading
  nixGL.installScripts = [ "mesa" "nvidiaPrime" ];
  
  home.packages = [
  (config.lib.nixGL.wrap pkgs.vscode)
  ];

  home.stateVersion = "25.05"; # Please read the comment before changing.

  home.file = {
  };

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

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

However when I try to launch vscode via terminal, it doesn’t launch. I am unable to figure out why. What am I doing wrong here. I tried with and without the NixGL wrapper.

user@user ~> code -v
1.100.2
848b80aeb52026648a8ff9f7c45a9b0a80641e2f
x64

I use it like this on my ubuntu:

  programs.vscode = {
    enable = true;
    package = config.lib.nixGL.wrap pkgs.vscode;
  };
1 Like

Nothing happens when I run the code command. I tried your way too. Am I missing any packages/libraries?

Nothing?

There is a lot of room for interpretation…

  1. Immediately prompt again, exit code of 0, but no window appears, nothing in the list of processes
  2. 1 but something in the processes
  3. 1 but with a non-zero exit code
  4. 2 but with a non-zero exit code
  5. No prompt no window, not much in the processes
  6. 5 but a lot of processes
  7. Any of the above with additional output in the journal
2 Likes
user@user ~> code -v
1.100.2
848b80aeb52026648a8ff9f7c45a9b0a80641e2f
x64

Fixing this output,


user@users ~> code --verbose
Warning: 'ozone-platform-hint' is not in the list of known options, but still passed to Electron/Chromium.
Warning: 'enable-features' is not in the list of known options, but still passed to Electron/Chromium.
Warning: 'enable-wayland-ime' is not in the list of known options, but still passed to Electron/Chromium.
[9321:0608/133151.970543:FATAL:setuid_sandbox_host.cc(163)] The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I'm aborting now. You need to make sure that /nix/store/n71p521p4gngr8mxrhh00hqrarbfpvar-vscode-1.100.2/lib/vscode/chrome-sandbox is owned by root and has mode 4755.

The -v flag was for version and not verbose lol. I was able to fix it (for now) by running it in no sandbox mode code --no-sandbox.

Thanks for your replies.