Write me a nix overlay that overrides the mesa package from an old nixpkgs commit
Assistant
Creating a Nix overlay that overrides the Mesa package from an old Nixpkgs commit can be a useful way to pin package versions while using a newer Nixpkgs set. Below is a step-by-step guide to create a custom overlay for this purpose.
Step 1: Find the Old Nixpkgs Commit
First, you need to find the commit hash of the Nixpkgs repository where the desired version of Mesa is located. You can do this by browsing the Nixpkgs GitHub repository or using a specific tag or branch that contains the Mesa version you want.
Step 2: Create Your Overlay
Create a new file in your Nix configuration directory, typically located at ~/.config/nixpkgs/overlays/mesa-overlay.nix. Here’s an example of what the overlay could look like:
self: super:
let
# Define the commit hash of the old Nixpkgs version
oldNixpkgs = import (fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs";
rev = "COMMIT_HASH"; # Replace with your actual commit hash
fetchSubmodules = true;
}) {};
in {
# Override the mesa package in the current package set
mesa = oldNixpkgs.mesa;
}
Explanation:
self and super are standard arguments in Nix overlays.
fetchFromGitHub is used to download the Nixpkgs repository from the specified commit.
The mesa = oldNixpkgs.mesa; line overrides the current version of Mesa with the version from the old Nixpkgs commit.
Step 3: Use the Overlay
To activate your overlay, make sure your ~/.config/nixpkgs/overlays/ directory is in your Nix configuration. If you don't have a config file yet, create one or add the following in ~/.config/nixpkgs/config.nix: