Compiling mesa without unnecessary drivers?

I am trying to remove unnecessary drivers that were compiled in mesa. The main code is this:

nixpkgs.overlays = [
  (final: prev: {
    mesa = prev.mesa.override {
      galliumDrivers = [
        # "d3d12" # WSL emulated GPU (aka Dozen)
        "iris" # new Intel (Broadwell+)
        "virgl" # QEMU virtualized GPU (aka VirGL)
      ];
      vulkanDrivers = [
        "intel" # new Intel (aka ANV)
      ];
    };
  })
];

Running nixos-rebuild gives:

error: builder for '/nix/store/m8z3rbqm7lxa58i9v0q5bgx2mrzxi4z3-mesa-26.2.3.drv' failed to produce output path for output 'spirv2dxil' at "/nix/store/m8z3rbqm7lxa58i9v0q5bgx2mrzxi4z3-mesa-26.2.3.drv.chroot/root/nix/store/agf7mk32rq6h987zgpd09qa8zl2xjbh8-mesa-26.2.3-spirv2dxil"

I also tried running galliumDrivers including d3d12 since it was said to rely on spirv2dxil, but nothing seems to have changed.

I’ve never tried to do this but the general shape of the override you added doesn’t seem too unreasonable based on a brief scan of https://github.com/NixOS/nixpkgs/blob/cf5e76507c6e23b59f7e0ffcc7baa2a39ddd8442/pkgs/development/libraries/mesa/default.nix.

The chroot path seems very weird but for all I know this could be very normal for this package.

In any case I can’t really help debug but the error you get seems to reproduce for me. A more explicit repro might help others:

Repro under fold (click to reveal)
# default.nix
{ pkgs ? import <nixpkgs> {} }:

pkgs.mesa.override {
  galliumDrivers = [
    # "d3d12" # WSL emulated GPU (aka Dozen)
    "iris" # new Intel (Broadwell+)
    "virgl" # QEMU virtualized GPU (aka VirGL)
  ];
  vulkanDrivers = [
    "intel" # new Intel (aka ANV)
  ];
}

and

nix-build -I nixpkgs="https://releases.nixos.org/nixos/unstable/nixos-26.11pre1078696.4975466d3247/nixexprs.tar.xz" default.nix to build it with a specified nixpkgs.

The drv it evals to for me is /nix/store/pgddz3gx2kllnmvhfzslk2ryry3djn79-mesa-26.2.3.drv and the outputs are:

$ nix-store --query --outputs /nix/store/pgddz3gx2kllnmvhfzslk2ryry3djn79-mesa-26.2.3.drv
/nix/store/3j5q3jv483nv9qjhvm5z7rjch8iwdj3b-mesa-26.2.3-cross_tools
/nix/store/k2wahn6r526pgmhhln8dbai9k0fji0b2-mesa-26.2.3-spirv2dxil
/nix/store/kkf0kdf9a878qhxg38bzsdfwqx2l45h8-mesa-26.2.3
/nix/store/yaq4bg3hclmg92mwkhjhgnj9qwhzn40p-mesa-26.2.3-debug
/nix/store/z207zr49fffs10bbzhfj92mkxjv470jc-mesa-26.2.3-opencl

Thanks for this, upon further testing it seems as though the only thing that output spirv2dxil is reliant on is microsoft-experimental in vulkanDrivers. Strangely enough, this means that the only vulkan driver that cannot be removed is an experimental driver which sole purpose is vulkan to d3d12, only found in WSL (more common would be d3d12 to vulkan, satisfied by vkd3d). It would be nice if there was a way for this esoteric driver to not be installed.

For anyone else’s information, the only other requirement is a suitable driver for gallium-va, satisfied by virgl or virtio or radeonsi or a few other options. The full list wouldn’t be too difficult to get since this part fails early in the compilation process.