Easiest Way to include nixpkgs pull request

I am not quite sure how to do this or if this is in any way feasible, but is there a way to add include pull request that has not yet been merged to my configuration? To be more specific, I want to include this pull request: Upgrade and modularize `fcitx5-mozc` by musjj · Pull Request #251706 · NixOS/nixpkgs · GitHub so that it works when I add it here:

enabled = "fcitx5";
      fcitx5 = {
        waylandFrontend = true;
        addons = with pkgs; [

I’d appreciate any help

Depending on how much you want to take on, it might be time to start your own nixpkgs branch that you use for your systems. I have my branch cmpkgs that tracks nixos-unstable. Ideally, it would just mirror nixos-unstable, but there’s usually something nixpkgs-related that I’m hacking on, or some cross-compiler fix that I’m carrying, etc.

1 Like

Just add .diff or .patch to the URL. This will redirect you to https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/251706.diff and https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/251706.patch and you can use the regular patch-machinery:

patches = [
      (fetchpatch {
        url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/251706.patch";
        hash = "sha256-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
1 Like

Note that doing this requires modifying nixpkgs, as my suggestion does. There are a few options:

  1. Override the package, set patches, use this as the package for the nixos service “package” option, if available.
  2. Override the package, set patches, use this as an overlay to replace the package in place.
  3. Make one’s own nixpkgs branch with that patch applied, build against that branch.

Up to the reader which choice makes the most sense.

Hm, this would be nice to look at in the future, but it seems kinda overkill right now, because I don’t really want to work on any package stuff or fix cross-compiler issues, also I wouldn’t know how to manage that, I could apply my patches but when the merge request gets added and there are some conflicts or leftovers from old patches, I don’t really want to manage that myself
I guess nixos cache also wouldn’t work if I use my own branch? which sucks because I’ll have to wait hours until every browser I use is compiled

Sorry I am not sure what I added to my config is 100% correct:

nixpkgs.overlays = [
      (final: prev: {
        fcitx5-mozc = prev.fcitx5-mozc.overrideAttrs (o: {
          patches =
              (pkgs.fetchpatch {
                url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/251706.patch";
                hash = "sha256-ERhR/mtMRqqK+t0IOy+CeO7NjgFITZrdFjf0gkeKQso=";

but it fails and when I look at the nix log it shows:

can't find file to patch at input line 310
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
|From d0989ec66af8df4a82e27911b8c0c9e6a62775b0 Mon Sep 17 00:00:00 2001
|From: musjj <72612857+musjj@users.noreply.github.com>
|Date: Tue, 5 Sep 2023 03:22:10 +0700
|Subject: [PATCH 3/3] fcitx5-mozc: 2.26.4220.102 -> unstable-2023-08-18
|Migrate from the deprecated GYP build system to the new Bazel build
| .../tools/inputmethods/fcitx5/fcitx5-mozc.nix | 210 +++++++++---------
| pkgs/top-level/all-packages.nix               |   6 +-
| 2 files changed, 111 insertions(+), 105 deletions(-)
|diff --git a/pkgs/tools/inputmethods/fcitx5/fcitx5-mozc.nix b/pkgs/tools/inputmethods/fcitx5/fcitx5-mozc.nix
|index e58db09f706c39..95c01f8b01ffc9 100644
|--- a/pkgs/tools/inputmethods/fcitx5/fcitx5-mozc.nix
|+++ b/pkgs/tools/inputmethods/fcitx5/fcitx5-mozc.nix
File to patch:
Skip this patch? [y]
Skipping patch.

and that for every file the patch affects (but that more looks like I am applying the patch wrong?)

That means you’ve done the Nix part right - but the code that the patch expects to be applied to differs too much from what is fetched by the original expression.

Looking closer at the first link, this is a patch for NixPkgs and not for fcitx5-mozc. Sorry, I had overlooked that part on the first answer.
In that case you can just import https://github.com/musjj/nixpkgs/tree/fcitx-mozc-bazel like any other NixPkgs (e.g. additional flake input) and pick the relevant package like you would do when choosing packages from unstable while having your system on release.

I’ve got everything working now, thank you both @wamserma and @colemickens so much!

The flake input part was really helpful! I now have this in my flake.nix:

    inputs.mypkgs = {
      url = "git+file:///path/to/nixpkgs";

and this in my configuration.nix:

nixpkgs.overlays = [
      (self: super: (let
        mypkgs = import inputs.mypkgs {
          inherit (self) system;
      in {
        fcitx5-mozc = mypkgs.fcitx5-mozc;

I’m using the local flake input because I had to fix some sha missmatches and update a broken url in the pull request and it felt cubersome to commit and push every try at this.

I also dont really get why I have to do the import inputs.mypkgs stuff, I just copied that from here: Build failure: nvidia_x11_latest · Issue #286313 · NixOS/nixpkgs · GitHub which, well is incidentally exactly what I was wanting to do here lol

I thought I could just do fcitx5-mozc = inputs.mypkgs.fcitx5-mozc but that didn’t work nor anything else I tried to directly use inputs.mypkgs, but well, it works perfectly now this way, even better than I anticipated, because I can actually just add every individual package in my overlay that I changed and remove it if it gets merged in, without any configuration overhead, or easily add my own packages if I want to use them in my config! Thanks so much!

1 Like