In my NixOS configuration, I enable services.urxvtd
. In 24.05, I ran into the bug described in tmux v3.4 outputs garbage in urxvt [SOLVED] / Applications & Desktop Environments / Arch Linux Forums. There’s a patch that fixes the bug, and I’d like to apply the patch to urxvt on my system.
Unfortunately I don’t didn’t know how to get the patch to where it needs to go. [While writing this post, I figured out something that works. I still have questions…]. The best I’ve got is was this:
services.urxvtd = {
enable = true;
package = pkgs.rxvt-unicode-unwrapped.overrideAttrs (orig: {
patches = orig.patches ++ [ ../patches/urxvt-garbage.patch ];
});
};
With that, I’ve successfully applied the patch. But I’m using the wrong package now! I want the wrapped version, which properly includes some Perl search paths or whatever.
But I don’t know how to modify the underlying unwrapped package while still using the wrapped package for services.urxvtd.package
.
Some things I’ve tried:
Apply overrideAttrs to pkgs.rxvt-unicode
I naively assumed that the wrapper still evaluates to something that has an overrideAttrs
, but I guess it doesn’t.
Replace urxvtd-unicode-unwrapped in a nixpkgs overlay
Doesn’t work, don’t know why. pkgs.rxvt-unicode-unwrapped
should be using pkgs.rxvt-unicode
as a callPackage input, right? Everything built fine, but the patch didn’t end up in my system.
Use overrideDerivation (1)
I.e.
package = pkgs.rxvt-unicode.overrideDerivation (drv: {
rxvt-unicode-unwrapped = pkgs.rxvt-unicode-unwrapped.overrideAttrs (...);
});
This managed to build, but the patch didn’t end up in my system, so it didn’t work.
Use overrideDerivation (2)
Ok, can I add patches directly to the rxvt-unicode derivation?
package = pkgs.rxvt-unicode.overrideDerivation (orig:{
patches = orig.patches ++ [
../patches/urxvt-garbage.patch
];
});
No, this again builds fine but the patch isn’t in my system.
Use override [THIS IS THE ONE THAT WORKS]
package = pkgs.rxvt-unicode.override ({
rxvt-unicode-unwrapped = pkgs.rxvt-unicode-unwrapped.overrideAttrs (orig: {
patches = orig.patches ++ [
../patches/urxvt-garbage.patch
];
});
});
Hey, this works!
Unfortunately the chapter on overrides wasn’t enough for me to figure this out directly. I guess my journey went like:
- From previous experience, I had learned that you can add patches via
overrideAttrs
- Reading nixpkgs sources, I learned that
mkOverridable
adds anoverride
attribute that lets you change the inputs to a function - Reading nixpkgs sources, I learned that
rxvt-unicode-unwrapped
was an overridable function that takes anrxvt-unicode-unwrapped
argument - I can compose
override
withoverrideAttrs
to build the package I need
I feel like there could be improvements to the process: I suffered this bug for six months because I didn’t have time to do this little journey before now. But I don’t have any immediate suggestions. Maybe this post will help somebody in the future.