serpent
A Mix task that wraps any Elixir Mix project generator in a devenv.sh environment.
Note that you can install Nix on top of macOS or most Linux distros without requiring a full NixOS setup.
Installation
Install the archive directly from Hex:
mix archive.install hex devenv_new
Usage
Use mix devenv.new to wrap any Mix project generator:
# Create a Phoenix project with devenv
mix devenv.new phx.new my_app --devenv postgres,redis
# Create an Igniter project with devenv
mix devenv.new igniter.new my_project --devenv elixir=1.17,postgres --install ash,ash_postgres
# Create a basic Elixir project with devenv
mix devenv.new new my_lib --devenv elixir=1.17,minio --sup
# To run Mix in a temporary Elixir Nix environment
nix-shell -p elixir --run 'mix devenv.new igniter.new demo_app '\
'--devenv postgres,bun '\
'--install ash,ash_postgres,ash_authentication_phoenix,ash_graphql '\
'--auth-strategy magic_link '\
'--with phx.new'
cd demo_app
devenv up
MIX_ENV=test mix ash.reset
mix test
See story.html for a full log of a generator run.
Devenv Features
Available devenv features:
- elixir - Elixir runtime (supports version specification, e.g.,
elixir=1.17) - postgres - PostgreSQL database with project-specific databases
- redis - Redis cache/session store
- minio - MinIO object storage (S3-compatible)
- npm - Node.js runtime with npm
- bun - Bun runtime/package manager
The generator is built to be easily extendable, by creating an .eex template file and adding it to the look-up table in devenv.new.ex.
Trending in Announcing
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries.
offset-based pagination with...
New
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
I released Doggo, a collection of unstyled Phoenix components.
https://github.com/woylie/doggo
Features
Unstyled Phoenix components....
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hello
Published a new library - ProcessHub!
ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
It’s not that it’s vocabulary is too advanced. It’s something worse.
I get lost trying to follow even a paragraph written by Claude. It’...
New
This showed up on my feed.. anyone heard of it? Just hype?
Ox Alpha is a reasoning model designed for coding, sustained ag...
New
Hey folks,
I just published a post about Hologram’s funding and where the project goes next - the short version:
Curiosum as Main Spons...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
sezaru
Super cool! I will try it out later.
One question, did you also setup the variable envs so all created files are encapsuled inside the project directory? For example, in my devenv config, I setup it so all postgres data will live inside the project directory (I think inside .env/.devenv/state/postgres), I also made that all elixir config files like hex, mix, erlang-history, etc are all inside the .env/.devenv/state too.
In other words, running elixir, postgres, erlang, etc never leaks anything outside the scope of the project.
serpent
No special env setup, so far. PostgreSQL lives under
.devenv/state/postgresby default. All state is contained within the project folder, but not necessarily under.devenv.If you have a good env setup to share, let me know. So far it only knows about languages and services, but other classes could be added.
sezaru
For Elixir, I define these variables:
And then I set them like this:
For postgres I set this:
For node, these ones:
And, if you plan to add support for rust, I set this:
serpent
Thank you for the inspiration! I was considering isolating Hex archives, actually.
zachdaniel
This is pretty neat! I’ve been planning on getting into nix & devenv at some point, especially considering how important it is getting to be able to run containerized local development. Its on my short list to checkout
olivermt
Why would you want nix to run containerized stuff?
(Genuine question, the benefits seem overlapping)
sezaru
It allows you to have full development dependencies per project and scoped only for them. It gives you access to basically all packages from Nix so you can setup it the way you want and do that in a declarative and consistent way.
IMO it is the best way to setup you development infrastructure without having to handle that at the OS level, specially if you work with multiple projects with different dependencies.
The only downside, IMO is that the nix language is kinda hard to work with if you don’t want to spend a lot of time understanding it.
PS. i’m talking here about using devenv, NixOS and Home Manager are not required to work with devenv at all (but I do like them a lot too)
olivermt
I know what nix does, what is confusing to me is how zach is going to get benefit from nix AND containers at the same time. Unless he meant «comtainerized» abstractly achieved via nix and not oci combined with nix
zachdaniel
Sorry, I kind of conflated a lot of things in one post, but my real point is that there are a whole host of tools, like nix and devenv, that I’ve been meaning to look into, specifically for agentic workflows (which may involve containerization, repeatable builds, sandboxing etc. TBD).
serpent
Container from “to contain”, Docker, LXC etc. offer containers, Devenv achieves “containerisation” in a different way, without strict file system boundaries.
That being said, Nix in general has good support for bundling a config in an OCI container, see here for Devenv.
Devenv is a good way to get a feeling for Nix: You can treat your
devenv.nixas a config data file without knowing the Nix language, some of the more complicated stuff can be setup viadevenv.yaml, like adding additional package sources.Without Devenv you would typically create a Flake providing a dev shell – for me that typically meant looking for and starting with a template. Always felt a bit cumbersome when I just required an ad-hoc environment to play around with some piece of software written in obscure language xy…