Https://bbs.archlinux.org/viewtopic.php?id=293022

Dear all,

Since quite a while now, I get weird characters in my URXVT upon terminal resizing or tmux-attaching:

10;rgb:ffff/ffff/ffff11;rgb:0000/0000/0000

This problem has been discussed and addressed for Arch, but NixOS lacks the supercharged package that fixed it in Arch.

I am a little surprised that this bug did not draw more attention, given how popular tmux and urxvt are. Has anybody seen a workaround in NixOS?

I wonder if this is related… I recently noticed that a few programs, notably gh, cause spurious weird characters to appear in my urxvt terminals. I’ll give that patch a try.

Unfortunately, while the patch does fix the problem for tmux, it doesn’t fix it for gh.

1 Like

Well, on NixOS it’s pretty trivial to patch stuff like this downstream:

{ pkgs, lib, ... }: {
  environment.systemPackages = let
    urxvt = pkgs.urxvt.overrideAttrs (old: {
      patches = old.patches ++ [
        (pkgs.fetchpatch {
          name = "7-bit-queries.patch";
          url = "https://aur.archlinux.org/cgit/aur.git/plain/7-bit-queries.patch?h=rxvt-unicode-truecolor-wide-glyphs";
          extraPrefix = "";
          hash = lib.fakeHash;
        })
      ];
    });
  in [
    urxvt
  ];
}

You can suggest this upstream too, if you read into the urxvt discussions and see why this isn’t just fixed there. I’m not a big fan of mindlessly applying patches.

1 Like

The tmux thing is already fixed upstream. They just haven’t released a new version yet.

Here’s the upstream change in patch form: urxvt-color-termination.patch Ā· GitHub

I tested that and it applies cleanly on rxvt-unicode 9.31 and fixes tmux. But it turns out my gh problem was a whole different thing:

Looks like anything using github.com/muesli/termenv is affected, including the formatter used by nixpkgs, treefmt.

2 Likes

@TLATER That snippet won’t quite work, for a couple of reasons:

  • The package is actually pkgs.rxvt-unicode.
  • It’s a wrapper around pkgs.rxvt-unicode-unwrapped, which is what you need to patch.
  • The patch file isn’t quite made correctly to automatically apply inside stdenv.

I’ve actually tested this overlay structure:

pkgs: prevPkgs:

{
  rxvt-unicode-unwrapped = prevPkgs.rxvt-unicode-unwrapped.overrideAttrs (prevAttrs: {
    patches = (prevAttrs.patches or []) ++ [ ./urxvt-color-termination.patch ];
  });
}

With ./urxvt-color-termination.patch being a local copy of urxvt-color-termination.patch Ā· GitHub.

2 Likes

fetchpatch should tape over that most of the time, would be curious what specifically doesn’t work here.

But yep, not tested at all, mainly trying to show how nixpkgs’ override infrastructure works.

1 Like

It’s a file path matching issue:

applying patch /nix/store/8gcgchzfnxyga0zbg8ybd72i49vi48jn-7-bit-queries.patch
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- a/a/src/command.C
|+++ b/b/src/command.C
--------------------------
File to patch: 
Skip this patch? [y] 
Skipping patch.
13 out of 13 hunks ignored
can't find file to patch at input line 222
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- a/a/src/rxvt.h
|+++ b/b/src/rxvt.h
--------------------------
File to patch: 
Skip this patch? [y] 
Skipping patch.
2 out of 2 hunks ignored
error: builder for '/nix/store/y3i1n5nkyw7hb2nq1lc9zgjm5qw6gsy6-rxvt-unicode-unwrapped-9.31.drv' failed with exit code 1;

stripLen = 1; fixes it. (Or just leaving off extraPrefix, apparently. Learning about a new piece of nixpkgs today :slight_smile:)

2 Likes

Thanks @tejing and @tlater! Great to hear this is being fixed upstream. I guess I’ll wait patiently then until it makes it into nixpkgs on its own.

Best,
Moritz

I made a PR to cherry-pick that patch in the nixpkgs version:

2 Likes