Overriding `src` of Qt5/KDE/Plasma pkgs

I have to goal of doing “integrated development” for KDE/Plasma components, which means:

  • I have a local repository clone, e.g. ~/code-repositories/public/KDE/utilities/print-manager
  • I override selected packages’ src attribute to point to the local clone
  • I can immediately see changes in effect in my DE after a nixos-rebuild switch

I know I could build them standalone without having to interfere with my configuration.nix/environment.systemPackages, but for many components which are part of the currently running session this makes the impossible to properly test them, so I want to have them be part of my regular system environment.

Therefore I created this overlay configuration:

nixpkgs.overlays = [
  (self: super: {
    libsForQt5 = super.libsForQt5 // {
      print-manager = super.libsForQt5.print-manager.overrideAttrs (oldAttrs: {
        src = builtins.fetchGit /home/eliasp/code-repositories/public/KDE/utilities/print-manager;
      });
    };
  })
];

This has the desired effect when explicitly adding libsForQt5.print-manager to environment.systemPackages, but it has absolutely no effect when libsForQt5.print-manager is added to environment.systemPackages through the Plasma5 module.

Having it in both places also causes collisions on rebuild, e.g.:

warning: collision between `/nix/store/6lvp44lpck0im1rsfipbk9z69ys7vnxd-print-manager-21.12.2/share/knotifications5/printmanager.notifyrc' and `/nix/store/zq26554a0dh53qzr8hbb549ba3idn1k7-print-manager-21.12.2/share/knotifications5/printmanager.notifyrc'
warning: collision between `/nix/store/6lvp44lpck0im1rsfipbk9z69ys7vnxd-print-manager-21.12.2/share/plasma/plasmoids/org.kde.plasma.printmanager/metadata.json' and `/nix/store/zq26554a0dh53qzr8hbb549ba3idn1k7-print-manager-21.12.2/share/plasma/plasmoids/org.kde.plasma.printmanager/metadata.json'
warning: collision between `/nix/store/6lvp44lpck0im1rsfipbk9z69ys7vnxd-print-manager-21.12.2/share/plasma/plasmoids/org.kde.plasma.printmanager/contents/ui/PopupDialog.qml' and `/nix/store/zq26554a0dh53qzr8hbb549ba3idn1k7-print-manager-21.12.2/share/plasma/plasmoids/org.kde.plasma.printmanager/contents/ui/PopupDialog.qml'

So it looks like manually adding it to environment.systemPackages and what the Plasma5 module is doing generates two completely distinct fixed points for the pkg libsForQt5.print-manager.

Any ideas:

  • how to get this working?
  • why this is a separate fixed point?
  • how to “debug” this? I failed getting lib.debug.traceSeq working to get a “backtrace” of this situation.

I would simply use a nixpkgs checkout. There I’d edit the interesting *.nix files to redirect source in whatever way I’d like (fetchgit, local dir with a checkout). Then sudo nixos-rebuild -I nixpkgs=path/to/nixpkgs test

EDIT: you can also do it almost the same way in case you’re using flake NixOS.

Using a local shallow clone of nixpkgs is actually what I used to do and why I’m looking now for a “proper solution”, as I’m tired of having to keep my nixpkgs clone rebased and felt a purely declarative approach should be possible and would theoretically make my life a lot easier.

I would expect it to work for the NixOS module, the only issue would occur if other packages in libsForQt5 depend on print-manager, in which case they would still be using the old one. To handle that properly, you need overrideScope', see Overlays - NixOS Wiki

overrideScope' looks exactly what I needed, but either I’m doing something completely wrong or it’s not working as expected.

In my configuration.nix:

nixpkgs.overlays = [
  (self: super: {
    libsForQt5 = super.libsForQt5.overrideScope' (qt5self: qt5super: {
      print-manager = qt5super.print-manager.overrideAttrs (oldAttrs: {
        src = builtins.fetchGit /home/eliasp/code-repositories/public/KDE/utilities/print-manager;
      });
    });
  })
];

Nothing happens on a rebuild, unless I explicitly add libsForQt5.print-manager to environment.systemPackages - then every modification in /home/eliasp/code-repositories/public/KDE/utilities/print-manager is picked up as expected.

:woman_facepalming:

So you will need to override libsForQt515. That will make libsForQt5 and plasma5Packages resolve correctly

nix-repl> let nixpkgs = import ./. { overlays = [ (final: prev: { libsForQt515 = prev.libsForQt515.overrideScope' (qt5final: qt5prev: { print-manager = "foo"; }); }) ]; }; in nixpkgs.plasma5Packages.print-manage"foo"

nix-repl> let nixpkgs = import ./. { overlays = [ (final: prev: { libsForQt515 = prev.libsForQt515.overrideScope' (qt5final: qt5prev: { print-manager = "foo"; }); }) ]; }; in nixpkgs.libsForQt5.print-manager    "foo"

since those apparently refer to the final package set:

Ugh! Thanks for this crazy detective work!

But I still end up with the same situation as before. From my configuration.nix:

nixpkgs.overlays = [  
  (final: prev: {  
    libsForQt515 = prev.libsForQt515.overrideScope' (qt5final: qt5prev: {  
      print-manager = qt5prev.print-manager.overrideAttrs (oldAttrs: {  
        src = builtins.fetchGit /home/eliasp/code-repositories/public/KDE/utilities/print-manager;  
      });  
    });  
  })  
];

Result is still the same as before…

Just for others that find this thread: I did not try it with print-manager, but had the same problem with kdenlive.
I was successful after overriding plasma5Packages instead of libsForQt515.

2 Likes