How to setup an Elixir sandbox for a nerves project in 2 simple steps with Nanobox
Elixir is seriously awesome. If you aren’t already familiar with Elixir, go check it out right now! As if Elixir wasn’t cool enough, the folks behind Nerves have re-captured my youthful imagination and peaked my childhood curiosity for building toys again. Err, I mean useful IOT devices for important grown up reasons… right.
Let’s move right along to the point here: You want to try out Elixir and boot your raspberry PI into a Nerves app. Let’s face it, you just don’t have time to setup an elixir sandbox. You can certainly figure it out, I mean seriously, you’re a software engineer you can do anything… but you can’t create more time, and that’s what’s at stake here. Let’s hire Nanobox to do this job for us… after all Nanobox is free.
Nanobox is a micro platform that can run your app anywhere. In this case, you just need an elixir environment on your local workstation to compile the Nerves app and generate a bootable image. Nanobox will create an isolated elixir environment that you can start, stop, and throw away at will. After you’ve downloaded nanobox, there are only two simple steps and you’re good to go!
Step 1: Create a boxfile.yml
Nanobox reads a configuration file at the base of your project, boxfile.yml. Create one with the following contents:
run.config:
engine: elixir extra_packages:
- fwup
- coreutils
- squashfs cache_dirs:
- _build
- deps extra_steps:
- mix archive.install https://github.com/nerves-project/archives/raw/master/nerves_bootstrap.ez --force build_triggers:
- mix.exs
- mix.lock fs_watch: true
This configuration informs nanobox how to build an environment within which your app can run.
Step 2: Run the environment
At this point, you’re all set. Simply type nanobox run
and you’ll watch nanobox build the environment (install packages, etc) after which you’ll be dropped into an command prompt with your source code and everything you need to develop, compile, and build a bootable image.
Happy hacking!
(Special thanks to @PhilipGiuliani for crafting the boxfile.yml configuration)