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

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
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
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
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
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
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
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New

We're in Beta

About us Mission Statement