Skip to content

nixos: inline set-environment for bash and zsh - #30418

Merged
LnL7 merged 1 commit into
NixOS:masterfrom
LnL7:inline-set-environment
Mar 8, 2018
Merged

LnL7 merged 1 commit into
NixOS:masterfrom
LnL7:inline-set-environment

Conversation

@LnL7

@LnL7 LnL7 commented Oct 14, 2017

Copy link
Copy Markdown
Member
Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Fits CONTRIBUTING.md.

@LnL7 LnL7 added the 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS label Oct 14, 2017
@orivej

orivej commented Nov 6, 2017

Copy link
Copy Markdown
Contributor

What is this good for?

@lukateras

lukateras commented Nov 8, 2017 •

Copy link
Copy Markdown
Member

@orivej I'd guess one file less to read.

@orivej

orivej commented Nov 8, 2017

Copy link
Copy Markdown
Contributor

That does not sound impressive.

@LnL7

LnL7 commented Nov 8, 2017 •

Copy link
Copy Markdown
Member Author

Just for simplicity, I've seen some people on irc having trouble figuring out where environment variables like NIX_PATH come from because they where searching in /etc or /run/current-system.

@orivej orivej left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's reasonable.

@LnL7
LnL7 merged commit db6fb86 into NixOS:master Mar 8, 2018
@LnL7
LnL7 deleted the inline-set-environment branch March 8, 2018 20:07
oxij pushed a commit to oxij/nixpkgs that referenced this pull request Aug 30, 2018
A shared exported guard `__NIXOS_SET_ENVIRONMENT_DONE` is introduced that can
be used to prevent child shells from sourcing `system.build.setEnvironment`
the second time.

This fixes e.g. `nix run derivation` when run from e.g. ZSH through the console or
ssh. Before this Bash would resource the common environment resetting the `PATH`
environment variable.

We also export `system.build.setEnvironment` to `/etc/set-environment` making it
easy to reset the common environment with `. /etc/set-environment` when
needed and to grep for environment variables in `/etc` (which was the
motivation of NixOS#30418).

This reverts changes made in b00a3fc
(the original NixOS#30418).
@oxij

oxij commented Aug 30, 2018

Copy link
Copy Markdown
Member

Follow up: #45784.

xeji pushed a commit that referenced this pull request Sep 6, 2018
A shared exported guard `__NIXOS_SET_ENVIRONMENT_DONE` is introduced that can
be used to prevent child shells from sourcing `system.build.setEnvironment`
the second time.

This fixes e.g. `nix run derivation` when run from e.g. ZSH through the console or
ssh. Before this Bash would resource the common environment resetting the `PATH`
environment variable.

We also export `system.build.setEnvironment` to `/etc/set-environment` making it
easy to reset the common environment with `. /etc/set-environment` when
needed and to grep for environment variables in `/etc` (which was the
motivation of #30418).

This reverts changes made in b00a3fc
(the original #30418).

(cherry picked from commit d273db4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants