-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
zsh: move sessionVariables from .zshrc to .zshenv #2708
zsh: move sessionVariables from .zshrc to .zshenv #2708
Conversation
96e35e0
to
0808d32
Compare
This patch moves both home.sessionVariables and programs.zsh.sessionVariables from .zshrc to .zshenv. Additionally, these two kinds of session variables will not be sourced more than once to allow user-customized ones to take effect. Before, session variables are in .zshrc, which causes non-interactive shells to not be able to get those variables. For example, running a command through SSH is in a non-interactive and non-login shell, which suffers from this. With this patch, all kinds of shells can get session variables. The reason why these session variables are not moved to .zprofile is that programs started by systemd user instances are not able to get variables defined in that file. For example, GNOME Terminal (gnome-terminal-server.service) is one of these programs and doesn't get variables defined in .zprofile. As a result, the shells it starts, which are interactive and non-login, do not get those variables. Fixes nix-community#2445 Related NixOS/nixpkgs#33219 Related NixOS/nixpkgs#45784
0808d32
to
8fd901a
Compare
fixed test |
cc @berbiche as you recently merged several PRs related to zsh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me. I will test this in my config.
I believe that this is busted because it re-uses the same environment variable name as See from the code that generates home-manager/modules/home-environment.nix Lines 547 to 548 in 69536af
and the code that this puts into home-manager/modules/programs/zsh.nix Lines 447 to 454 in 69536af
When |
Never mind! I need to check my eyes! 👓 However! It does seem to be broken for some reason, as my prompt is no longer getting set... I'll post again if I find the real root cause |
Alrighty. It looks like the actual culprit was the prompt init code in That, coupled with the fact that our variables were previously getting sourced after that by virtue of being From the zsh man page:
In the very short term, I've updated my system config to remove |
@clhodapp |
this breaks my setup as i have an existing |
@NorthIsUp you could move your .zshenv to another file and source it: |
Description
This patch moves both home.sessionVariables and
programs.zsh.sessionVariables from .zshrc to .zshenv. Additionally,
these two kinds of session variables will not be sourced more than
once to allow user-customized ones to take effect.
Before, session variables are in .zshrc, which causes non-interactive
shells to not be able to get those variables. For example, running a
command through SSH is in a non-interactive and non-login shell, which
suffers from this. With this patch, all kinds of shells can get
session variables.
The reason why these session variables are not moved to .zprofile is
that programs started by systemd user instances are not able to get
variables defined in that file. For example, GNOME
Terminal (gnome-terminal-server.service) is one of these programs and
doesn't get variables defined in .zprofile. As a result, the shells it
starts, which are interactive and non-login, do not get those
variables.
Fixes #2445
Related NixOS/nixpkgs#33219
Related NixOS/nixpkgs#45784
This file is not formatted before and is excluded by ./format, so I don't format it.
Checklist
Change is backwards compatible.
Code formatted with
./format
.Code tested through
nix-shell --pure tests -A run.all
.Test cases updated/added. See example.
Commit messages are formatted like
See CONTRIBUTING for more information and recent commit messages for examples.
If this PR adds a new module
Added myself as module maintainer. See example.
Added myself and the module files to
.github/CODEOWNERS
.