Home Explore Blog CI



nixpkgs

1st chunk of `nixos/modules/services/hardware/display.md`
d0226ecb4adc4447ea595344d5516f401d66626abe27df240000000100000917
# Customizing display configuration {#module-hardware-display}

This section describes how to customize display configuration using:
- kernel modes
- EDID files

Example situations it can help you with:
- display controllers (external hardware) not advertising EDID at all,
- misbehaving graphics drivers,
- loading custom display configuration before the Display Manager is running,

## Forcing display modes {#module-hardware-display-modes}

In case of very wrong monitor controller and/or video driver combination you can
[force the display to be enabled](https://mjmwired.net/kernel/Documentation/fb/modedb.txt#41)
and skip some driver-side checks by adding `video=<OUTPUT>:e` to `boot.kernelParams`.
This is exactly the case with [`amdgpu` drivers](https://gitlab.freedesktop.org/drm/amd/-/issues/615#note_1987392)

```nix
{
  # force enabled output to skip `amdgpu` checks
  hardware.display.outputs."DP-1".mode = "e";
  # completely disable output no matter what is connected to it
  hardware.display.outputs."VGA-2".mode = "d";

  /* equals
  boot.kernelParams = [ "video=DP-1:e" "video=VGA-2:d" ];
  */
}
```

## Crafting custom EDID files {#module-hardware-display-edid-custom}

To make custom EDID binaries discoverable you should first create a derivation storing them at
`$out/lib/firmware/edid/` and secondly add that derivation to `hardware.display.edid.packages` NixOS option:

```nix
{
  hardware.display.edid.packages = [
    (pkgs.runCommand "edid-custom" {} ''
       mkdir -p $out/lib/firmware/edid
       base64 -d > "$out/lib/firmware/edid/custom1.bin" <<'EOF'
       <insert your base64 encoded EDID file here `base64 < /sys/class/drm/card0-.../edid`>
       EOF
       base64 -d > "$out/lib/firmware/edid/custom2.bin" <<'EOF'
       <insert your base64 encoded EDID file here `base64 < /sys/class/drm/card1-.../edid`>
       EOF
    '')
  ];
}
```

There are 2 options significantly easing preparation of EDID files:
- `hardware.display.edid.linuxhw`
- `hardware.display.edid.modelines`

## Assigning EDID files to displays {#module-hardware-display-edid-assign}

To assign available custom EDID binaries to your monitor (video output) use `hardware.display.outputs."<NAME>".edid` option.
Under the hood it adds `drm.edid_firmware` entry to `boot.kernelParams` NixOS option for each configured output:

Title: Customizing Display Configuration in NixOS
Summary
This section explains how to customize display configuration in NixOS using kernel modes and EDID files, which can be useful for addressing issues with display controllers, graphics drivers, or loading custom configurations before the Display Manager starts. It covers forcing display modes, crafting custom EDID files, and assigning EDID files to specific displays.