How can I append a path to my PATH with home-manager for new shells using home.sessionPath without needing reboot?

home = {
  sessionPath = [

This seems to work when restarting, but not when launching new shells.

I see that it ends up in .profile

$cat .profile
. "/home/b0ef/.nix-profile/etc/profile.d/"

…and that contains

$ cat .nix-profile/etc/profile.d/
# Only source this once.
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi

export PATH="$PATH${PATH:+:}/home/b0ef/.foo/bar"

, but I want it to append my PATH for new shells, not needing to reboot.

1 Like

ok, so the issue is that sessionPath is a Session variable, that only gets read when you start a new Xorg session.

That’s problematic.

Then I don’t understand how we can modify the PATH without restarting Xorg?

I just want my PATH to update for a new invocation of bash, like .bashrc, I assume.

There are quite a few threads on this, but I understand none of them;)

Is there some consensus on how this should be done?

I could be wrong, but anything you set in home.sessionVariables get set when you start a new shell.

All the shells also have some manual extraConfig or extraInit attribute you can set, which should definitely work.

No, I think you’re wrong about home.sessionVariables. I think the naming session is a dead giveaway, in that it’s set once per session, meaning Xorg session. I’m not sure where we could find a definition?

I envision hacking together something like export path=path+the new path, but I haven’t found a single example where it’s done this way. That’s why I find it strange.

I mean, all I’m trying to do, is add to my PATH and I can’t find a single example of how it’s done;) (bar session variable which requires restart)

Oh, that’s right! I guess when you think about it, I am not sure how your entire system would magically get the variable unless you re-logged in. Here is a good thread on the topic:

It seems like here they settled on setting it through their shell, which is more or less syntatic sugar for extraConfig/Init

So zsh/bash.sessionVariables is probably what you want here. These variables get set for every new shell.

To be clear, I ended up adding it to my home.nix (second suggestion).