Nvidia drivers on NixOS laptop

Hi im new to nixos and idk how to install it can someone help me? I want install with nvidia.nix file not in conf.nix

The NVIDIA page on NixOS wiki may help you set up the NVIDIA driver

  1. create nvidia.nix
  2. paste you settings

(my example with NVIDIA and Intel iGPU)
your settings may be another check https://wiki.nixos.org/wiki/NVIDIA

{ ... }:

{
  hardware.graphics.enable = true;
  services.xserver.videoDrivers = [ “modesetting” “nvidia” ];
  hardware.nvidia = {
    modesetting.enable = true;
    open = true;
    powerManagement.enable = true;
    prime = {
      offload.enable = true;
      offload.enableOffloadCmd = true;
      intelBusId = “PCI:0@0:2:0”;
      nvidiaBusId = “PCI:1@0:0:0”;
    };
  };
}
  1. in you main configuration.nix file add nvidia.nix to imports
    imports = [
    # Hardware scan
    ./hardware-configuration.nix
    ./nvidia.nix
    ];
2 Likes

These are the sort of answers needed. Not the generic TLDR responses with a link

The link is needed because “nvidia” is meaningless without an exact model number, and dozens of people came together to write a more complete* wiki page that should cover every edge case. (And frankly repeating the same info here is going to make the answer here outdated within a year, probably.)

*not necessarily accurate, but @TLATER could probably say more on that.

7 Likes

Yup. Nvidia is quite a broad topic! It’s hard to help without knowing more, and configs can differ greatly just based off of what devices you have. For example, a server I have:

{
  nixpkgs.config.allowUnfree = true;
  nixpkgs.config.cudaSupport = true;

  nix.settings.system-features = [ "cuda" ];

  services.xserver.videoDrivers = [ "nvidia" ];
  hardware = {
    graphics.enable = true;
    nvidia.open = true;
  };

  environment.systemPackages = with pkgs; [
    pciutils
    btop-cuda
    nvtopPackages.nvidia
  ];
}
1 Like