Comments (5)
Here's an almost transparent workaround:
In .vscode/settings.json
:
{
"terminal.integrated.automationProfile.linux": {
"path": "${workspaceRoot}/.vscode/nix-shell-or-bash.sh",
"env": {
"PROJ_DIR": "${workspaceRoot}"
}
}
}
Then, in .vscode/nix-shell-or-bash.sh
(don't forget to chmod +x
the file!)
#!/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
from nix-env-selector.
Hi @bcardiff the extension doesn't affect tasks for now :(
from nix-env-selector.
What might be an entry point to solve this is the configuration option terminal.integrated.automationShell.linux
. But nix-shell is not a POSIX compliant shell i.e. it does not handle -c
well. Furthermore is it not possible to specify additional arguments to vscode to handle this. Obviously one can resort to a wrapper, that filters the -c
switch and then set this wrapper as the automation shell.
In the meanwhile, the following tasks.json
snippet works without this extension.
CAUTION: This snippets assumes, that the nix expression file is called either shell.nix
or default.nix
:
{
"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.
from nix-env-selector.
This is a huge pain esp. when dealing with non-type: "shell"
tasks. Eg for vscode extension development, the main launch command looks like:
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}",
},
from nix-env-selector.
Is there any new workaround for this since the referenced issue has been closed?
from nix-env-selector.
Related Issues (20)
- Have the extension output logs in the Output window HOT 4
- Can't make my fhs env work HOT 1
- shell.nix exetubables don't seem to be made available after selecting shell.nix HOT 1
- [Feature]: Support shell.nix files outside of the project directory
- [BUG] Extension don't add package to PATH variable, when some active tabs need any package from shell.nix HOT 4
- "command 'nixEnvSelector.selectEnv' not found" HOT 1
- [Feature]: Support multiroot workspace HOT 2
- C/C++ Support: Can this be used to help generate the c_cpp_properties.json configuration file?
- [Documentation]: Document what `Hit environment` means
- [Feature]: Remember nix environment answer
- [Feature]: VSCode-Remote (SSH) support? HOT 6
- No longer applies shell.nix to integrated terminal? HOT 2
- Extension Development Host does not launch
- Can find packages from nix-shell, but not with nix-env-selector HOT 3
- TypeError when applying nix environment in Remote SSH HOT 3
- [Feature]: VSCodium support HOT 1
- Latest Pylance update brakes python environment HOT 1
- nix-env-selector does not work with flakes HOT 7
- rust-analyzer can't detect environment variables HOT 1
- Remote/SSH developement with flakes not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nix-env-selector.