Xmind and it is running from KDE Desktop Application but it does not start from terminal / konsole

I have installed Xmind and it is running from Desktop Application but it will not start from terminal / konsole

this is my system data:
nix-channel --list
nixos nixos-24.11 release nixos-24.11.712148.edf04b75c13c

KDE Plasma version 6.2.4
KDE Frameworks Version 6.8.0
QT-Version 6.8.0
Graphics Platform Wayland

Output from configuration.nix

environment.systemPackages = with pkgs; [
(makeDesktopItem {
name = “xmind”;
exec = "${pkgs.writeShellScriptBin “xmind-wrapper” ‘’

export LD_LIBRARY_PATH=“${pkgs.glib.out}/lib:$LD_LIBRARY_PATH”

export LD_LIBRARY_PATH=“${pkgs.glib.out}/lib:${pkgs.gtk2.out}/lib:${pkgs.gdk-pixbuf.out}/lib:$LD_LIBRARY_PATH”
exec ${pkgs.xmind}/bin/XMind “$@”
‘’}/bin/xmind-wrapper";
icon = “xmind”;
desktopName = “XMind”;
genericName = “Mind Mapping”;
categories = [ “Office” ];
})

xmind
vim
wget
kitty
vlc
ddcutil
ddcui
ddccontrol
google-chrome
easyeffects
gtk2
glib
gdk-pixbuf
webkitgtk
#libgthread
lame
];

ls -l /run/current-system/sw/bin/|grep -i xmind
lrwxrwxrwx 1 root root 69 jan 1 1970 XMind → /nix/store/6hrlhh9m1qmad42lqp1x8szh52ww8klm-xmind-8-update9/bin/XMind

[iw@nixos:~/.local/share/applications]$ cat xmind.desktop
[Desktop Entry]
Categories=Office
Exec=/nix/store/vx79zlrpx770a1nkbas9vbll80qpcg8r-xmind-wrapper/bin/xmind-wrapper
GenericName=Mind Mapping
#Icon=xmind
Icon=/nix/store/381yxrh58f5hwy5frdy1x1z55mk7vcr1-system-path/share/icons/hicolor/scalable/apps/xmind.png
Name=XMind
Type=Application
Version=1.4

[iw@nixos:~/.local/share/applications]$ cat /nix/store/vx79zlrpx770a1nkbas9vbll80qpcg8r-xmind-wrapper/bin/xmind-wrapper
#!/nix/store/p6k7xp1lsfmbdd731mlglrdj2d66mr82-bash-5.2p37/bin/bash
export LD_LIBRARY_PATH=“/nix/store/26hcp8h792wl0h52c5r94qakhvk6q717-glib-2.82.1/lib:$LD_LIBRARY_PATH”
exec /nix/store/6hrlhh9m1qmad42lqp1x8szh52ww8klm-xmind-8-update9/bin/XMind “$@”

when running from terminal get this error:

XMind
XMind:
GTK+ Version Check
XMind:
An error has occurred. See the log file
/home/iw/.xmind/workspace-cathy/.metadata/.log.
and the error log:

cat /home/iw/.xmind/workspace-cathy/.metadata/.log
!SESSION 2024-12-31 16:13:28.875 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_432
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=sv_SE
Framework arguments: -eclipse.keyring @user.home/.xmind/secure_storage_linux
Command-line arguments: -os linux -ws gtk -arch x86_64 -data @user.home/.xmind/workspace-cathy -eclipse.keyring @user.home/.xmind/secure_storage_linux

!ENTRY org.eclipse.osgi 4 0 2024-12-31 16:13:31.095
!MESSAGE Application error
!STACK 1
java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
/home/iw/.xmind/configuration-cathy_linux_64/org.eclipse.osgi/4024/0/.cp/libswt-pi-gtk-4623.so: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
no swt-pi-gtk in java.library.path
/home/iw/.swt/lib/linux/x86_64/libswt-pi-gtk-4623.so: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
Can’t load library: /home/iw/.swt/lib/linux/x86_64/libswt-pi-gtk.so

    at org.eclipse.swt.internal.Library.loadLibrary(Library.java:327)
    at org.eclipse.swt.internal.Library.loadLibrary(Library.java:236)
    at org.eclipse.swt.internal.gtk.OS.<clinit>(OS.java:28)
    at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:63)
    at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:54)
    at org.eclipse.swt.widgets.Display.<clinit>(Display.java:139)
    at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:773)
    at org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:160)
    at org.xmind.cathy.internal.CathyApplication.start(CathyApplication.java:96)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1492)

