Does anyone have experience with using NixOS, VSCode, direnv, and ElixirLS together? I'm trying to version manage my Elixir version like in asdf-vm

By any chance does anyone here use NixOS, VSCode, and ElixirLS? I’m trying to replace asdf-vm with direnv (because asdf doesnt work very well/at all on NixOS), but ElixirLS is complaining that it can’t find Elixir. This makes sense because the PATH is only correct in the terminal. ElixirLS fixes this when using asdf by simply sourcing the same file the terminal is sourcing, but it doesnt do this with direnv

1 Like

Can you share your Nix config?

hum… I don’t have any issue with it on my end with nixos.

in terms of elixir packages, just needed:


and for vscode (ignore the mkIf’s … i am copy and pasting from a custom module where I configure what I want to install) :

programs.vscode = mkIf (cfg.vscode.enable) {
enable = true;
package = pkgs.vscodium;
extensions = mkIf (cfg.vscode.defaultExtensions) [

its also super easy to setup on neovim with nixvim, just enable:

programs.nixvim.plugins.lsp.servers.elixirls.enable = true;

btw… why using direnv and not a nix shell?

1 Like

So long story short, I’m using a shell.nix where I declare my packages (specific Erlang and Elixir versions) which then get loaded by direnv automatically so I don’t have to type nix-shell in the terminal and get dropped in this barren place instead of my configured shell. However this would still not be correct since I’m using the vscode-elixirls extension, which simply checks whether your path contains the elixir command.

However, I found a very convenient solution. There is a package called Nix Environment Selector for VSCode which is able to load a shell.nix file and then relaunch VSCode in that environment, which is as close as possible to what I was looking for. So mission accomplished and the thread can is solved :slight_smile:

Oh, and thanks for your answer anyway :smiley:


Sorry to add to this, since solution was already found:

Found this good simple doc on this, for future reference, for me :slight_smile: and for others:

I find combining a flake devShell and nix-direnv to work flawlessly. The vscode direnv extension will prompt to restart extensions if the environment changes.