Pistrie

Pistrie

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

Marked As Solved

Pistrie

Pistrie

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:

Also Liked

gXuEubhxAgHEd

gXuEubhxAgHEd

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

in terms of elixir packages, just needed:

pkgs.elixir
pkgs.elixir_ls

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) [
pkgs.vscode-extensions.bradlc.vscode-tailwindcss
pkgs.vscode-extensions.bungcip.better-toml
pkgs.vscode-extensions.eamodio.gitlens
pkgs.vscode-extensions.jakebecker.elixir-ls
pkgs.vscode-extensions.jnoortheen.nix-ide
pkgs.vscode-extensions.matklad.rust-analyzer
pkgs.vscode-extensions.phoenixframework.phoenix
pkgs.vscode-extensions.serayuzgur.crates
pkgs.vscode-extensions.usernamehw.errorlens
pkgs.vscode-extensions.alefragnani.bookmarks
pkgs.vscode-extensions.thenuprojectcontributors.vscode-nushell-lang
pkgs.vscode-extensions.gruntfuggly.todo-tree
];
};

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?

Where Next?

Popular in Questions Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New

We're in Beta

About us Mission Statement