You are missing some libraries that didnt get linked with the executable you are creating.

libgthread in particular i know gets stored in a different location from where nix dynamic linker expects them to be. You need to tell it where they are by hand, it wont find them automatically

Thank you very much @Mephist0phel3s for your reply.

I am not totally new to Nixos but am in a state of learning those more advanced stuff with package managing. is it defined in configuration.nix. I just grabbed a code from the web, the code below and I am not sure how to tell Nixos to use libgthread-2.0.so.0 with xmind.
I understand most of the code but am little lost on the line export LD_LIBRARY_PATH
How do you do that? Would you mind show me? Thanks!

(makeDesktopItem {
name = “xmind”;
exec = “${pkgs.writeShellScriptBin “xmind-wrapper” ‘’
export LD_LIBRARY_PATH=”${pkgs.glib.out}/lib:${pkgs.gtk2.out}/lib:${pkgs.gdk-pixbuf.out}/lib:$LD_LIBRARY_PATH"
exec ${pkgs.xmind}/bin/XMind “$@”
‘’}/bin/xmind-wrapper";
icon = “xmind”;
desktopName = “XMind”;
genericName = “Mind Mapping”;
categories = [ “Office” ];
})

I am also not an expert but am learning as you are so will do what i can.

I suggest reading Where can I get libgthread-2.0.so.0 - #7 by ryan4yin and Reddit - Dive into anything
Both are very informative on the nature of dynamic linking in nix as it can be a clusterfuck.

Typically, you’d wrap your libraries up and link them with this line:

export LD_LIBRARY_PATH=”${pkgs.glib.out}/lib:${pkgs.gtk2.out}/lib:${pkgs.gdk-pixbuf.out}/

In the future, you can use nix-index to run down libraries.
Example.
install nix-index to your sys packages and rebuild, with your normal user run the command nix-index. It will take a few to complete, when its done, run this:

nix-locate --minimal --top-level lib/libgthread-2.so.0

and it should spit out:

[jason@Beast:~]$ nix-locate --minimal --top-level lib/libgthread-2
remarkable2-toolchain.out
remarkable-toolchain.out
hyperhdr.out
glib.out

Cool, now we know we can find the library libgthread-2.so.0 in the package remarkable2-toolchain.
Go to NixOS Search to search for it and others like it, makes browsing a bit easier if you are not already familiar with this.

Now, the linker. There (annoyingly) isnt a dedicated section in the wiki to describe, instead its nested in the packaging section. Packaging/Binaries - NixOS Wiki
You are sort of creating a derivation even if its just to execute it from shell so this applies in a few ways. Notably with library linking: This is quoteds from the source mentioned just prior:

All the libraries which are not yet found are the ones we need to add to the runtime search path of the executable (RPATH). Again we can use patchelf to do this. We will be using nix-index for finding the files we are looking for:

$ # we generate the database index of all files in our channel first
$ nix-index
+ querying available packages
+ generating index: 41977 paths found :: 15957 paths not in binary cache :: 00000 paths in queue 
+ wrote index of 21,621,061 bytes
# we use the power of nix-locate to find the packages which contain the file:
$ nix-locate --minimal --top-level -w lib/libsane.so.1
saneBackends.out
$ nix-locate --minimal --top-level -w lib/libQt5Svg.so.5
remarkable2-toolchain.out
remarkable-toolchain.out
libsForQt5.qt5.qtsvg.out
onlyoffice-bin.out
$ nix-locate --minimal --top-level -w lib/libQt5PrintSupport.so.5
robo3t.out
libsForQt5.qt5.qtbase.out
$ nix-locate --minimal --top-level -w lib/libstdc++.so.6
# ...
# libsdtc++.so.6 is `special`, it resides in stdenv.cc.cc.lib (see other packages)

The next step is to create a library path for all these packages. We use nix-repl to resolve the paths:

$ nix repl '<nixpkgs>'
# .out can be omitted because this is the default output for all packages
# makeLibraryPath outputs the correct path for each package to use as rpath
nix-repl> with pkgs; lib.makeLibraryPath [ sane-backends libsForQt5.qt5.qtbase libsForQt5.qt5.qtsvg stdenv.cc.cc.lib ]
"/nix/store/7lbi3gn351j4hix3dqhis58adxbmvbxa-sane-backends-1.0.25/lib:/nix/store/0990ls1p2nnxq6605mr9lxpps8p7qvw7-qtbase-5.9.1/lib:/nix/store/qzhn2svk71886fz3a79vklps781ah0lb-qtsvg-5.9.1/lib:/nix/store/snc31f0alikhh3a835riyqhbsjm29vki-gcc-6.4.0-lib/lib"

Let’s try out the path we generated:

$ patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" --set-rpath /nix/store/7lbi3gn351j4hix3dqhis58adxbmvbxa-sane-backends-1.0.25/lib:/nix/store/0990ls1p2nnxq6605mr9lxpps8p7qvw7-qtbase-5.9.1/lib:/nix/store/qzhn2svk71886fz3a79vklps781ah0lb-qtsvg-5.9.1/lib:/nix/store/snc31f0alikhh3a835riyqhbsjm29vki-gcc-6.4.0-lib/lib   masterpdfeditor4
$ ./masterpdfeditor4
# SUCCESS!!!

You can learn much of this by reading the source of other nix derivations and flakes, its all written uniformly in nix.

So i believe it should look something like this:



    environment.systemPackages = with pkgs; [
    (makeDesktopItem {
    name = “xmind”;
    exec = "${pkgs.writeShellScriptBin “xmind-wrapper” ‘’

export LD_LIBRARY_PATH=“${pkgs.glib.out}/lib:$LD_LIBRARY_PATH”

export LD_LIBRARY_PATH=“${pkgs.glib.out}/lib:${pkgs.gtk2.out}/lib:${pkgs.gdk-pixbuf.out}/lib:$LD_LIBRARY_PATH”
let
    libPath = lib.makeLibraryPath [
      glib 
      remarkable2-toolchain
    ];
in

exec ${pkgs.xmind}/bin/XMind “$@”
‘’}/bin/xmind-wrapper";
icon = “xmind”;
desktopName = “XMind”;
genericName = “Mind Mapping”;
categories = [ “Office” ];
})

xmind
vim
wget
kitty
vlc
ddcutil
ddcui
ddccontrol
google-chrome
easyeffects
gtk2
remarkable2-toolchain
glib
gdk-pixbuf
webkitgtk
#libgthread
lame
];

EDIT to add:
more informative reading material:
https://nixos.wiki/wiki/Cheatsheet
https://nix.dev/guides/recipes/sharing-dependencies
https://nix.dev/tutorials/callpackage

Thanks @Mephist0phel3s for your effort, but I fail on this step

nix-locate --minimal --top-level lib/libgthread-2.so.0
The program ‘nix-locate’ is not in your PATH. It is provided by several packages.
You can make it available in an ephemeral shell by typing one of the following:
nix-shell -p nix-index
nix-shell -p nix-index-unwrapped

nix-shell -p nix-index
this derivation will be built:
/nix/store/knp93gcjfpmv91f2ps7lq0ab4m36iin7-nix-index-0.1.8.drv
building ‘/nix/store/knp93gcjfpmv91f2ps7lq0ab4m36iin7-nix-index-0.1.8.drv’…

nix-locate --minimal --top-level lib/libgthread-2.so.0
error: reading from the database at ‘/home/iw/.cache/nix-index/files’ failed.
This may be caused by a corrupt or missing database, try (re)running nix-index to generate the database.
If the error persists please file a bug report at GitHub - nix-community/nix-index: Quickly locate nix packages with specific files [maintainers=@bennofs @figsoda @raitobezarius].
caused by: No such file or directory (os error 2)

and when I try to run nix-index the system freezes every time, so I guess something is corrupt and I may accept I need to reinstall my system to fix it

You skipped a step.

You need to install nix-index to your sys packages in config and rebuild.

Then, as a normal user, init the index by running nix-index. It will take a few minutes to finish. Let it finish.

Then try nix-locate --minimal --top-level lib/libgthread-2.so.0

Thanks but the system frooze, but I suspect that could be my NIX_PATH is not including my user
I am running this as my current user
echo $NIX_PATH
nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels

So I try to figure out how to set it properly

I guess I have overlooked that simple solution to set it in .bashrc.

Could it be that simple?

If the system completely froze that indicates another problem. Post your dmesg and journal logs

This is the journalctl

journalctl
okt 30 22:00:43 nixos kernel: microcode: updated early: 0x20 → 0x21, date = 2019-02-13
okt 30 22:00:43 nixos kernel: Linux version 6.6.40 (nixbld@localhost) (gcc (GCC) 13.2.0, GNU ld (GNU Binutils) 2.4>
okt 30 22:00:43 nixos kernel: Command line: BOOT_IMAGE=(hd0,msdos1)/nix/store/dad83vylfxq8y7xdvcsgicy59yzfp8k2-lin>
okt 30 22:00:43 nixos kernel: BIOS-provided physical RAM map:
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x0000000000000000-0x000000000009d7ff] usable
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x000000000009d800-0x000000000009ffff] reserved
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x00000000000e0000-0x00000000000fffff] reserved
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x0000000000100000-0x000000001fffffff] usable
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x0000000020000000-0x00000000201fffff] reserved
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x0000000020200000-0x0000000040003fff] usable
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x0000000040004000-0x0000000040004fff] reserved
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x0000000040005000-0x00000000da174fff] usable
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x00000000da175000-0x00000000da621fff] reserved
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x00000000da622000-0x00000000da63bfff] ACPI data
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x00000000da63c000-0x00000000dc608fff] ACPI NVS
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x00000000dc609000-0x00000000dc7d1fff] reserved
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x00000000dc7d2000-0x00000000dc7d2fff] usable
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x00000000dc7d3000-0x00000000dc815fff] ACPI NVS
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x00000000dc816000-0x00000000dcffffff] usable
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x00000000dd000000-0x00000000df9fffff] reserved
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x00000000f8000000-0x00000000fbffffff] reserved
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x00000000fec00000-0x00000000fec00fff] reserved
okt 30 22:00:43 nixos kernel: BIOS-e820: [mem 0x00000000fed00000-0x00000000fed03fff] reserved

dmesg was pretty long is it something I can grep from it?

#Thanks for all help! Can still not run nix-index because system freezes but the main problem solved by first running wrapper script in configuration.nix and then adding a symlink from it to home dir of user

Step 1
¤¤¤ /etc/nixos/configuration.nix ¤¤¤

List packages installed in system profile. To search, run:

$ nix search wget

environment.systemPackages = with pkgs; [

(makeDesktopItem {
name = “xmind”;
exec = “${pkgs.writeShellScriptBin “xmind-wrapper” ‘’
export LD_LIBRARY_PATH=”${pkgs.glib.out}/lib:$LD_LIBRARY_PATH"
exec ${pkgs.xmind}/bin/XMind “$@”
‘’}/bin/xmind-wrapper";
icon = “xmind”;
desktopName = “XMind”;
genericName = “Mind Mapping”;
categories = [ “Office” ];
})
#xmind

other necessary dependencies

gtk2
gtk3
glib

gdk-pixbuf

nix-index
vim
wget
kitty
vlc
ddcutil
ddcui
ddccontrol
google-chrome
easyeffects
#gdk-pixbuf
#webkitgtk
#libgthread
lame
jdk8
jre8
];

Step 2
#symlink to run xmind from command line

[iw@nixos:~/.local/bin]$ ls -l
total 4
lrwxrwxrwx 1 root root 75 jan 4 14:07 xmind → /nix/store/vx79zlrpx770a1nkbas9vbll80qpcg8r-xmind-wrapper/bin/xmind-wrapper

#Link to icon on Desktop

ls -l Xmind.desktop
lrwxrwxrwx 1 jk users 88 jan 4 16:04 Xmind.desktop → /nix/store/5d489fk8lrpskkdg4baz90bz3b7lnhxl-system-path/share/applications/xmind.desktop

#Path to wrapper script for xmind
cat /nix/store/5d489fk8lrpskkdg4baz90bz3b7lnhxl-system-path/share/applications/xmind.desktop
[Desktop Entry]
Categories=Office
Exec=/nix/store/vx79zlrpx770a1nkbas9vbll80qpcg8r-xmind-wrapper/bin/xmind-wrapper
GenericName=Mind Mapping
Icon=xmind
Name=XMind
Type=Application
Version=1.4