Describe the bug
On the Plasma 5 desktop, theme is broken on several tabs of systemsettings5. This happens on both plasma desktop 5.16.5 and 5.17.5
To Reproduce
Steps to reproduce the behavior:

Expected behavior
Theme should work properly
Additional context
If run from the terminal, the following log is displayed when switching the tab:
org.kde.kcoreaddons: Error loading plugin "kcm_kscreen" "The shared library was not found."
Plugin search paths are ("/nix/store/dkm6jsa0apc7vlpdkslpvsxw1qr7kxh2-python3-3.7.6/lib/qt-5.12.6/plugins", "/run/wrappers/lib/qt-5.12.6/plugins", "/home/kj/.nix-profile/lib/qt-5.12.6/plugins", "/etc/profiles/per-user/kj/lib/qt-5.12.6/plugins", "/nix/var/nix/profiles/default/lib/qt-5.12.6/plugins", "/run/current-system/sw/lib/qt-5.12.6/plugins", "/nix/store/p4vbc0aqsj22f38fniixm0mc9binmal6-systemsettings-5.17.5-bin/lib/qt-5.12.6/plugins", "/nix/store/5h2d5lmhxy4b5ad6h41y8gxa5rd20q4a-plasma-workspace-5.17.5/lib/qt-5.12.6/plugins", "/nix/store/pwkk4w00kvddfyzdv9g0z0531mjv6ddj-qtlocation-5.12.6-bin/lib/qt-5.12.6/plugins", "/nix/store/kwxxwfd3vyz9aw16wyi031ll776rr7hx-libkscreen-5.17.5/lib/qt-5.12.6/plugins", "/nix/store/n1xfvr02f5l81gjap4v51jqc7dc7y8jp-kwin-5.17.5-bin/lib/qt-5.12.6/plugins", "/nix/store/rpy458gzc6rpgszwi1hpinsrv3yr3p6f-breeze-qt5-5.17.5-bin/lib/qt-5.12.6/plugins", "/nix/store/9rm257fgzpb5nhf2swhqvmh15yb4zbg1-frameworkintegration-5.66.0-bin/lib/qt-5.12.6/plugins", "/nix/store/3kfyqzz0chffhrlfcd3z0y03624z57aa-qtsensors-5.12.6-bin/lib/qt-5.12.6/plugins", "/nix/store/sprs2s1m8xgqf4kspl5pnwmfxf3ll0mw-ktexteditor-5.66.0-bin/lib/qt-5.12.6/plugins", "/nix/store/28chnah4xmkb1j9mb8b6m0cpl65qdys7-kscreenlocker-5.17.5/lib/qt-5.12.6/plugins", "/nix/store/jqnydkyplv1s0l7sqavh6qk3g3ay5lpn-plasma-framework-5.66.0-bin/lib/qt-5.12.6/plugins", "/nix/store/wkfp1h7xja24gw5y71ixmsj0y7zq1vic-kdelibs4support-5.66.0/lib/qt-5.12.6/plugins", "/nix/store/94wk9psqhasi9wysh96abdxnqhq08bzc-kemoticons-5.66.0-bin/lib/qt-5.12.6/plugins", "/nix/store/fhi739yhv9bapk09a071pi2gips3x6vy-kplotting-5.66.0/lib/qt-5.12.6/plugins", "/nix/store/462sx9hz9bij1piwbdqbj04fiaz43sw9-baloo-5.66.0-bin/lib/qt-5.12.6/plugins", "/nix/store/krphqcq0dv1h9psa4qwgr0lbxy6r19k3-kidletime-5.66.0-bin/lib/qt-5.12.6/plugins", "/nix/store/b8jwp7i8hrbdkrzd95cnv7vm0w4h3rk1-kfilemetadata-5.66.0-bin/lib/qt-5.12.6/plugins", "/nix/store/17j1xi89yz969vq0nh58w7xzfjdp3l64-qtmultimedia-5.12.6-bin/lib/qt-5.12.6/plugins", "/nix/store/vpclqcmcwsgxwsw2nj4d779xqva6i6i2-khtml-5.66.0-bin/lib/qt-5.12.6/plugins", "/nix/store/0yh5jm2488m40b4r4iwdvmgwdc05dnsq-kio-5.66.0/lib/qt-5.12.6/plugins", "/nix/store/z2l2h5idnn45ybbmpkgbnqy43jai0ni2-phonon-4.11.1/lib/qt-5.12.6/plugins", "/nix/store/25acay6sf1nc7dcal25gb9pqr9d3rp3z-kxmlgui-5.66.0-bin/lib/qt-5.12.6/plugins", "/nix/store/sgpsgpwkzkz61rcc5f5jlrjdy3fa37hi-ktextwidgets-5.66.0-bin/lib/qt-5.12.6/plugins", "/nix/store/i4kb53jjn7g1a9cbs96944mfw75igyra-kcompletion-5.66.0/lib/qt-5.12.6/plugins", "/nix/store/gjhx2ng2ggsw9lbihk59l2ynvr1b8q14-sonnet-5.66.0-bin/lib/qt-5.12.6/plugins", "/nix/store/zwx96j7gllhckvran7ab2fqcdxn96fv4-kiconthemes-5.66.0-bin/lib/qt-5.12.6/plugins", "/nix/store/6m98b8nkyvcy19i1jmzha3rf45s65wnh-kitemviews-5.66.0/lib/qt-5.12.6/plugins", "/nix/store/3vqwlbm2wl90vy91ky11wnvdmzabbv6r-kglobalaccel-5.66.0-bin/lib/qt-5.12.6/plugins", "/nix/store/xchw8xyppk5q750kfbaic52zq6d5ll1g-kwindowsystem-5.66.0/lib/qt-5.12.6/plugins", "/nix/store/zcnjc2dybpkdhiskgmspyk2ajd89asax-kguiaddons-5.66.0/lib/qt-5.12.6/plugins", "/nix/store/4pcp8z5hfdhs46gf1si5wpiqshxg86wb-kwidgetsaddons-5.66.0/lib/qt-5.12.6/plugins", "/nix/store/1v8ja8988gk5p5m91nnyi27pc622521z-kauth-5.66.0/lib/qt-5.12.6/plugins", "/nix/store/09v7c5gn755varmy8nm5vi1r556dkpyk-kconfigwidgets-5.66.0-dev/lib/qt-5.12.6/plugins", "/nix/store/gsrc9z7jls62kgwhyh0xxdvlb30bsysf-ki18n-5.66.0-bin/lib/qt-5.12.6/plugins", "/nix/store/pfsm8mmw5vi2b7xfavlkawl9yqal71ak-qtwayland-5.12.6-bin/lib/qt-5.12.6/plugins", "/nix/store/rp9zgzm1s5bw8545mhyihmksaxc9zfyv-qtdeclarative-5.12.6-bin/lib/qt-5.12.6/plugins", "/nix/store/55arwwspz5sjx2qc65wy66i6kkazrd74-qtsvg-5.12.6-bin/lib/qt-5.12.6/plugins", "/nix/store/6vypqvbkj9jwf4lrjmgm3p8s2xn4addp-qtbase-5.12.6-bin/lib/qt-5.12.6/plugins", "/nix/store/gbbgnr20a3wia424qrd5rrp6630pn75k-fcitx-with-plugins-4.2.9.6/lib/qt4/plugins", "/nix/store/p4vbc0aqsj22f38fniixm0mc9binmal6-systemsettings-5.17.5-bin/bin")
The environment variable QT_PLUGIN_PATH might be not correctly set
QQmlEngine::setContextForObject(): Object already has a QQmlContext
file:///nix/store/djyvdkqxnj8j044lnnwvcixq15qb44k5-kscreen-5.17.5/share/kpackage/kcms/kcm_kscreen/contents/ui/Screen.qml:50: TypeError: Value is null and could not be converted to an object
file:///nix/store/djyvdkqxnj8j044lnnwvcixq15qb44k5-kscreen-5.17.5/share/kpackage/kcms/kcm_kscreen/contents/ui/main.qml:28: ReferenceError: units is not defined
file:///nix/store/djyvdkqxnj8j044lnnwvcixq15qb44k5-kscreen-5.17.5/share/kpackage/kcms/kcm_kscreen/contents/ui/main.qml:27: ReferenceError: units is not defined
file:///nix/store/djyvdkqxnj8j044lnnwvcixq15qb44k5-kscreen-5.17.5/share/kpackage/kcms/kcm_kscreen/contents/ui/Screen.qml:48: ReferenceError: units is not defined
file:///nix/store/djyvdkqxnj8j044lnnwvcixq15qb44k5-kscreen-5.17.5/share/kpackage/kcms/kcm_kscreen/contents/ui/Screen.qml:59: ReferenceError: units is not defined
file:///nix/store/djyvdkqxnj8j044lnnwvcixq15qb44k5-kscreen-5.17.5/share/kpackage/kcms/kcm_kscreen/contents/ui/Screen.qml:57: ReferenceError: units is not defined
file:///nix/store/djyvdkqxnj8j044lnnwvcixq15qb44k5-kscreen-5.17.5/share/kpackage/kcms/kcm_kscreen/contents/ui/main.qml:116: ReferenceError: units is not defined
file:///nix/store/djyvdkqxnj8j044lnnwvcixq15qb44k5-kscreen-5.17.5/share/kpackage/kcms/kcm_kscreen/contents/ui/main.qml:116: ReferenceError: units is not defined
file:///nix/store/djyvdkqxnj8j044lnnwvcixq15qb44k5-kscreen-5.17.5/share/kpackage/kcms/kcm_kscreen/contents/ui/Screen.qml:48: ReferenceError: units is not defined
file:///nix/store/djyvdkqxnj8j044lnnwvcixq15qb44k5-kscreen-5.17.5/share/kpackage/kcms/kcm_kscreen/contents/ui/main.qml:116: ReferenceError: units is not defined
file:///nix/store/djyvdkqxnj8j044lnnwvcixq15qb44k5-kscreen-5.17.5/share/kpackage/kcms/kcm_kscreen/contents/ui/OutputPanel.qml:93:12: QML RotationButton: Binding loop detected for property "height"
file:///nix/store/djyvdkqxnj8j044lnnwvcixq15qb44k5-kscreen-5.17.5/share/kpackage/kcms/kcm_kscreen/contents/ui/OutputPanel.qml:90:12: QML RotationButton: Binding loop detected for property "height"
file:///nix/store/djyvdkqxnj8j044lnnwvcixq15qb44k5-kscreen-5.17.5/share/kpackage/kcms/kcm_kscreen/contents/ui/OutputPanel.qml:87:12: QML RotationButton: Binding loop detected for property "height"
file:///nix/store/djyvdkqxnj8j044lnnwvcixq15qb44k5-kscreen-5.17.5/share/kpackage/kcms/kcm_kscreen/contents/ui/OutputPanel.qml:84:12: QML RotationButton: Binding loop detected for property "height"
file:///nix/store/djyvdkqxnj8j044lnnwvcixq15qb44k5-kscreen-5.17.5/share/kpackage/kcms/kcm_kscreen/contents/ui/Output.qml:80: ReferenceError: units is not defined
file:///nix/store/djyvdkqxnj8j044lnnwvcixq15qb44k5-kscreen-5.17.5/share/kpackage/kcms/kcm_kscreen/contents/ui/Output.qml:90: ReferenceError: units is not defined
Metadata
[root@DCHORUS-LEGION-NIXOS:~]# nix-shell -p nix-info --run "nix-info -m"
- system: `"x86_64-linux"`
- host os: `Linux 5.4.17, NixOS, 20.03pre212208.8130f3c1c2b (Markhor)`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.3.2`
- channels(root): `"nixos-20.03pre212208.8130f3c1c2b"`
- channels(kj): `""`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
It's because the proper theme is not selected for the qtquickcontrol2 parts of settings. The same problem applies to all the kirigami based applications (discover as an example).
The workaround:
QT_QUICK_CONTROLS_STYLE=plasma systemsettings5
However, when I do this some parts of the settings application will segfault.
You can also pick another theme from this list - https://doc.qt.io/qt-5/qtquickcontrols2-styles.html
imagine looks decent:
QT_QUICK_CONTROLS_STYLE=imagine systemsettings5
But in any case, it's a problem that plasma doesn't set this correctly and of course that we get segfaults when using the proper theme.
Cc: @ttuegel
What you are seeing is technically not a broken theme. It's the default qtquickcontrols2 theme.
Switching to another style didn't really help here - KCMs are still utterly broken (e.g. display KCM doesn't load the QML for positioning the displays).
According to nix-env -q, I have 0 pkgs in my environment, so nothing there should mess with me here...
Seeing The environment variable QT_PLUGIN_PATH might be not correctly set reminds me quite a bit of #27050
My $QT_PLUGIN_PATH contains 138 items - I wonder whether we're hitting some limit here which might cause this?
There are a few things which strike me as weird...
kcmshell5 kscreen complains about not being able to find kcm_kscreen.so and hints at a probably misconfigured $QT_PLUGIN_PATH environment variable, but the paths displayed after the error message don't seem to originate from the values in $QT_PLUGIN_PATH.
kcmshell5 kscreen seems to be right, that none of the printed paths contains kcm_kscreen.so:
$ kcmshell5 kscreen 1>/dev/null 2>&1 | grep 'Plugin search paths are' | cut -d\( -f2 | cut -d\) -f1 | sed -e 's|, |\n|g' | sed -e 's|^"||g' -e 's|"$||g' | xargs -I {} find {}/ -type f -name kcm_kscreen.so
find: β/run/wrappers/lib/qt-5.12.6/plugins/β: No such file or directory
find: β/home/eliasp/.nix-profile/lib/qt-5.12.6/plugins/β: No such file or directory
find: β/etc/profiles/per-user/eliasp/lib/qt-5.12.6/plugins/β: No such file or directory
find: β/nix/var/nix/profiles/default/lib/qt-5.12.6/plugins/β: No such file or directory
The same goes for $QT_PLUGIN_PATH - none of the entries seems to provide kcm_kscreen.so:
$ echo $QT_PLUGIN_PATH | sed 's|:|\n|g' | sort | xargs -I {} find {}/ -type f -name kcm_kscreen.so
find: β/etc/profiles/per-user/eliasp/lib/kde4/plugins/β: No such file or directory
find: β/etc/profiles/per-user/eliasp/lib/qt4/plugins/β: No such file or directory
find: β/home/eliasp/.nix-profile/lib/kde4/plugins/β: No such file or directory
find: β/home/eliasp/.nix-profile/lib/qt4/plugins/β: No such file or directory
find: β/nix/var/nix/profiles/default/lib/kde4/plugins/β: No such file or directory
find: β/nix/var/nix/profiles/default/lib/qt4/plugins/β: No such file or directory
find: β/run/current-system/sw/lib/kde4/plugins/β: No such file or directory
find: β/run/current-system/sw/lib/qt4/plugins/β: No such file or directory
Looking at /nix/store, the following possible matches are currently present:
find /nix/store/*-kscreen-*/lib/qt-*/plugins/ -type f -name kcm_kscreen.so
/nix/store/17iyjhqrgxq63wmzz76vp9q3b9x2lg3p-kscreen-5.16.5/lib/qt-5.12.6/plugins/kcm_kscreen.so
/nix/store/24vyflvrgxi5h5mxlbgcncskmanj1381-kscreen-5.16.5/lib/qt-5.12.6/plugins/kcm_kscreen.so
/nix/store/2jp445v9xr214wgb3rjh4ix1xmy2ysr3-kscreen-5.16.5/lib/qt-5.12.6/plugins/kcm_kscreen.so
/nix/store/53w8y9xj5rvlz9rq5hmlh9alqdcgi69w-kscreen-5.14.5/lib/qt-5.12/plugins/kcm_kscreen.so
/nix/store/5m7zscnx24777xzj9zi26q4pfgplrxhi-kscreen-5.16.5/lib/qt-5.12.3/plugins/kcm_kscreen.so
/nix/store/8a3mwspiivlb6w08srjj4l4517m74f6g-kscreen-5.16.5/lib/qt-5.12.6/plugins/kcm_kscreen.so
/nix/store/djyvdkqxnj8j044lnnwvcixq15qb44k5-kscreen-5.17.5/lib/qt-5.12.6/plugins/kcms/kcm_kscreen.so
/nix/store/f5n1ybbzjrnllfiv8rvmr4z884znxkra-kscreen-5.16.5/lib/qt-5.12.6/plugins/kcm_kscreen.so
/nix/store/i7gilrkxnvmp7g0njg8bv5g9w2g6yic5-kscreen-5.14.5/lib/qt-5.12/plugins/kcm_kscreen.so
/nix/store/k7q9g6l0qd13dbqa0h35ffmwfg11apg2-kscreen-5.16.5/lib/qt-5.12.5/plugins/kcm_kscreen.so
/nix/store/nplwcwlgiw0dmh70qvakqcghvkis1nh4-kscreen-5.14.5/lib/qt-5.12/plugins/kcm_kscreen.so
/nix/store/rlm403l4qnb2y4cwfrnjvcvyga2vy5w6-kscreen-5.16.5/lib/qt-5.12.6/plugins/kcm_kscreen.so
/nix/store/wcixgs1y0xkap5am9k47jq1zjv2bqqnr-kscreen-5.16.5/lib/qt-5.12.5/plugins/kcm_kscreen.so
/nix/store/xw2avh713pa6gxpfpz4mhq8sgid5cylf-kscreen-5.14.5/lib/qt-5.12/plugins/kcm_kscreen.so
/nix/store/y34p9zp8q677qs5n26y9ax0kxba20ypj-kscreen-5.16.5/lib/qt-5.12.6/plugins/kcm_kscreen.so
/nix/store/y97p4yqkxyyc0yqlc1n2cpwcw22z4n0h-kscreen-5.14.5/lib/qt-5.12/plugins/kcm_kscreen.so
kcmshell5 and $QT_PLUGIN_PATH come from? Some of those don't even exist and nothing in my user's profile seems to add them!kcmshell5 and $QT_PLUGIN_PATH?β¦and it looks like we're actually dealing with 2 separate issues here and you were right @peterhoeg - trying to inject a correct path into QT_PLUGIN_PATHS silences the error msgs about not being able to find kcm_kscreen.so, but the rendering issues persist:
QT_PLUGIN_PATH=$(dirname $(nix eval --raw nixpkgs.kscreen)/lib/qt-5*/plugins/kcms/kcm_kscreen.so):${QT_PLUGIN_PATH} kcmshell5 kscreen
But in any case, it's a problem that plasma doesn't set this correctly and of course that we get segfaults when using the proper theme.
@peterhoeg Do you have any idea how Plasma is supposed to set this? I don't see reference to QT_QUICK_CONTROLS_STYLE in any obvious place. The segfault with the theme set is likely due to some plugin mismatch.
The segfault with the theme set is likely due to some plugin mismatch.
This part is easy: we haven't actually packaged kdeFrameworks.qqc2-desktop-style, as required by plasma-desktop and others!
It looks like we have 3 issues:
systemsettings crashes due to missing plugins, ie: incorrect QT_PLUGIN_PATH
entries in QT_PLUGIN_PATH are duplicated
$ echo $QT_PLUGIN_PATH | tr ':' "\n" | wc -l
90
$ echo $QT_PLUGIN_PATH | tr ':' "\n" | sort -u | wc -l
49
plasma-integration, our plasma-integration package doesn't use it for anything. See the wip pr.Cherry-picking the commit from #80521 and setting QT_QUICK_CONTROLS_STYLE=Plasma makes it work for me.
Why we have to set that variable, I cannot say. If somebody else can confirm that it fixes it for them, we can fix the nixos module as a workaround.
Are you sure it's #80521? Looks completely unrelated to me.
https://github.com/NixOS/nixpkgs/pull/80521 is indeed the right one.
@peterhoeg At a quick glance it looks like #80521 hasn't yet been backported to stable. Are there still plans to do so?
Backported - I guess we can close this now.
How are we supposed to get the fix? For me (on nixos-unstable), it still looks like the widgets in the original post:

With a manually-specified QT_QUICK_CONTROLS_STYLE=Plasma it applies a native widget look, but it's broken in a different way (see "Orientation"):

Am I missing something, or can we reopen this issue?
Am I missing something, or can we reopen this issue?
Same for me - re-opening for now.