Hey All,
Recently, I decided to switch from the stable to the unstable branch on my flake to see if it will improve my overall experience with the system. While I needed to address some of the config changes, most of them were trivial.
However, this one is a bit tricky. In the application list I see a new item which is “Manage Printers”. If you click on it will lead to the http://localhost:631/
web page which is supposed to be an interface for CUPS service to manage printers, but of course, this page is not loading and throws ERR_CONNECTION_REFUSED
. The thing is — print services are disabled globally via services.printing.enable = false;
and there are no other references in my config(s) to printers. I thought it might come from Gnome, which I currently use, but if I switch to Hyprland config (which removes gnome completely) I still see it in wofi app menu. Where does this come from? I cannot track this down…
(post deleted by author)
No clue either, but here’s a workaround
{
environment.extraSetup = ''
rm $out/share/applications/cups.desktop
'';
}
is /run/current-system/sw/share/applications/cups.desktop
even an extant file or is this some caching issue? If the file exists, what’s the output of realpath /run/current-system/sw/share/applications/cups.desktop
?
It was /nix/store/w3clwb8c7c8vc7ls163p5pjspccgcrhj-cups-2.4.11/share/applications/cups.desktop
before I applied the workaround
Does nix eval MYFLAKE#nixosConfigurations.$(hostname).options.environment.systemPackages.definitionsWithLocations
mention cups at all? (Replacing MYFLAKE
of course). And in which file if so?
(Or if you don’t use flakes, nixos-option environment.systemPackages
.)
If it doesn’t mention cups, what’s the output of nix why-depends /run/current-system /nix/store/w3clwb8c7c8vc7ls163p5pjspccgcrhj-cups-2.4.11
?
Nope. There’s absolutely no “cups” in the output.
/nix/store/kbqfsfhfvqbpk6g0cbn4vx9b43a6mzc4-nixos-system-absolute-gnome-25.05pre-git
└───/nix/store/5i7zrddg33l6vblsy9j3ww2my3g7vmys-system-path
└───/nix/store/w3clwb8c7c8vc7ls163p5pjspccgcrhj-cups-2.4.11
I have absolutely no clue why system-path depends on cups
It’s time to reveal the issue!
Why does the mysterious “Manage Printing” application appear in nearly every Qt User’s Desktop Environment?
The main problem is caused by two things: the setup hook and the propagatedBuildInputs
.
Note that I’m not very familiar with nixpkgs, it’s solely based on reading the source code. I hope someone can point out any mistakes if there are any.
-
Setup hook
It’s caused by the extra-cmake-modules’setup hook. Setup hook will be executed by downstream dependency, the setup hook will accept the dependency packages as parameters and adds the pkg to
propagatedUserEnvPkgs
if the pkg contains ashare/dbus-1
directory.Since nearly every KDE packages depends on
extra-cmake-modules
, it will be executed by nearly every KDE packages.You can find out how the setup hook is executed from here
-
PropagatedBuildInputs
Every KDE packages depends on
qt6.qtbase
package, the package propagate cupsThis means that every package that depends on
qt6.qtbase
package, it will also directly depend oncups
package. Because the setup hook will be executed on direct dependencies, it will add CUPS topropagatedUserEnvPkgs
, this essentially means that thecups
package is included inenvironment.systemPackage
.
To see who is depends oncups
:$ nix-store --query --referrers /nix/store/8xxq0pmjnn8jdrcbnd3kddgdvl5vdcgm-cups-2.4.11
the setup hook also sets
qtWrapperArgs+=(--prefix XDG_DATA_DIRS : "$1/share")
, that’s whyenvironment.extraSetup = ''rm $out/share/applications/cups.desktop'';
will not work on KDE. The Plasma desktop will also be wrapped with this, as it’s in the wrapper binary can’t be affected by the system environment. Other desktop environments don’t depend on Qt, so they don’t have this problem.