Best practice for enabling hardware support

Hello!

While i investigated how to add hardware support using some udev rules, i found the syntax hardware.bladeRF.enable. It seems common, so i think that is how it should be done.

But enabling video drivers is different and quiet complex.

So could we just introduce this and use the full potential of NixOS as an expert system?

hardware.gpu.nvidia.enable
hardware.gpu.amd.enable
hardware.gpu.ati.enable
hardware.gpu.intel.enable

For example, WHEN hardware.gpu.nvidia.enable = true; AND nixpkgs.config.allowUnfree = true;, the proprietary driver is used.

In addition, WHEN services.boinc.enable = true; THEN services.boinc.extraEnvPackages = with pkgs; [ linuxPackages.nvidia_x11 ocl-icd ];.

I tried that in my config: Add NVIDIA and AMD module · davidak/nixos-config@6a7c365 · GitHub

It should be possible for nixos-generate-config to detect hardware like GPUs and set them as metadata in hardware-configuration.nix. WHEN an NVIDIA GPU is detected, hardware.gpu.nvidia.enable should be set to true. The correct driver version for the Model should get automatically detected.

Discussion about that:

https://github.com/NixOS/nixos-hardware/issues/140
https://github.com/NixOS/nixos-hardware/issues/49

The syntax is already used in hardware.cpu.intel.updateMicrocode, but not for GPUs.

What do you think?

5 Likes