Home Explore Blog CI



nixpkgs

2nd chunk of `nixos/modules/services/hardware/display.md`
169876c0fee0747c2ed9a4608273055055131b1aef161f910000000100000d1d
`$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:

```nix
{
  hardware.display.outputs."VGA-1".edid = "custom1.bin";
  hardware.display.outputs."VGA-2".edid = "custom2.bin";
  /* equals:
  boot.kernelParams = [ "drm.edid_firmware=VGA-1:edid/custom1.bin,VGA-2:edid/custom2.bin" ];
  */
}
```

## Pulling files from linuxhw/EDID database {#module-hardware-display-edid-linuxhw}

`hardware.display.edid.linuxhw` utilizes `pkgs.linuxhw-edid-fetcher` to extract EDID files
from https://github.com/linuxhw/EDID based on simple string/regexp search identifying exact entries:

```nix
{
  hardware.display.edid.linuxhw."PG278Q_2014" = [ "PG278Q" "2014" ];

  /* equals:
  hardware.display.edid.packages = [
    (pkgs.linuxhw-edid-fetcher.override {
      displays = {
        "PG278Q_2014" = [ "PG278Q" "2014" ];
      };
    })
  ];
  */
}
```


## Using XFree86 Modeline definitions {#module-hardware-display-edid-modelines}

`hardware.display.edid.modelines` utilizes `pkgs.edid-generator` package allowing you to
conveniently use [`XFree86 Modeline`](https://en.wikipedia.org/wiki/XFree86_Modeline) entries as EDID binaries:

```nix
{
  hardware.display.edid.modelines."PG278Q_60" = "    241.50   2560 2608 2640 2720   1440 1443 1448 1481   -hsync +vsync";
  hardware.display.edid.modelines."PG278Q_120" = "   497.75   2560 2608 2640 2720   1440 1443 1448 1525   +hsync -vsync";

  /* equals:
  hardware.display.edid.packages = [
    (pkgs.edid-generator.overrideAttrs {
      clean = true;
      modelines = ''
        Modeline "PG278Q_60"      241.50   2560 2608 2640 2720   1440 1443 1448 1481   -hsync +vsync
        Modeline "PG278Q_120"     497.75   2560 2608 2640 2720   1440 1443 1448 1525   +hsync -vsync
      '';
    })
  ];
  */
}
```

## Complete example for Asus PG278Q {#module-hardware-display-pg278q}

And finally this is a complete working example for a 2014 (first) batch of [Asus PG278Q monitor with `amdgpu` drivers](https://gitlab.freedesktop.org/drm/amd/-/issues/615#note_1987392):

```nix
{
  hardware.display.edid.modelines."PG278Q_60" = "   241.50   2560 2608 2640 2720   1440 1443 1448 1481   -hsync +vsync";
  hardware.display.edid.modelines."PG278Q_120" = "  497.75   2560 2608 2640 2720   1440 1443 1448 1525   +hsync -vsync";

  hardware.display.outputs."DP-1".edid = "PG278Q_60.bin";
  hardware.display.outputs."DP-1".mode = "e";
}
```

Title: Assigning and Generating EDID Files in NixOS
Summary
This section describes how to assign custom EDID binaries to monitor outputs using the `hardware.display.outputs."<NAME>".edid` option in NixOS. It also covers pulling EDID files from the linuxhw/EDID database and using XFree86 Modeline definitions to create EDID binaries. A complete example for an Asus PG278Q monitor with `amdgpu` drivers is provided.