Giter Club home page Giter Club logo

Comments (12)

zyansheep avatar zyansheep commented on May 29, 2024 37

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.

kubukoz avatar kubukoz commented on May 29, 2024 8

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.

srid avatar srid commented on May 29, 2024 6

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.

kubukoz avatar kubukoz commented on May 29, 2024 3

@arrterian I'd happily sponsor work that would result in this being implemented, do you think that could be arranged?

from nix-env-selector.

srid avatar srid commented on May 29, 2024 2

This one's being maintained actively: https://marketplace.visualstudio.com/items?itemName=mkhl.direnv

from nix-env-selector.

jmatsushita avatar jmatsushita commented on May 29, 2024 1

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.

rgoulter avatar rgoulter commented on May 29, 2024 1

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.

yusdacra avatar yusdacra commented on May 29, 2024

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.

edulix avatar edulix commented on May 29, 2024

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.

zyansheep avatar zyansheep commented on May 29, 2024

@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.

mimoo avatar mimoo commented on May 29, 2024

@kubukoz wdym the appropriate vscode extension? The direnv one? So no need for this one?

from nix-env-selector.

kubukoz avatar kubukoz commented on May 29, 2024

@mimoo yeah, I'm using this one: https://marketplace.visualstudio.com/items?itemName=Rubymaniac.vscode-direnv

from nix-env-selector.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.