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

androidStudioPackages: prefix PATH rather than replacing #61839

Merged
merged 1 commit into from May 27, 2019

Conversation

tadfisher
Copy link
Contributor

Motivation for this change

A couple of issues exist regarding Android Studio not being able to run binaries on the user's PATH:

This occurs because studio.sh is wrapped with a hardcoded PATH. It's not really feasible to predict every possible binary Android Studio can run, due to build scripts and plugins, but we can at least propagate the user's PATH through studio.sh so that binaries can be found without explicitly overriding the derivation.

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.

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.

This is a good idea, thanks for the PR.

Unfortunately the current solution doesn't work because $PATH is set to /run/wrappers/bin:/usr/bin:/usr/sbin before the wrapper for Android Studio will be called (see #29513 (comment) and pkgs/build-support/build-fhs-userenv/env.nix). You can e.g. verify this with the built-in terminal.

But what we could do is something like this (#29513 (comment)):

We could e.g. append /home/xyz/.nix-profile/bin ($HOME is set) and/or /run/current-system/sw/bin but AFAIK we can't keep the original $PATH without modifying buildFHSUserEnv.

The default $PATH on NixOS looks like this:

[michael@quorra:~]$ less /nix/store/62rf4xzq9slkc37g72hvvpxywhj9c83q-set-environment | grep " PATH="
export PATH="$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/etc/profiles/per-user/$USER/bin"
export PATH="/run/wrappers/bin:$PATH"
export PATH="$HOME/bin:$PATH"

Which we could replicate but then it wouldn't work on non-NixOS systems.

To make it work reasonably on both NixOS and non-NixOS systems it might make sense to append something like this to $PATH:
/home/$USER/.nix-profile/bin:/run/current-system/sw/bin:/usr/local/bin:/usr/bin:/bin

To cover the most important paths (note: maybe also /nix/var/nix/profiles/default/bin and/or /etc/profiles/per-user/$USER/bin - I haven't looked into that).

@tadfisher
Copy link
Contributor Author

I see. I'm using this with the passthru.wrapper derivation because I install the Android SDK components separately from Studio, so I have no need for the FHS environment.

Perhaps an interim solution could be an extraPaths parameter for the FHS env, in addition to this fix? I would really enjoy continuing to avoid the FHS environment, personally.

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.

Sorry for my delayed response.

Fortunately there was another PR (#62040) in the meantime which modifies buildFHSUserEnv in the same way and is merged now :)

This means that it will now also work with buildFHSUserEnv and there is no reason not to merge it 🎉. Thanks again for the PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants