DEV Community

Dwayne Crooks
Dwayne Crooks

Posted on

My reproducible Erlang playground with Nix

I started learning Erlang and wanted somewhere to keep the small programs and experiments I write along the way.

Since I also prefer to manage my project's system dependencies with Nix, I created a small Nix development shell to pin them.

For now, it contains little more than Erlang itself.

The playground

The repository for the playground is available on GitHub.

There are two main parts:

The Nix development environment

The full flake.nix is small, but the part that matters most here is:

pkgs.beam29Packages.erlang
Enter fullscreen mode Exit fullscreen mode

beam29Packages selects packages built for Erlang/OTP 29, which is the latest major Erlang/OTP release at the time of writing. With the current flake.lock, that resolves to Erlang/OTP 29.0.6.

So every time I run:

nix develop
Enter fullscreen mode Exit fullscreen mode

I get the same Erlang version. Someone else cloning the repository and entering the development shell gets that same version as well.

The important detail is that nixpkgs-unstable is not resolved afresh each time. flake.lock pins the Nixpkgs revision, and that revision determines which Erlang/OTP 29 version the development environment uses. It stays that way until I update the flake inputs.

Keeping the environment small

The development environment is intentionally small. I'm still early in learning Erlang, and the programs in the playground don't need much beyond Erlang itself.

In particular, I haven't added Rebar3 yet. At this stage I'm mostly working with the Erlang shell, compiling small modules, and experimenting with language and concurrency features directly.

That will likely change as the playground grows. Once I start working on larger programs or OTP applications, Rebar3 may make sense to add. Until then, I prefer to keep the environment limited to the tools I actually need.

Where this goes next

What I wanted out of the repository was simple: one place to keep the Erlang programs and experiments I write while learning, together with a reproducible development environment for running them.

That's what it gives me now.

The playground will probably change quite a bit as I get further into Erlang. I may add more development tools, experiments with different OTP versions, or whatever else the work starts to require.

For now, though, I can clone the repository, run:

nix develop
erl
Enter fullscreen mode Exit fullscreen mode

and know which Erlang environment I'm working in.

That's enough to keep learning.

Top comments (0)