Editing Nixpkgs locally? (kernel package "bug")

XY problem: How do I edit nixpkgs locally?
Original problem: linux kernel package has a “bug” when building 5.19 development versions (pre-rc)

I’m trying to bisect when a lvm/btrfs/dm bug was introduced into the kernel. I figured that nixos would be a reasonable choice to easily compile with minimal configuration all the kernels between 5.10 and 6.1. I was basically right in that regard, until I got to a range of 5.18.0 vs 5.19-rc2. I wanted to then bisect range, but the makefile pre-rc1 lists 5.18, while the randomseed patch is moved in some of the revisions already. Normally it’s conditioned on >= 5.19, but as the makefile for 5.19 dev lists 5.18, it chooses the wrong patch. I want to remove the patch in nixpkgs so I can manually specify it in my configuration.nix How do I go about getting a change in nixpkgs locally?

With flakes it’s just changing your nixpkgs input to a path: url (e.g. inputs.nixpkgs.url = "git+file:///home/byteit/Projects/nixpkgs"; - note if you use git+file you will need to commit changes, and with flakes you need to nix flake lock --update-input to get the build to change if you make changes to upstream).

Without flakes it’s changing the entry in NIX_PATH (via -I or the env variable) that usually refers to the channel you’re using to a local path (e.g. nixpkgs=/home/byteit/Projects/nixpkgs).

Other than that, obviously, just clone nixpkgs to that local path and make your modifications.

If you don’t want to fork in the long term, you can apply smaller changes like this with overlays fairly easily.

1 Like