-
-
Notifications
You must be signed in to change notification settings - Fork 29
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] Pick up nix environment in tasks #55
Comments
Hi @bcardiff the extension doesn't affect tasks for now :( |
What might be an entry point to solve this is the configuration option In the meanwhile, the following {
"label": "make",
"type": "shell",
"linux": {
"options": {
"shell": {
"executable": "/run/current-system/sw/bin/nix-shell",
"args": [
"--run",
],
},
},
},
"command": "make",
}, The VSCode Team seems to focus on terminal profiles. Once these are referencable within tasks, a corresponding task template could be provided by this extension. |
This is a huge pain esp. when dealing with non-
|
Is there any new workaround for this since the referenced issue has been closed? |
Here's an almost transparent workaround: In {
"terminal.integrated.automationProfile.linux": {
"path": "${workspaceRoot}/.vscode/nix-shell-or-bash.sh",
"env": {
"PROJ_DIR": "${workspaceRoot}"
}
}
} Then, in #!/bin/sh
echo $PROJ_DIR
shift # ignore the initial -c added by VS Code
# The condition may be wrong because I'm not sure if Nix (!= NixOS) users have this file
if [ -e /run/current-system/sw/bin/nix-shell ]; then
# A nix-shell is a available
if [ -e "$PROJ_DIR/.envrc" ]; then
# Use direnv (usually faster than nix-shell)
direnv exec $PROJ_DIR $@
else # TODO you could add an elif for a flake.nix file and launch nix develop instead
# Use nix-shell
nix-shell --run "$@"
fi
else
# For people not using NixOS
bash -c "$@"
fi |
Describe the bug
I attempted a minimalist example to run the hello program provided by nix from a task and the task is not found after loading / hitting the environment. I'm probably doing something wrong here, but if I load the nix environment before opening vscode from the same terminal things work. Thanks in advance.
To Reproduce
Steps to reproduce the behavior:
The output in the terminal shows that it can't find hello
Expected behavior
The following is the expected output, but I can only get it if vscode is started from a terminal with the nix environment loaded already. Which is precisely what I am looking to not do with this extension.
Environment:
The text was updated successfully, but these errors were encountered: