home = {
sessionPath = [ "~/.emacs.d/bin" ];
sessionVariables = {
EDITOR = "emacs";
};
};
# SessionPath and sessionVariables creates a hm-session file that must be sourced:
# Beware, it puts it in .profile, not in the .bashrc!
programs.bash = {
enable = true;
};
Then the hm-session-vars file is included in .profile (which is just run once when your graphical interface first starts). So either you can source .profile every bash, or you ask bash to source that file for you. I just do that by replacing the above bash configuration with:
I tried this (except I used “kak” instead of “vim”), but it isn’t working for me. After home-manager switch, restarting the terminal and even a reboot, I still get this:
echo $EDITOR
nano
I don’t even know where nano is being set as my editor. I can’t find a statement in home.nix nor configuration.nix.
EDITOR environment variable is defined as nano by default on NixOS:
Also, did you read this entry on HM FAQ? If your current shell is not provided by HM, you need to explicitly source a file for HM session variables to take effect.
That link seems to contradict itself and say the opposite of what you are saying.
First it says: Home Manager is only able to set session variables automatically if it manages your Bash, Z shell, or fish shell configuration.
Then it says: If you don’t want to let Home Manager manage your shell then you will have to manually source the ~/.nix-profile/etc/profile.d/hm-session-vars.sh file in an appropriate way.
I DO want to let Home Manager manage my shell, so therefore I don’t have to manually source that file.
But it doesn’t say that I must do something different to let HM manage my shell. That would seem to imply that I don’t need to do anything, that HM automatically manages my shell.
home.sessionVariables are defined in a file named hm-session-vars.sh. If you are in a shell provided by a HM module, this file is already sourced (They are also explicitly sourcing it but it is hidden to the user.). If you are not using a shell provided by a HM module (e.g. shell provided by NixOS) or writing your own HM module for a shell, then you need to source that file yourself to have those sessions variables defined.
One more person here with similar problems. I’ve set variables in home.sessionVariables, programs.bash.sessionVariables, and systemd.user.sessionVariables and nothing is set once I log in. Using SDDM → i3.
The strange thing is that things like GDK_SCALE etc seem to be having an effect on the UI, so they are being loaded at some point, but then they disappear. bemenu doesn’t recognize PATH updates, and terminals don’t see any of the variables that have been set.
UPDATE: It’s not clear that GDK_SCALE is being used.
UPDATE2: So it looks like the .profile file written by home-manager’s bash module is not executable, and is also owned by root. It’s put into $HOME with a chain of a couple symbolic links which obfuscates this, but this is clearly the reason it’s not working for me at least. Not sure if I’m doing something strange of if this is broken in the unstable channel.