Home-manager and graphic drivers on non-NixOS desktop

Hello everyone,

I am currently running Ubuntu 24.04.2 and I have set up home-manager to manage my dev environment. I am struggling to set up my config to run programs (kitty, alacritty, or wezterm) or a desktop environment such as hyprland that require graphic drivers (here an Nvidia GPU).

From what I understood, since it is a non-NixOS distribution, the drivers are managed by Ubuntu. I tried the nixGL solution but failed to run kitty for example. See below the output of nixGL kitty:

[0,119] [glfw error 65542]: EGL: Failed to get EGL display: Success
[0,124] Traceback (most recent call last):
  File "/nix/store/8h3d079ngpr14q14icpjd6jz346ia7j6-kitty-0.39.0/bin/../lib/kitty/kitty/main.py", line 537, in main
    _main()
  File "/nix/store/8h3d079ngpr14q14icpjd6jz346ia7j6-kitty-0.39.0/bin/../lib/kitty/kitty/main.py", line 529, in _main
    run_app(opts, cli_opts, bad_lines, talk_fd)
  File "/nix/store/8h3d079ngpr14q14icpjd6jz346ia7j6-kitty-0.39.0/bin/../lib/kitty/kitty/main.py", line 262, in __call__
    _run_app(opts, args, bad_lines, talk_fd)
  File "/nix/store/8h3d079ngpr14q14icpjd6jz346ia7j6-kitty-0.39.0/bin/../lib/kitty/kitty/main.py", line 229, in _run_app
    window_id = create_os_window(
                ^^^^^^^^^^^^^^^^^
ValueError: Failed to create GLFWwindo

You can find below a mininal version of my home-manager configuration.
flake.nix

{
  inputs = {
    # Specify the source of Home Manager and Nixpkgs.
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { nixpkgs, home-manager, ... }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
    in {
      homeConfigurations."dst" = home-manager.lib.homeManagerConfiguration {
        inherit pkgs;
        modules = [ ./home.nix ];
      };
    };
}

home.nix:

{ config, pkgs, ... }:

{
  home.username = "dst";
  home.homeDirectory = "/home/dst";
  home.stateVersion = "24.11";
  programs.kitty.enable = true;
  programs.home-manager.enable = true;
}

Do you have any ideas how I should proceed ?

Thank you !

I’ve not had good results with nixGL on foreign distros personally. If possible I’d use kitty from your distro’s package manager.

EDIT: there’s also GitHub - numtide/nix-gl-host: Run OpenGL/Cuda programs built with Nix, on all Linux distributions., I have no experience with it though.

You could give nix-system-graphics a try as well.