D4no0
I was wondering, what is the most painless way to get started with multiple elixir/erlang versions on nixos?
I’ve tried to install asdf, however when it comes to compiling OTP, I cannot configure correctly the dependencies required by OTP when building it from source, I am more than positive that the packages I’m using are the incorrect ones.
I also have zero idea how things like flakes, home-manager works (and I don’t have them set up yet), so it would be great to get a turnkey solution for the time being, until I get my head around all the concepts of nix.
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
I think I’ve found a small improvement I could contribute to <%= web_namespace %>.CoreComponents (installer/templates/phx_web/compo...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
joelpaulkoch
Have you tried following this post: Nix Flake Template for Elixir? - #5 by c4710n ? (And in particular this repository: GitHub - nix-giant/nix-dev-templates · GitHub)
You’ll have to enable flakes, but you can also do that temporarily by passing a cli argument as described here: https://nixos.wiki/wiki/flakes
I believe the following should work:
Inside your project directory run
nix --experimental-features 'nix-command flakes' flake init --template github:c4710n/nix-dev-templates#elixirThen you can change your version in
flake.nix, you can search for available versions here: NixOS SearchThen run
nix --experimental-features 'nix-command flakes' developand you should have your version available.I’m not sure about the enabling flakes temporarily part, so I hope that works.
Edit: It could be that the updated version is not picked up by nix because the old version is still in
flake.lock, or when it’s not staged in git. I think I remember running into this at some point.cmkarlsson
Welcome to NixOS!
To paraphrase a famous french philosopher. “I’m sorry for the long post, I didn’t have time to make it shorter.”
Quick Introduction
The latest stable (24.05) release of nixos comes with erlang 24, 25, 26, 27.
If you have NixOS installed you can try any of them out by running
nix-shellOnce you exit the shell
erlang_25goes aways and everything is cleaned up.nix-shellis great to try different kind of software without messing anything up. You can find all the packages herehttps://search.nixos.orgSetting up erlang/elixir dev environments
To make the versions you use more convenient and bundle up other pieces of software I setup shell development environments.
Lets explore:
$ mkdir ~/tmp/gshell.nixfile with content below$ nix-shellMy standard simple
shell.nixfile for erlang/elixir development looks like this:I put this
shell.nixfile in the root of my project directory. I can thecdinto the dir and runnix-shellAnd I have access to all the tools listed in the basePackages.
To make things a more convenient I use nix-direnv (GitHub - nix-community/nix-direnv: A fast, persistent use_nix/use_flake implementation for direnv [maintainer=@Mic92 / @bbenne10] · GitHub) which means I can just
cdinto the directory and it automatically enables my environment and keeps my preferred shell (I use fish, whereas the standard nix-shell gives you bash).Overriding elixir version
I am generally happy with using the erlang versions that come with NixOS. However, I often want to run a newer elixir version. Please look at the following
shell.nixfile for building elixir from github.For a setup with a separate postgresql database per project please check out the answer here:
I am a big fan of NixOS. WIth the development shells it makes it so easy for me to setup nearly all my projects development requirements and it has saved me so much time over the years I have been using it. And they just keep on working!
D4no0
Sorry for the dumb question, but what is the difference between
flakeandnix-shell? I see people using either one or the second and I don’t fully understand the difference between them.In my case I usually care about the opposite, there are a lot of times when I need a very specific OTP version, for example
26.2.5.4. Is it possible to do the same with erlang dependency as you did with the elixir one?cmkarlsson
Yes, it is a bit unfortunate. From my understanding they are two different ways to do the same thing. I am sure flakes are great but I haven’t explored them much so cannot give any assistance regarding them.
nix-shellis the standard (or perhaps old?) way of specifying development shells. Flakes can also specify development shells but they can also do much more.I should mention that my instructions above requires a channel named
nixpkgson your system. This is the default if you install nixos but if you have configured flakes for your system, the shell.nix might need to be adapted.Yes. You should be able to do the same as well as modifying compiler flags if that is necessary. I had a quick look at the package so I think it should be enough to substitute
elixirforversionand then specify the correct revision, owner and repo in the src override.Completely untested and more what I would try first:
I am not at all sure what the
nameanedrevshould be above though.D4no0
I managed to get the project up and running using the sample
shell.nixconfig, it is great how easy that was and how it worked out of the box. It will take some time to setup the language server (as I want to use elixir-ls), but having the initial configuration that works is the core thing I was searching for hours and couldn’t find.For now I will stick to
, but this doesn’t mean that @joelpaulkoch 's answer is not valid too, maybe I will try it later when I will have more time.
nix-shell, as it works and I actually understand at least partly what is going on thereTo keep maximum visibility for other people searching for this too I will leave both answers in this post and mark this post as the correct answer:
Thanks again @cmkarlsson and @joelpaulkoch for the swift response and detailed answers!