# Including nixpkgs PRs for your system has never been easier!

**URL:** https://discourse.nixos.org/t/including-nixpkgs-prs-for-your-system-has-never-been-easier/65724
**Category:** Announcements
**Created:** [June 16, 2025, 3:05pm UTC](https://discourse.nixos.org/t/including-nixpkgs-prs-for-your-system-has-never-been-easier/65724 "2025-06-16T15:05:10Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![gepbird](https://discourse.nixos.org/user_avatar/discourse.nixos.org/gepbird/32/10112_2.png) [@gepbird](https://discourse.nixos.org/u/gepbird)
#### Post date: [June 16, 2025, 3:05pm UTC](https://discourse.nixos.org/t/including-nixpkgs-prs-for-your-system-has-never-been-easier/65724/1 "2025-06-16T15:05:10Z")

</div>

I made a flake that lets you seamlessly use nixpkgs pull requests before they hit your channel, check it out! [GitHub - gepbird/nixpkgs-patcher: Using nixpkgs pull requests that haven't landed into your channel has never been easier!](https://github.com/gepbird/nixpkgs-patcher)

You no longer need to wait for PRs get merged. … or for the merged PRs to land in your channel.  
You no longer need to craft overlays to change package versions, or replace packages from a PR.  
You no longer need to write `disableModules` and `imports` to use a NixOS module from a PR.  
You no longer need to maintain your own fork of nixpkgs.

All you need is declaring a new flake input with the PR diff:

```auto
# file: flake.nix
{
  inputs.nixpkgs-patch-git-review-bump = {
    url = "https://github.com/NixOS/nixpkgs/pull/410328.diff";
    flake = false;
  };
}

```

Related discussions:

- [Easiest Way to include nixpkgs pull request](https://discourse.nixos.org/t/easiest-way-to-include-nixpkgs-pull-request/39307)
- [How to try a PR](https://discourse.nixos.org/t/how-to-try-a-pr/15410)
- [Support flake references to patches · Issue #3920 · NixOS/nix · GitHub](https://github.com/NixOS/nix/issues/3920)

I’m aware there are similar tools to this (see [GitHub - gepbird/nixpkgs-patcher: Using nixpkgs pull requests that haven't landed into your channel has never been easier!](https://github.com/gepbird/nixpkgs-patcher#comparison-with-alternatives)), the focus of nixpkgs-patcher is the ease of use for specifically patching nixpkgs for your personal system.

---

<div class="post-metadata">

### Author: ![PhilipTaron](https://discourse.nixos.org/user_avatar/discourse.nixos.org/philiptaron/32/35913_2.png) [@PhilipTaron](https://discourse.nixos.org/u/PhilipTaron)
#### Post date: [June 16, 2025, 3:36pm UTC](https://discourse.nixos.org/t/including-nixpkgs-prs-for-your-system-has-never-been-easier/65724/2 "2025-06-16T15:36:47Z")

</div>

In addition to this module, there’s also a trick that @MattSturgeon taught me:

```auto
inputs.nixpkgs.url = "github:NixOS/nixpkgs?ref=pull/379731/merge";

```

This uses GitHub’s feature of concocting a tree with the PR merged against master.

---

<div class="post-metadata">

### Author: ![kdn](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/k/8e7dd6/32.png) [@kdn](https://discourse.nixos.org/u/kdn)
#### Post date: [June 16, 2025, 3:50pm UTC](https://discourse.nixos.org/t/including-nixpkgs-prs-for-your-system-has-never-been-easier/65724/3 "2025-06-16T15:50:40Z")

</div>

I’ve written myself [something similar](https://github.com/nazarewk-iac/nix-configs/blob/e9dbf5246f03d0103f37134e3b1dadce05dd41d6/.flake.patches/update.py) with locally checked out patches after a while with [GitHub - katrinafyi/nix-patcher: a tool for patching Nix flake inputs, declaratively!](https://github.com/katrinafyi/nix-patcher) , I don’t remember exactly, but I think I had some issues with:

- issues with naming and/or ordering of patches (sometimes they need to be applied in the correct order)
- mutating references to patches: I was never sure I’d get the exact patch/PR version that I expected and I’m pretty sure this gave some issues when building configurations after some time has passed since the last flake update
  - caching those locally solved this issue for me

Didn’t dig much into how you’re doing the patching, but:

- you might want to add `?full_index=1` to the examples, github likes to truncate the references to different lengths
- does your solution work properly and reproducibly when referencing those mutating references? eg: PRs that are heavily worked on

PS: I love that you have also figured out and wrote down many different ways you can reference a patch on GitHub, was about to suggest my [`config.toml`](https://github.com/nazarewk-iac/nix-configs/blob/e9dbf5246f03d0103f37134e3b1dadce05dd41d6/.flake.patches/config.toml) comments, but you seem to have it all 🙂

---

<div class="post-metadata">

### Author: ![vcunat](https://discourse.nixos.org/user_avatar/discourse.nixos.org/vcunat/32/11_2.png) [@vcunat](https://discourse.nixos.org/u/vcunat)
#### Post date: [June 16, 2025, 6:33pm UTC](https://discourse.nixos.org/t/including-nixpkgs-prs-for-your-system-has-never-been-easier/65724/4 "2025-06-16T18:33:23Z")

</div>

In this simple way you can only merge a single PR into its merge base, so that only covers the simpler use cases.

---

<div class="post-metadata">

### Author: ![gepbird](https://discourse.nixos.org/user_avatar/discourse.nixos.org/gepbird/32/10112_2.png) [@gepbird](https://discourse.nixos.org/u/gepbird)
#### Post date: [June 16, 2025, 6:34pm UTC](https://discourse.nixos.org/t/including-nixpkgs-prs-for-your-system-has-never-been-easier/65724/5 "2025-06-16T18:34:28Z")

</div>

Thanks for sharing your solution and interest!

> I don’t remember exactly, but I think I had some issues with:
> 
> - issues with naming and/or ordering of patches (sometimes they need to be applied in the correct order)

With nixpkgs-patcher, patches get applied alphabetically, more info on ordering is at [GitHub - gepbird/nixpkgs-patcher: Using nixpkgs pull requests that haven't landed into your channel has never been easier!](https://github.com/gepbird/nixpkgs-patcher#patches-are-out-of-order)

> - you might want to add `?full_index=1` to the examples, github likes to truncate the references to different lengths

That’s interesting, I see the `index` line in the diff is the full commit hash, but I don’t really see the value in that for typing those few characters out. When does github truncate it to different lengths? Is the same length not guaranteed when using the same URLs at different times?

> - does your solution work properly and reproducibly when referencing those mutating references? eg: PRs that are heavily worked on

With a URL like `https://github.com/NixOS/nixpkgs/pull/410328.diff` you can get different patches on different systems (however when it changes you’ll see that `flake.lock` is dirty), doing a `nix flake update nixpkgs-patch-git-review-bump` will get you the currently latest patch.

To ensure reproducibility, you can pin it to a specific commit hash, or a range of commits with compare and commit hashes like `https://github.com/NixOS/nixpkgs/compare/b024ced1aac25639f8ca8fdfc2f8c4fbd66c48ef...0330cef96364bfd90694ea782d54e64717aced63.diff` (after a force-push to the PR, IIRC GitHub should show that those commits don’t belong to any branch but still be available for download).

Another way to ensure reproducibility is use it with `fetchpatch` where you need to specify a `hash` and be sure that it will fail to build when the PR is updated, see [GitHub - gepbird/nixpkgs-patcher: Using nixpkgs pull requests that haven't landed into your channel has never been easier!](https://github.com/gepbird/nixpkgs-patcher#using-your-configuration). Or download the patch locally and reference to it with `path:./git-review-bump.diff` to be extra sure. I’ll add a note about it to the readme, thanks 🙂

---

<div class="post-metadata">

### Author: ![kdn](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/k/8e7dd6/32.png) [@kdn](https://discourse.nixos.org/u/kdn)
#### Post date: [August 6, 2025, 8:57am UTC](https://discourse.nixos.org/t/including-nixpkgs-prs-for-your-system-has-never-been-easier/65724/6 "2025-08-06T08:57:56Z")

</div>

> [@gepbird](#):
>
> When does github truncate it to different lengths? Is the same length not guaranteed when using the same URLs at different times?

It is **usually** stable, but it can return different commit lengths for exactly the same URL unless you instruct it explicitly to always return full commit lengths with `?full_index=1`. I have seen it happen many times in both permanent (changes forever) and temporary manner (changes reverting back after few hours/days, maybe even differently based on geolocation).

You can find more through [GitHub search](https://github.com/search?q=%22full_index%3D1%22&type=issues) and some community discussion [Patch URL from pull requests should use full index to maintain stable contents · community · Discussion #12531 · GitHub](https://github.com/orgs/community/discussions/12531)
