Using overrideScope' on Qt leaves dependency on old qmake

This is possibly a bug but I could also be doing this totally wrong!

I’m trying to apply a custom patch to Qt using overrideScope'. This seems to mostly work except that the qmake that’s actually used to build Qt isn’t seeing the override - it’s built with a qtbase that isn’t patched.

Here’s a demo:

$ nix repl
Welcome to Nix version 2.2.2. Type :? for help.

nix-repl> :l
Added 10566 variables.

nix-repl> pkgs.qt512.qmake # old qmake
«derivation /nix/store/89lj77ypxadp06n76pr6338aiw8wd3a5-hook.drv»

nix-repl> qt_override = pkgs.qt512.overrideScope' (
  self: super: { qtbase = super.qtbase.overrideAttrs (o: {
    patches = o.patches ++ [./some.patch]; }); })

nix-repl> qt_override.qtsvg
«derivation /nix/store/j4nbjjzphqsb9b27nra78i1iwmjf8c8q-qtsvg-5.12.0.drv»

# Grep shows we are still depending on old qmake
$ nix-store --query -R /nix/store/j4nbjjzphqsb9b27nra78i1iwmjf8c8q-qtsvg-5.12.0.drv | grep /nix/store/89lj77ypxadp06n76pr6338aiw8wd3a5-hook.drv

I ran this example against a local (slightly stale) nixpkgs but have subsequently verified on the 19.03 channel and nixpkgs master.

This is very old and this won’t apply to versions of Qt in modern nixpkgs, but just in case someone is building old software:

The problem here is that qmake comes from a makeSetupHook inside the Qt packages scope that isn’t overrideable. So, overriding the scope will override all the actual modules, which are created with mkDerivation, but will not override qmake.