https://github.com/daaboulex/mesa-git-nix
Mesa from git main packaged for NixOS — bleeding-edge GPU drivers
https://github.com/daaboulex/mesa-git-nix
bleeding-edge flake gpu mesa mesa-git nix nixos opengl radeonsi radv vulkan
Last synced: 10 days ago
JSON representation
Mesa from git main packaged for NixOS — bleeding-edge GPU drivers
- Host: GitHub
- URL: https://github.com/daaboulex/mesa-git-nix
- Owner: Daaboulex
- License: mit
- Created: 2026-03-02T21:06:59.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-05-19T09:31:47.000Z (15 days ago)
- Last Synced: 2026-05-19T09:59:05.504Z (15 days ago)
- Topics: bleeding-edge, flake, gpu, mesa, mesa-git, nix, nixos, opengl, radeonsi, radv, vulkan
- Language: Shell
- Size: 146 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# mesa-git-nix
[](https://github.com/Daaboulex/mesa-git-nix/actions/workflows/ci.yml)
[](https://nixos.org)
[](./LICENSE)
Bleeding-edge [Mesa](https://www.mesa3d.org/) from the `main` branch, packaged as a Nix flake.
Overrides nixpkgs' `mesa` via `overrideAttrs` — no derivation rewrite needed. Provides an overlay (`mesa-git` / `mesa-git-32`), vendor-aware driver presets, and a NixOS module to swap the system graphics driver in one line.
## Upstream
| | |
|---|---|
| **Project** | https://gitlab.freedesktop.org/mesa/mesa |
| **License** | MIT |
| **Tracked** | Git HEAD (main) |
## Why?
nixpkgs-unstable tracks Mesa stable releases. Mesa `main` often contains unreleased driver optimizations weeks or months before a stable cut:
- **RDNA 4 / GFX12**: RadeonSI compute dispatch, buffer/image clears, shader improvements
- **RADV**: Vulkan driver fixes, new extensions, performance tuning
- **NVK / ANV / etc.**: Ongoing Vulkan and OpenGL improvements across all drivers
[Chaotic-Nyx](https://github.com/chaotic-cx/nyx) (the previous community mesa-git source) was archived in December 2025 with no maintained replacement.
## Pinned Commit
| Field | Value |
|---------|-------|
| Branch | `main` |
| Rev | [`52d57d98a294`](https://gitlab.freedesktop.org/mesa/mesa/-/commit/52d57d98a2948214a2d029f2f4e8b476bf39ada3) |
| Version | `26.2.0-devel` |
| Date | 2026-05-19 |
Updated automatically every 12 hours by CI. See [`version.json`](./version.json) for the full commit SHA.
## Installation
Add as a flake input:
```nix
{
inputs.mesa-git = {
url = "github:Daaboulex/mesa-git-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
}
```
Then add the overlay:
```nix
nixpkgs.overlays = [ inputs.mesa-git.overlays.default ];
```
Import the NixOS module:
```nix
imports = [ inputs.mesa-git.nixosModules.default ];
```
## Usage
### Flake Input
```nix
# flake.nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
mesa-git-nix = {
url = "github:daaboulex/mesa-git-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
}
```
### Option A: NixOS Module (Recommended)
The included NixOS module sets `hardware.graphics.package` and `hardware.graphics.package32` for you, with optional vendor-based driver selection.
```nix
# configuration.nix or host config
{ inputs, ... }: {
imports = [ inputs.mesa-git-nix.nixosModules.default ];
nixpkgs.overlays = [ inputs.mesa-git-nix.overlays.default ];
mesa-git = {
enable = true;
drivers = [ "amd" ]; # Only compile AMD drivers (see Driver Presets below)
};
}
```
### Option B: Overlay Only
If you manage `hardware.graphics.package` yourself or want to integrate mesa-git into your own module system:
```nix
{ inputs, pkgs, lib, ... }: {
nixpkgs.overlays = [ inputs.mesa-git-nix.overlays.default ];
# All drivers (default)
hardware.graphics.package = lib.mkForce pkgs.mesa-git;
hardware.graphics.package32 = lib.mkForce pkgs.mesa-git-32;
# Or with vendor selection (AMD-only)
hardware.graphics.package = lib.mkForce (pkgs.mkMesaGit { vendors = [ "amd" ]; });
hardware.graphics.package32 = lib.mkForce (pkgs.mkMesaGit32 { vendors = [ "amd" ]; });
}
```
### Option C: Standalone Build
```bash
nix build github:daaboulex/mesa-git-nix
nix eval github:daaboulex/mesa-git-nix#mesa-git.version
```
## Driver Presets
By default, mesa-git builds **all** drivers (same as nixpkgs). Set `drivers` to only compile what your hardware needs — this dramatically reduces build time.
### Vendor Presets
| Vendor | `drivers` | Gallium | Vulkan |
|--------|-----------|---------|--------|
| AMD | `[ "amd" ]` | radeonsi, r600, r300 | RADV |
| Intel | `[ "intel" ]` | iris, crocus, i915 | ANV, HasVK |
| NVIDIA | `[ "nvidia" ]` | nouveau, tegra | NVK |
| All | `[ ]` (default) | all 24 drivers | all 14 drivers |
### Common Essentials (Always Included)
Regardless of vendor selection, these are always built:
- **Gallium**: llvmpipe (software fallback), softpipe, zink (OpenGL-over-Vulkan), virgl (VM)
- **Vulkan**: Lavapipe/swrast (software fallback), virtio (VM)
### Multi-GPU / Integrated Graphics
For systems with multiple GPUs (e.g., Intel iGPU + NVIDIA dGPU), list all vendors:
```nix
mesa-git.drivers = [ "intel" "nvidia" ]; # Builds Intel + NVIDIA + common essentials
```
### Custom Driver Lists
For full control, use `mkMesaGit` / `mkMesaGit32` directly:
```nix
hardware.graphics.package = lib.mkForce (pkgs.mkMesaGit {
galliumDrivers = [ "radeonsi" "llvmpipe" "zink" ];
vulkanDrivers = [ "amd" "swrast" ];
});
```
## How It Works
The overlay applies `overrideAttrs` to nixpkgs' `mesa` derivation, changing only what's necessary:
| Attribute | Change |
|-----------|--------|
| `version` | `26.1.0-dev-` |
| `src` | Pinned git main commit from `version.json` |
| `patches` | Cleared (nixpkgs patches target release line numbers) |
| `postPatch` | Replicates `opencl.patch` effects via `substituteInPlace` + `sed`; skips `mesa-gl-headers` validation |
| `mesonFlags` | Driver lists replaced when vendor presets are used |
| `env.MESON_PACKAGE_CACHE_DIR` | Rebuilt from `wraps.json` (Rust crate deps matching git main) |
Everything else (build inputs, outputs, `postInstall`, `postFixup`) is inherited from nixpkgs.
### What the `postPatch` Does
1. **`clang-libdir` meson option** — nixpkgs' `opencl.patch` adds a custom meson option so Nix can control the clang library search path. We replicate this with `substituteInPlace` on `meson.build` and append the option definition from `clang-libdir-option.meson`.
2. **Rusticl ICD install** — disables auto-installing the `.icd` file (nixpkgs reconstructs it with an absolute Nix store path in `postInstall`).
3. **`mesa-gl-headers` check** — skipped entirely, since git main headers diverge from the pinned release headers package.
## Development
```bash
git clone https://github.com/Daaboulex/mesa-git-nix
cd mesa-git-nix
nix develop # enter dev shell, installs pre-commit hooks
nix fmt # format flake + module
nix flake check --no-build # eval check
nix build .#mesa-git # build the package
nix eval .#mesa-git.version # confirm pinned commit + version string
```
### Updating the pin
```bash
./scripts/update.sh
```
This script:
1. Fetches the latest commit SHA from `gitlab.freedesktop.org/mesa/mesa` `main`
2. Computes the source hash with `nix-prefetch-git`
3. Sparse-clones `subprojects/*.wrap` to regenerate `wraps.json` (Rust crate dependencies)
4. Writes `version.json`
After updating, test with:
```bash
nix build .#mesa-git
nix eval .#mesa-git.version
```
CI runs the same chain every 12 hours via `.github/workflows/update.yml`, so manual updates are rarely needed.
## Verification
After `nixos-rebuild switch`:
```bash
# OpenGL version should show the git version string
glxinfo | grep "OpenGL version"
# Vulkan driver info should show RADV with git version
vulkaninfo | grep driverInfo
```
## Repository Structure
```
mesa-git-nix/
├── flake.nix # Flake: overlay + NixOS module + packages
├── flake.lock
├── overlay.nix # Nixpkgs overlay: mesa-git, mkMesaGit, driver presets
├── module.nix # NixOS module: mesa-git.enable + drivers option
├── clang-libdir-option.meson # Meson option snippet (avoids Nix string escaping)
├── version.json # Pinned commit: rev, hash, version, date
├── wraps.json # Rust crate deps for MESON_PACKAGE_CACHE_DIR
├── update.sh # Script to pin latest mesa main commit
├── pkgs/
│ └── mesa-git.nix # Package documentation (build via overlay)
├── LICENSE
└── README.md
```
## Options
This module declares options under `mesa-git`. See [`module.nix`](module.nix) for all available options.
## License
This packaging flake is [MIT](./LICENSE) licensed. Mesa itself is distributed under the [MIT license](https://docs.mesa3d.org/license.html).
---
*Maintained as part of the [Daaboulex](https://github.com/Daaboulex) NixOS ecosystem.*