How to test changes to nixpkg modules?

Hello,

as the titles says I’m wondering in what the best way is to test changes to modules from the nixpkgs repo. This question came up, because I wanted to change the waydroid module, so that the package used can be set via an option.

What is the best practice to test those changes?
I have seen, that for packages I can execute

nix-build -A $yourpackage

from my local branch to test it, but in this case it’s not a package.
Do I copy the file to my local environment (maybe put it in its own namespace) and change and test it. Afterwards, I transfer the relevant parts back to my copy of the nixpkgs repo and create the PR.
Or is there a better way to do this?

For context, I’m using the stable branches on my system (currently 24.11) and sometimes I use some packages from unstable, when required.

If you’re using normal non-flake nixos-rebuild for your OS, it accepts -I nixpkgs=/path/to/nixpkgs, so you can build/switch/… on any modified nixpkgs tree.

I am using flakes for my system. Is the idea then, that I basically change my current system branch to my own modified version?
That would mean, I would base my change of from the 24.11 branch to test my change?

Well yes. I don’t know what other kind of testing you had in mind than deploying the change to (some of) your systems. You might deploy to a VM instead of usual system, for example, by nixos-rebuild build-vm.

Of course you can rebase the change (in git) as you prefer for the testing. Hopefully unstable and 24.11 wouldn’t be too far from each other for the purpose of testing.

Alright, then I know how to do it. Just wanted to know the best practice.
The missing link for me was, that you can override the nixpkgs source with a local path.
Then I can test it on my system.

Thank you @vcunat :slight_smile: