-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
home.sessionVariables
has no effect when using a graphical desktop environment
#1011
Comments
I have the same problem. Adding the
snippet to my home manager config however does not work with gnome. When i do |
Completely untested, but you might try |
I'm using this to address the issue, works like a charm:
|
cool this worked for me. But I have to note that I autostart my window manager Sway also with this command:
|
@mammothbane unfortunately does seem to be ignored by gnome. I am currently setting env vars that shell also be available in gnome shells like this: programs.bash.bashrcExtra = ''
SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh"
''; i don't like it, but i also don't want to change anything in /etc/nixos/configuration.nix to make this work, as this would break my session vars for all the systems i have no root access to. |
Could home-manager set systemd.sessionVariables with home.sessionVariables by default? |
The right way to fix this is to wrap apps which need the socket, since giving an env var to an application that shoundnt use it is both wasteful and incorrect. This is why gnome stopped sourcing profile's, and is the way forward. Li's plan is to use systemd units to launch all apps. Gnome devs have been discussing this also. |
I looked into the source of the zsh and bash nix expression respectivly and noticed that both of them are just sourceing the session variables incorrectly: They are sourcing them in the .zshrc/.bashrc, which only affects the actual shells. In order to have them more globally I'd suggest sourcing them in .bash_profile/.xprofile/.zsh_env respectivly. |
Thank you for your contribution! I marked this issue as stale due to inactivity. If this remains inactive for another 7 days, I will close this issue. Please read the relevant sections below before commenting. If you are the original author of the issue
If you are not the original author of the issue
Memorandum on closing issuesIf you have nothing of substance to add, please refrain from commenting and allow the bot close the issue. Also, don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen--nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort. |
Hello here is my snippet programs.bash = {
enable = true;
sessionVariables = {
VAGRANT_DEFAULT_PROVIDER="libvirt";
TERM="xterm-256color";
};
}; should we depreciate this option in favor of Edit: home.sessionVariables = {
VAGRANT_DEFAULT_PROVIDER="libvirt";
TERM="xterm-256color";
};
systemd.user.sessionVariables = {
VAGRANT_DEFAULT_PROVIDER="libvirt";
TERM="xterm-256color";
}; to have something working i had to update my bash as follows programs.bash = {
enable = true;
bashrcExtra = ''
export VAGRANT_DEFAULT_PROVIDER="libvirt";
export TERM="xterm-256color";
'';
}; |
cc @rycee I think the variables in As for |
@berbiche Yeah, that's right. Except that
X login sessions should load this file and introduce the variables. People who don't want HM to manage the X session can manually put that line in their |
Thank you for your contribution! I marked this issue as stale due to inactivity. If this remains inactive for another 7 days, I will close this issue. Please read the relevant sections below before commenting. If you are the original author of the issue
If you are not the original author of the issue
Memorandum on closing issuesIf you have nothing of substance to add, please refrain from commenting and allow the bot close the issue. Also, don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen--nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort. |
Any word if |
AFAIK no. The Home Manager generated .xprofile file is not sourced by any Wayland display managers, including Gnome. |
Does it make sense to open something new for that scenario? Maybe I will later if no one protests or points me in a better direction. |
Please do :) |
This has been fixed in NixOS with NixOS/nixpkgs#185987. We now source |
@kira-bruneau So |
@auroraanna I have the same problem.
|
I don't think this should be closed. I use KDE Wayland, SDDM, and Zsh and my Following https://userbase.kde.org/Session_Environment_Variables I've added the following to my configuration: { config, ... }: {
xdg.configFile."plasma-workspace/env/hm-session-vars.sh".text = ''
. "${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh"
'';
} This fixes I'm not sure if this is a bug with KDE, SDDM, or with how NixOS packages them seeing that I've read in several places that SDDM and maybe even KDE should source files like .zprofile and .zshenv. https://wiki.archlinux.org/title/environment_variables#Per_Wayland_session
|
oh, does that only work in Xorg sessions? That would explain why it's still not working for me. I'm using Wayland. |
@dacioromero solution is a great step forward but still has a caveat - whatever is defined in Here is why:
At this stage I wouldn't put interactive shell related stuff in |
SDDM was updated to 0.20.0 and is in nixos-unstable NixOS/nixpkgs#239389 and it seems to source my .zshenv so I don't need my workaround. It'll probably have the same caveat that @haizaar pointed out though. |
The following worked for me:
|
GNOME Wayland actually hasn’t stopped sourcing the login shell environment. I can’t speak for other environments, but
Indeed, this means |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/home-manager-sessionvariables-not-persisted-after-log-out/55021/2 |
At the time of writing, the contents
home.sessionVariables
are placed in~/.profile
.As I use KDE Plasma, these variables never get loaded for me because:
/etc/profile
on NixOS 19.09 does not source~/.profile
~/.profile
~/.bash_profile
or~/.profile
, but~/.bashrc
instead)For example, if I set:
I get:
My
~/.profile
,~/.bash_profile
, and~/.bashrc
files are all managed by home-manager and their contents are as follows:To make matters worse, it seems that NixOS doesn't make an authoritative decision about whether
~/.profile
(or actually, whether any other file) will be reliably sourced at login when using a graphical environment (NixOS/nixpkgs#5200)If I log in via the console or via SSH however, this does count as a bash login shell and my environment variables are set correctly.
For now my current workaround is to put the following in my system's
/etc/nixos/configuration.nix
which applies a workaround at the system level:but I could just as easily put the following in my
home.nix
:I also think I could get around this by putting
xsession.enable = true;
in myhome.nix
which would add the necessaryif [ -e $HOME/.profile ] ...
code to my~/.xprofile
.Any comments or suggested solutions to this quirk between home-manager and NixOS, or anything in the documentation I have missed?
The text was updated successfully, but these errors were encountered: