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

[Feature]: Support conda / buildFHSUserEnv #17

Closed
tbenst opened this issue Dec 12, 2019 · 3 comments
Closed

[Feature]: Support conda / buildFHSUserEnv #17

tbenst opened this issue Dec 12, 2019 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@tbenst
Copy link

tbenst commented Dec 12, 2019

Is your feature request related to a problem? Please describe.
Occasionally, I need to use conda on my NixOS box. Normally, I'd use nix-shell to enter a buildFHSUserEnv, then run VSCode. This workflow isn't possible with remote-ssh, however, and this is where nix-env-selector is fantastic.

nix-env-selector uses nix-shell --run and this is unfortunately unsupported for buildFHSUserEnv. <- also has a workaround however.

Describe the solution you'd like
I'd like to be able to use buildFHSUserEnv with nix-env-selector. A hacky solution would be to grep for "buildFHSUserEnv" in the *.nix file, and if found, to instead pass --argstr run XXX. Then, in the FHS, I could write `runScript = "bash --rcfile <(echo '. ~/.bashrc; conda activate caiman; ${run}')";

Describe alternatives you've considered
For shebang scripts, I use the workaround linked above: create an executable called conda for my conda.nix buildFHSUserEnv:

#!/usr/bin/env bash
set -euo pipefail
fhs="/Computer/shell/conda.nix"
function run {
  nix-shell --pure --argstr run "$*" "${fhs}"
}
if [[ $# -eq 0 ]]; then
  run bash
else
  run "conda $@"
fi

Then, in a python script I do (-S is for passing multiple arguments)

#!/usr/bin/env -S conda run -n caiman python
import caiman
print("hello world")

Unfortunately, I haven't succeeded in hooking in my conda wrapper with VScode's python interpreter selector.

@tbenst tbenst added the enhancement New feature or request label Dec 12, 2019
@arrterian
Copy link
Owner

@tbenst I investigated the issue briefly. Sad but we need to run some shell command as process fork from node js and I didn't find the solution with buildFHSUserEnv if you can help to get env output inside the environment by forking process it can help in another way I think we should close the issue as unresolved in this context.

@tbenst
Copy link
Author

tbenst commented Apr 28, 2020

Hi @arrterian, thanks for looking into this! I didn’t quite follow your comment, could you elaborate or point me to code? happy to help. Thanks!

@arrterian
Copy link
Owner

@tbenst
Now the extension works this way. https://github.com/arrterian/nix-env-selector/blob/master/src/helpers.ts#L22
We run env command inside nix-shell then parse the output through dotenv, then set each variable to node-process on extension host via process.env. If we can get the output from buildFHSUserEnv via forking some process I will able to implement that in extension. But I can't find a solution to how to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants