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.

https://nixos.org/nixos/manual/#sec-x11-graphics-cards-nvidia

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: https://github.com/davidak/nixos-config/commit/6a7c3653e2a567d24883c405adf69718e852a87d

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 hardware.cpu.intel.updateMicrocode, but not for GPUs.

What do you think?

3 Likes