Override texlive.bin

I’m trying to override a cairo in texlive.bin. I don’t want to override it in all of nixpkgs, as that would lead to me having to recompile almost every single package on my system and my machine is not fast enough, and quite a few of the builds don’t even succeed (yes overriding cairo leads to recompiling systemd, linux and a whole bunch of other packages…).

bin doesn’t seem to be overridable

    (final: prev: {
      texlive = prev.texlive // {
        bin = prev.texlive.bin.override {
          cairo = prev.cairo.overrideAttrs (old: {
            patches = (old.patches or [ ]) ++ [
              (prev.fetchpatch {
                url =
                  "https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/595.patch";
                hash = "sha256-iWYxMVeNpseClSTf7BfU9GBe+tJWc+DUJWTWE5MnGh4=";
              })
            ];
          });
        };
      };
    })

This seems to lead to infinite recursion.

I’ve also tried adding this to my systemPackages, but that also doesn’t work:

(import <nixpkgs> {
          overlays = [
            (final: prev: {
              cairo = (prev.cairo.overrideAttrs (old: {
                patches = (old.patches or [ ]) ++ [
                  (prev.fetchpatch {
                    url =
                      "https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/595.patch";
                    hash =
                      "sha256-iWYxMVeNpseClSTf7BfU9GBe+tJWc+DUJWTWE5MnGh4=";
                  })
                ];
              }));
            })
          ];
        }).texlive;

Is there a way to do this?

bin is an output of the texlive package, so the thing you need to override is texlive directly, i.e. (pkgs.texlive.override { cairo = ...; }). Also is there a reason you need an overlay and not just an override directly? If you’re just putting it in a package list, you shouldn’t even need to specify .bin directly, it should be the default output used.

From what I understand texlive.bin is not an output of texlive, but just a property on the set.
Cairo is also not an input of texlive
I get this error with (pkgs.texlive.override { cairo = ...; }):

       error: function 'anonymous lambda' called with unexpected argument 'cairo'
       at /nix/store/k9bmrcqs2h3crv310zr01vahy55v4cpv-nixos-24.11/nixos/pkgs/tools/typesetting/tex/texlive/default.nix:5:1:

Oh, I was wrong. Both are package sets. Yeah, that’s going to be nasty to override…

At that point if the bug is that critical, I’d see if it’s possible to get the cairo patch into nixpkgs and let hydra handle the rebuilds.