I am running a headless server (GPU is for CUDA) and I did not think this would be needed.
After adding this line to my config I get:
# nvidia-smi
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
Rebooting fixed the thing.
Shouldn’t the nvtopPackages.nvidia pull it in by default?
EDIT: boot.kernelPackages = pkgs.linuxPackages is not needed.
Then I think it could be better labeled, especially if it not 1:1 Xorg related.
It might be better to have a hardware.nvidia.enable option, but there could be a good reason why it’s currently like this as well.
Isn’t that imperative though?
No, you’re still declaratively installing the package and configuring the drivers.
I thought that nix is just “say what you want, not how you want it”.
NixOS modules can automatically install packages for you, but I don’t think it works the other way around. It’s even more difficult in this case because the driver configuration largely depends on which hardware you have, which NixOS can’t guess.
That said, perhaps this can be possible in the future with something like nixos-facter.
Disclaimer: I’m not a GPU driver expert and I have a limited understanding of inner workings of CUDA/nvidia stuff.
Looking into issues from nvtop repo, it seems to me that nvtop was deliberately decoupled from much of an nvidia drivers due to compatibility issues - [Ubuntu < 22.04] apt install nvtop breaks / requires another nvidia driver · Issue #51 · Syllo/nvtop · GitHub .
As I have only AMD GPUs, I can’t reliably test nvidia-related stuff myself. I’d say if you want to improve the package in this regard, feel free to open an issue on Github and tag nixpkgs CUDA team, they likely help you to figure out good solution.