How do I install a package from a fork of nixpkgs?

I have submitted a package to nixpkgs, but it hasn’t been merged yet. In the meantime, I would like to be able to use it in my nixos configuration. How can I include a package from an alternate nixpkgs repo without replacing the official nixpkgs repo url with a link to a fork? Is there a way to add patches to flake input URL’s that I might be able to use?

PS: It’s probably worth noting that my system configuration is in a flake

In a flake, it’s quite easy. Just add an input like = "github:me/nixpkgs/branch";, then pass that through to your nixos config, which there’s a good overview of how to do here, then you can put something like${pkgs.system}.foo in your environment.systemPackages (whether you need inputs. will depend on how you passed it through).

1 Like

Ah, that’s a great blog post! Thank you for sharing! I think it should work now, but I don’t know for sure because this issue is preventing my system from building :stuck_out_tongue:

Is there a similar technique to this that would let me override the gmic package in my configuration to be the one from this PR so my system will build? gmic is a dependency of a few packages I have, so just adding it like this doesn’t fix it.

I do

nixos-rebuild -I nixpkgs="$PWD" switch


home-manager -I nixpkgs="$PWD" switch

On my checkout of nixpkgs with extra commits/tweaks; I don’t know what’s the most ergo way to do this nowadays but that’s what I have been using for years.

If you want to replace dependencies of other packages, then you’ll need to set up an overlay.

Something like this may well work:

nixpkgs.overlays = [
  (final: prev: {
    gmic =${pkgs.system}.gmic;

However, there may be a diamond dependency mismatch issue with something like that. Another option is to make the overlay final.callPackage the individual file from the PR version of nixpkgs, which would get all of gmic's dependencies from your main nixpkgs version, rather than from the PR version, like with my overlay above.

1 Like

For future reference, I also found this wiki article on this topic: