home-manager icon indicating copy to clipboard operation
home-manager copied to clipboard

home-environment: Stop exporting __HM_SESS_VARS_SOURCED

Open wahjava opened this issue 2 years ago • 4 comments

Description

If the __HM_SESS_VARS_SOURCED is set in environment of parent process, then the spawned child shell will inherit it, and won't set the session variables one expects to be set in their home environment

And, I don't see any need for exporting environment variable, just setting it is enough for it to be a guard.

P.S. This is essentially a re-open of #2328 which I messed up.

Checklist

  • [x] Change is backwards compatible.

  • [x] Code formatted with ./format.

  • [x] Code tested through nix-shell --pure tests -A run.all.

  • [x] Test cases updated/added. See example.

  • [x] Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    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.

wahjava avatar Apr 30 '22 03:04 wahjava

If I understand correctly, if the environment (home.sessionVariables, etc.) is changed after it has been loaded (for instance before starting your window manager) then new shells won't see the new environment variables?

berbiche avatar May 05 '22 22:05 berbiche

If I understand correctly, if the environment (home.sessionVariables, etc.) is changed after it has been loaded (for instance before starting your window manager) then new shells won't see the new environment variables?

Exactly

wahjava avatar May 06 '22 03:05 wahjava

Hey, any progress on this PR? I've encountered this issue myself and this would be the solution. What's stopping this from being merged?

subterfugue avatar Jun 01 '22 06:06 subterfugue

Thank you for your contribution! I marked this pull request as stale due to inactivity. Please read the relevant sections below before commenting.

If you are the original author of the PR

  • GitHub sometimes doesn't notify people who commented / reviewed a PR previously when you (force) push commits. If you have addressed the reviews you can officially ask for a review from those who commented to you or anyone else.
  • If it is unfinished but you plan to finish it, please mark it as a draft.
  • If you don't expect to work on it any time soon, please consider closing it with a short comment encouraging someone else to pick up your work.
  • To get things rolling again, rebase the PR against the target branch and address valid comments.
If you are not the original author of the PR

  • If you want to pick up the work on this PR, please create a new PR and indicate that it supercedes and closes this PR.

stale[bot] avatar Aug 31 '22 01:08 stale[bot]

Won't this introduce duplicated entries in PATH-like variables? I think this might be a problem?

ncfavier avatar Jan 08 '23 16:01 ncfavier

Won't this introduce duplicated entries in PATH-like variables? I think this might be a problem?

I've been using it for an year on multiple systems, and haven't experienced what you're pointing. Could you please elaborate why/how that may happen ?

Thanks

wahjava avatar Jan 08 '23 17:01 wahjava

Things like export PATH=foo:$PATH will result in duplicated foo entries in nested shells. I don't know if this is a problem.

ncfavier avatar Jan 08 '23 17:01 ncfavier

Things like export PATH=foo:$PATH will result in duplicated foo entries in nested shells. I don't know if this is a problem.

Well, I've not noticed it in practice, it did make switching home-manager profiles more deterministic for me when I was experimenting with session variables. And yes, I'd noticed NixOS uses similar concept (environment variable).

wahjava avatar Jan 08 '23 17:01 wahjava

Thank you for your contribution! I marked this pull request as stale due to inactivity. Please read the relevant sections below before commenting.

If you are the original author of the PR

  • GitHub sometimes doesn't notify people who commented / reviewed a PR previously when you (force) push commits. If you have addressed the reviews you can officially ask for a review from those who commented to you or anyone else.
  • If it is unfinished but you plan to finish it, please mark it as a draft.
  • If you don't expect to work on it any time soon, please consider closing it with a short comment encouraging someone else to pick up your work.
  • To get things rolling again, rebase the PR against the target branch and address valid comments.
If you are not the original author of the PR

  • If you want to pick up the work on this PR, please create a new PR and indicate that it supercedes and closes this PR.

stale[bot] avatar Apr 08 '23 20:04 stale[bot]

Thank you for your contribution! I marked this pull request as stale due to inactivity. Please read the relevant sections below before commenting.

If you are the original author of the PR

  • GitHub sometimes doesn't notify people who commented / reviewed a PR previously when you (force) push commits. If you have addressed the reviews you can officially ask for a review from those who commented to you or anyone else.
  • If it is unfinished but you plan to finish it, please mark it as a draft.
  • If you don't expect to work on it any time soon, please consider closing it with a short comment encouraging someone else to pick up your work.
  • To get things rolling again, rebase the PR against the target branch and address valid comments.
If you are not the original author of the PR

  • If you want to pick up the work on this PR, please create a new PR and indicate that it supercedes and closes this PR.

stale[bot] avatar Apr 13 '24 11:04 stale[bot]