Best practice for enabling hardware support


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?


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:

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:

The syntax is already used in, but not for GPUs.

What do you think?