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

beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> somethi...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
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

Other popular topics Top

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
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New

We're in Beta

About us Mission Statement