Overlay with new version

Hi everyone,

Today I’m trying to use an overlay to get the latest version of kitty v0.25.2 instead of v0.25.1.

I took exemple of the wiki Overlays - NixOS Wiki and my overlay is the following

self: super:
{
  kitty = super.kitty.overrideAttrs (old: {
    src = super.fetchFromGitHub {
      owner = "kovidgoyal";
      repo = "kitty";
      rev = "v0.25.2";
      hash = "sha256-o/vVz1lPfsgkzbYjYhIrScCAROmVdiPsNwjW/m5n7Us=";
    };
  });
}

nixos rebuild fails with this error

patching file kittens/ssh/main.py
Reversed (or previously applied) patch detected!  Assume -R? [n] 
Apply anyway? [n] 
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file kittens/ssh/main.py.rej
error: builder for '/nix/store/7jlxy9ngp4mqpdnxnbbpjjz49s2vvb8w-kitty-0.25.1.drv' failed with exit code 1

Any help greatly appreciated

Thx

I’m not 100% sure about the error, but it looks like the nixos-unstable channel already has v0.25.2 for kitty. So you should be able to use that. There are instructions here for how to use select packages from unstable while using stable for the rest of your packages.

1 Like

The error is because the base package expression tries to apply extra patches not compatible with 0.25.2 source code. You can see that the patches removed in the update commit:

https://github.com/NixOS/nixpkgs/commit/6bd65099b6ff15b5f5cd2d56215e1c07628ed3b5

You will need to filter them out

self: super:
{
  kitty = super.kitty.overrideAttrs (old: {
    src = super.fetchFromGitHub {
      owner = "kovidgoyal";
      repo = "kitty";
      rev = "v0.25.2";
      hash = "sha256-o/vVz1lPfsgkzbYjYhIrScCAROmVdiPsNwjW/m5n7Us=";
    };
    patches =
      let
        namesOfPatchesToRemove = [
          "fix-tarball-file-permissions.patch"
          "fontconfig-1.patch"
          "fontconfig-2.patch"
          "fontconfig-3.patch"
          "skip-login-shell-detection-for-nologin.patch"
        ];
      in
      builtins.filter
        (patch: !builtins.elem (patch.name or null)  namesOfPatchesToRemove)
        (old.patches or [ ]);
  });
}

But updating the channel as Logan suggests is probably better anyway.

1 Like

Thanks a lot for this very detailled answer. Very much appreciated.

Hi,

Both of the above methods are working and the version 0.25.2 of kitty is installed in the nix store.
But wathewer method used, the symbolic link in ~/.nix-profile/bin/kitty is not updated and still point to the old version of kitty.

kitty --version
kitty 0.25.1 created by Kovid Goyal
/nix/store/wxhynx5if1g2q8pzdrkpm77hrnm9hq2k-kitty-0.25.2/bin/kitty --version
kitty 0.25.2 created by Kovid Goyal

What I’m missing here ?

nixos-rebuild does not take care of your profile (unless you use something like home-manager through NixOS). Most likely ~/.nix-profile/bin/kitty was installed by nix-env.

Check nix-env -q for packages installed by it and nix-env -e kitty to uninstall. Then kitty from system-wide profile should be picked up.

It turns out that the old version of kitty is in my PATH.

echo $PATH
/home/pascal/bin:/nix/store/9mfrnggyymsvblw5z5n6facbvjsf5j2c-kitty-0.25.1/bin:/nix/store/wc5pshsqxp1i85nc1i98fga7mha7yqfw-imagemagick-7.1.0-37/bin:/nix/store/zn75yl366as243660mmz57c1v0qc406n-ncurses-6.3-p20220507-dev/bin:/run/wrappers/bin:/home/pascal/.nix-profile/bin:/etc/profiles/per-user/pascal/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin

I’m unable to find out how or in which file my PATH is set (didn’t find anything in the usual files, profile, bashrc…)

It’s an issue in nixpkgs Kitty leaks packages into system environment · Issue #171972 · NixOS/nixpkgs · GitHub

Hi. What about if I encounter the patch error if I’m trying to go back to an earlier version like in qemu here, I got the error when I update my nixpkgs unstable branch:

  qemu = pkgs.qemu.overrideAttrs (oldAttrs: rec {
    version = "8.1.3";
    src = pkgs.fetchurl {
      url = "https://download.qemu.org/qemu-${version}.tar.xz";
      hash = "sha256-Q8wXaAQQVYb3T5A5jzTp+FeH3/QA07ZA2B93efviZbs=";
    };
  });
error: builder for '/nix/store/8yfksk6w1fmfl5rv01rlm31zdbpnz5cf-qemu-8.1.3.drv' failed with exit code 1;
       last 10 log lines:
       > Perhaps you used the wrong -p or --strip option?
       > The text leading up to this was:
       > --------------------------
       > |--- a/include/ui/rect.h
       > |+++ b/include/ui/rect.h
       > --------------------------
       > File to patch:
       > Skip this patch? [y]
       > Skipping patch.
       > 1 out of 1 hunk ignored
       For full logs, run 'nix log /nix/store/8yfksk6w1fmfl5rv01rlm31zdbpnz5cf-qemu-8.1.3.drv'.

I had the exact same issue recently; this should work:

  qemu = pkgs.qemu.overrideAttrs (oldAttrs: rec {
    version = "8.1.3";
    src = pkgs.fetchurl {
      url = "https://download.qemu.org/qemu-${version}.tar.xz";
      hash = "sha256-Q8wXaAQQVYb3T5A5jzTp+FeH3/QA07ZA2B93efviZbs=";
    };
    patches = builtins.filter (x: (x.name or "") != "9d5b42beb6978dc6219d5dc029c9d453c6b8d503.diff") oldAttrs.patches;
  });

Where the filter uses the “name” attribute of the patch which is the file name part of the url by default when fetchpatch is used.
If the patch is a local file instead it doesn’t have a name attribute so we need to use (x.name or "") in the filter condition.

1 Like

Thanks, it worked! I found this a simple solution as well. :slight_smile: