Files
2025-12-23 14:58:54 +00:00

3.2 KiB

NixOS Facter

Source: {file}modules/hardware/facter

Upstream documentation: https://nix-community.github.io/nixos-facter/

NixOS Facter provides automatic hardware detection and configuration for NixOS systems. It generates a machine-readable JSON report capturing detailed hardware information, which NixOS modules then use to automatically configure appropriate drivers, kernel modules, and system settings.

Generating a Hardware Report

To generate a hardware report, run the following command as root on the target machine:

$ sudo nix-shell -p nixos-facter --run 'nixos-facter -o facter.json'

This scans your system and produces a JSON report containing:

  • System architecture
  • Virtualization environment (if any)
  • Hardware details (CPU, GPU, network controllers, disks, etc.)
  • SMBIOS/DMI information

Using the Report

Add the generated report to your NixOS configuration:

{
  hardware.facter.reportPath = ./facter.json;
}

Alternatively, you can inline the report directly:

{
  hardware.facter.report = builtins.fromJSON (builtins.readFile ./facter.json);
}

What Gets Configured

Based on the hardware report, NixOS Facter automatically configures:

  • System: Sets based on detected architecture
  • Firmware: Enables and CPU microcode updates on bare-metal
  • Boot: Configures UEFI support and loads initrd modules for storage controllers, disks, and input devices
  • Virtualization: Detects VMs (QEMU/KVM, VirtualBox, Hyper-V, Parallels) and enables appropriate guest support
  • Graphics: Enables and loads GPU kernel modules
  • Networking: Configures DHCP on detected interfaces and enables WiFi firmware
  • Bluetooth: Enables when hardware is detected
  • Fingerprint: Enables for supported readers
  • Cameras: Enables for Intel IPU6 webcams

Debugging

To understand what changes NixOS Facter makes to your system closure, use the built-in debugging tools:

nvd diff

Shows packages added and removed by enabling facter.

With flakes:

$ nix run .#nixosConfigurations.<hostname>.config.hardware.facter.debug.nvd

Without flakes:

$ nix-build '<nixpkgs/nixos>' -A config.hardware.facter.debug.nvd -I nixos-config=./configuration.nix
$ ./result/bin/facter-nvd-diff

nix-diff

Shows detailed derivation differences.

With flakes:

$ nix run .#nixosConfigurations.<hostname>.config.hardware.facter.debug.nix-diff

Without flakes:

$ nix-build '<nixpkgs/nixos>' -A config.hardware.facter.debug.nix-diff -I nixos-config=./configuration.nix
$ ./result/bin/facter-nix-diff

Options

A complete list of options for the facter module may be found here.