Problem Description
On NixOS, when pinning applications to the KDE Plasma Icon-Only Task Manager panel, icons periodically break and revert to generic "blank document" or white sheet placeholders.
This usually happens immediately after a system upgrade (nixos-rebuild switch), a Home Manager generation change, or a Nix garbage collection cycle (nix-collect-garbage).
Root Cause
KDE Plasma natively resolves pinned taskbar shortcuts to absolute file URIs pointing directly inside the Nix store:
file:///nix/store/example-package/share/applications/firefox.desktop
Because the Nix store is immutable and isolated, any configuration change or garbage collection purges the old hash path. When Plasma tries to read the path pinned in its configuration file, the target directory no longer exists, causing the icon asset lookups to fail gracefully back to system defaults.
To resolve this permanently, we must force KDE Plasma to stop tracking absolute store paths and instead use dynamic applications: URIs (e.g., applications:firefox.desktop), which look up applications globally within the current user profile environment.
Add an automation script to your home.nix config. This utilizes a Home Manager activation hook to search and replace raw /nix/store/ references inside the Plasma desktop configuration file every time you switch generations.
Ensure your home.nix module header explicitly imports lib:
{ config, pkgs, lib, ... }:
{
... your existing configurations ...
home.activation = {
clean-plasma-launchers = lib.hm.dag.entryAfter ["writeBoundary"] ''
# Run only if the Plasma desktop configuration file exists
if [ -f "${config.home.homeDirectory}/.config/plasma-org.kde.plasma.desktop-appletsrc" ]; then
# Rewrite volatile absolute nix store paths to dynamic abstract application URIs
$DRY_RUN_CMD sed -i 's|file:///nix/store/[^/]*/share/applications/|applications:|g' \
${config.home.homeDirectory}/.config/plasma-org.kde.plasma.desktop-appletsrc || true
fi
'';
};
}
Rebuild your Home Manager generation to activate the hook:
home-manager switch
systemctl restart --user plasma-plasmashell
sudo reboot now
Verification & Maintenance
No Broken Icons Post-GC: You can safely run nix-collect-garbage -d at any time; your pinned panel applications will gracefully resolve to the active paths in the current profile generation.
Idempotent Execution: The sed substitution matches pattern structures safely, meaning it will only target absolute store links and leave existing valid applications: URIs untouched during subsequent generations.