Skip to content
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

buildFHSUserEnv: extend PATH and LD_LIBRARY_PATH #62040

Merged
merged 1 commit into from
May 27, 2019

Conversation

abbradar
Copy link
Member

This allows one to run applications from PATH and override libraries for
applications inside chrootenv.

Motivation for this change

Useful for development environments.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option 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)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Tested by running Steam and my local development environments.

This allows one to run applications from PATH and override libraries for
applications inside chrootenv. Useful for development environments.
@abbradar
Copy link
Member Author

I'll merge it in several days if there are no objections.

@Mic92
Copy link
Member

Mic92 commented May 25, 2019

I think it make sense to match the behavior of nix-shell here.

@abbradar
Copy link
Member Author

@Mic92 What exactly do you mean?

@Mic92
Copy link
Member

Mic92 commented May 25, 2019

I mean that a nix-shell environment would also keep PATH unmodified unless the --pure flag is used.

@abbradar
Copy link
Member Author

abbradar commented May 25, 2019 via email

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 11-100 labels May 25, 2019
Copy link
Member

@primeos primeos left a comment

Choose a reason for hiding this comment

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

LGTM, this would e.g. also make #61839 possible.

If it should be configurable we could introduce an attribute like pure ? false that can be passed to env.nix via buildFHSUserEnv (@Mic92 would that be enough?).

(Or we could do something like nix-shell does and store the original PATH to another environment variable like HOST_PATH.)

@@ -52,8 +52,8 @@ let
etcProfile = writeText "profile" ''
export PS1='${name}-chrootenv:\u@\h:\w\$ '
export LOCALE_ARCHIVE='/usr/lib/locale/locale-archive'
export LD_LIBRARY_PATH='/run/opengl-driver/lib:/run/opengl-driver-32/lib:/usr/lib:/usr/lib32'
export PATH='/run/wrappers/bin:/usr/bin:/usr/sbin'
export LD_LIBRARY_PATH="/run/opengl-driver/lib:/run/opengl-driver-32/lib:/usr/lib:/usr/lib32:$LD_LIBRARY_PATH"
Copy link
Contributor

Choose a reason for hiding this comment

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

Lose the "s.

Copy link
Member

Choose a reason for hiding this comment

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

Care to elaborate? I would keep them as they don't cause any harm (and I personally prefer quoting everything by default). While it shouldn't make a difference for Bash, there are or at least where shell where it does make a difference (IIRC).

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't really matter much, I'll merge

@infinisil infinisil merged commit b6a959b into NixOS:master May 27, 2019
@nixos-discourse
Copy link

This pull request has been mentioned on Nix community. There might be relevant details there:

https://discourse.nixos.org/t/weekly-leaderboards/2637/21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 11-100
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants