Comments (12)
Yes! This would be awesome! I just moved all my projects over to flakes, but this has been holding me back...
from nix-env-selector.
For another workaround, consider using nix-direnv and its appropriate vscode extension too - it seems to work with use flake
for me.
from nix-env-selector.
If anyone is looking for a workaround: https://github.com/srid/haskell-template uses flake-compat
to provide a shell.nix
that in turn uses flake.nix
(as well as flake.lock
). All of that can go away if this issue gets implemented. Using direnv is another option.
EDIT: It no longer uses flake-compat, and shell.nix
simply contains: (builtins.getFlake ("git+file://" + toString ./.)).devShells.${builtins.currentSystem}.default
from nix-env-selector.
@arrterian I'd happily sponsor work that would result in this being implemented, do you think that could be arranged?
from nix-env-selector.
This one's being maintained actively: https://marketplace.visualstudio.com/items?itemName=mkhl.direnv
from nix-env-selector.
It works already if you create the shell.nix
file and you select shell.nix
with the Nix Env: Select Environment command.
from nix-env-selector.
What would be needed for this?
Some notes:
Implementation wise, for covering nix develop
I'd estimate the main work would be in src/main/ext/nix_env.cljs
. https://github.com/arrterian/nix-env-selector/blob/472c4c4211f13f74ea27418e1ec30a706b809e5f/src/main/ext/nix_env.cljs, the actions.cljs then uses env/get-nix-env-async
and env/set-current-env
.
This file seems to roughly take the output of nix-shell --run "export"
, and parses the various declare -x name="nix-shell"
.
The nix flake equivalent nix develop
at least provides nix print-dev-env --json
which may be easier to make use of as a way to get environment variables from a flake devshell.
For covering nix shell nixpkgs#<pkg>
, I guess it'd involve something like the equivalent of getting the path from nix build nixpkgs#gcc --no-link --json
.
The setting name nixEnvSelector.nixFile
doesn't make as much sense for flake devshells as it does for the nix-shell
command.
from nix-env-selector.
What would be needed for this? I didn't look into how this extension works, but I believe a hacky solution would be using flake-compat
as explained by the OP. It would basically be something like nix-build -E '(import (fetchTarball { /* flake-compat url and hash */ }) { src = ./.; }).shellNix'
which I think the extension could use (again, I don't how the extension handles this).
from nix-env-selector.
Just to be clear, if I create a shell.nix
with the content that @jmatsushita is proposing.. this should be working already? because it's not for me :-( Even if nix-shell shell.nix
works.
from nix-env-selector.
@arrterian I'd happily sponsor work that would result in this being implemented, do you think that could be arranged?
I will pledge $20 worth of Monero if that means anything : )
from nix-env-selector.
@kubukoz wdym the appropriate vscode extension? The direnv one? So no need for this one?
from nix-env-selector.
@mimoo yeah, I'm using this one: https://marketplace.visualstudio.com/items?itemName=Rubymaniac.vscode-direnv
from nix-env-selector.
Related Issues (20)
- Stuck applying environment HOT 12
- Rustup packages as settings packages HOT 3
- 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 6
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.