Hi.
I’m trying to create application shortcuts / .desktop
files for some scripts I wrote (example: firefox-rnd
, starts firefox in a random profile). The scripts are in $HOME/bin
which is in my PATH when I’m in the console. However, that directory isn’t in PATH when started in a .desktop
file.
test.desktop
[Desktop Entry]
Comment=
Exec=firefox-rnd
GenericName=
Icon=system-run
MimeType=
Name=Firefox Random
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=
Goal
Parity with OpenSuse and Ubuntu (which I had before and just switched from). That means, I just want to have Exec=firefox-rnd
or whatever program I want to run.
Path=path/to/firefox-rnd/directory
was not necessary in other distros and shouldn’t be necessary in nixos.
home-manager
is not an option either. I’m very new to nixos and the warning on the repo is very offputting (basically understand nix
or you might lose data aka my entire $HOME).
Ugly workaround
Use bash --login -c "firefox-rnd"
. Then the PATH is correct.
Question
How do I start my KDE session with the correct PATH (as in bash) on nixOS (just as I had it on other distributions)?
Maybe you’re looking for environment.homeBinInPath
?
I did that, but promptly discovered that lots of other env vars are missing. For my python script for example PYTHONPATH
is missing in order to find the installed python modules.
It looks like the environment variables are set by PAM (Pluggable Authentication Modules), more specifically pam_env
. environment.homeBinInPath
just adds $HOME/bin
to environment.sessionVariables
which end up in /etc/set-environment
and /etc/pam/environment
. That however doesn’t help me much because all the other env vars that are in my ~/.profile
aren’t being set. Transfering all that to /etc/nixos/configuration.nix
seems like overkill.
I’m not sure why it works on OpenSuse and Ubuntu, but not on NixOS. Is there no way to source ~/.profile
when logging in with SDDM (it starts the KDE session) and/or PAM?
Edit: Ubuntu has documentation stating that ~/.profile
is read by the display manager, but not how. Would be nice if that could be reproduced in NixOS. I might have to boot up Ubuntu in a VM to see how they do it, but if someone knows and wants to spare me the hassle, please do share.
NixOS does modify SDDM to just start a login shell instead of sourcing ~/.profile
itself, so you might look into what the shell is doing, e.g. if you’re using Bash is it stopping at ~/.bash_profile
.
Thanks @_Andrew , I finally found it. Undocumented and non-standard: $HOME/.xprofile
which is sourced by xsession-wrapper. I created a new issue to address this, because probably I’m not the first and won’t be the last to be frustrated by this situation.
Would’ve had to search way longer without your comments.
Until the issue is resolved, I’ll mark my comment as the solution:
put this into your .xprofile
:
source $HOME/.profile
Cheers
2 Likes