Packages

Mix task to create Nerves projects with dev container setup for Windows users

Current section

Files

Jump to
dev_nerves README.md
Raw

README.md

# DevNerves
A Mix task that creates Nerves projects with complete dev container setup, making Nerves development on Windows (and other platforms) smooth and hassle-free.
## ๐ŸŽฏ What is DevNerves?
DevNerves simplifies the tedious process of setting up a Nerves development environment, especially on Windows. It combines:
- โœ… Automated Nerves project creation
- โœ… Complete Docker dev container setup
- โœ… VS Code integration with proper extensions
- โœ… Interactive target device selection (no more typing numbers!)
- โœ… WiFi configuration built-in
- โœ… Comprehensive getting started guide
## ๐Ÿš€ Features
- **๐Ÿณ Dev Container** - Pre-configured Docker environment with all Nerves tools
- **๐ŸชŸ Windows Friendly** - Specifically designed to solve Windows development pain points
- **๐ŸŽฏ Multiple Targets** - Support for Raspberry Pi (Zero, 3, 4, 5) and BeagleBone Black
- **๐Ÿ“ก WiFi Setup** - Optional WiFi configuration during project creation
- **๐Ÿ”ง VS Code Integration** - Workspace file with proper ElixirLS configuration
## ๐Ÿ“‹ Prerequisites
Before installing DevNerves, ensure you have:
- **Elixir** 1.14 or later
- **Mix** (comes with Elixir)
- **Docker Desktop** installed and running
- **VS Code** with the "Dev Containers" extension
### Windows Users
Enable host networking in Docker Desktop:
1. Open Docker Desktop Settings
2. Go to Resources โ†’ Network
3. Check "Enable host networking"
4. Click "Apply & Restart"
## ๐Ÿ“ฆ Installation
### Option 1: Install from Hex (Recommended)
```bash
mix archive.install hex dev_nerves
```
### Option 2: Install from Source
```bash
git clone https://github.com/yourusername/dev_nerves.git
cd dev_nerves
mix do deps.get, archive.build, archive.install
```
## ๐ŸŽฎ Usage
### Basic Usage
```bash
mix dev_nerves.new my_robot
```
This will:
1. Launch an interactive setup wizard
2. Ask you to select your target device
3. Optionally configure WiFi
4. Create a complete Nerves project with dev container setup
### Advanced Usage
Skip the interactive prompts by providing options:
```bash
# Create project with specific target
mix dev_nerves.new my_robot --target rpi4
# Create with WiFi pre-configured
mix dev_nerves.new my_robot --target rpi4 --wifi-ssid "MyWiFi" --wifi-psk "password123"
# Short form
mix dev_nerves.new my_robot -t rpi3
```
### Options
- `--target`, `-t` - Target device: `rpi0`, `rpi3`, `rpi4`, `rpi5`, `bbb`
- `--wifi-ssid` - WiFi network name (SSID)
- `--wifi-psk` - WiFi password
## ๐ŸŽฏ Supported Targets
DevNerves supports all officially supported Nerves targets:
| Device | Target Code | Description |
|--------|------------|-------------|
| Raspberry Pi A+, B, B+ | `rpi` | BCM2835, 512MB RAM |
| Raspberry Pi Zero/Zero W | `rpi0` | BCM2835, 512MB RAM |
| Raspberry Pi Zero 2W / 3A (64-bit) | `rpi0_2` | BCM2837, 512MB RAM |
| Raspberry Pi 2 Model B | `rpi2` | BCM2836, 1GB RAM |
| Raspberry Pi 3 Model B/B+ | `rpi3` | BCM2837, 1GB RAM |
| Raspberry Pi Zero 2W / 3A (32-bit) | `rpi3a` | BCM2837, 512MB RAM |
| Raspberry Pi 4 Model B | `rpi4` | BCM2711, 2-8GB RAM |
| Raspberry Pi 5 | `rpi5` | BCM2712, 4-8GB RAM |
| BeagleBone Black/Green/Wireless, PocketBeagle | `bbb` | AM335x, 512MB RAM |
| Generic x86_64 | `x86_64` | x86_64 architecture |
| OSD32MP1 | `osd32mp1` | STM32MP157, 512MB RAM |
| GRiSP 2 | `grisp2` | i.MX 6UL, 512MB RAM |
| MangoPi MQ Pro | `mangopi_mq_pro` | Allwinner D1, 1GB RAM |
See [Nerves Supported Targets](https://hexdocs.pm/nerves/supported-targets.html) for more details.
## ๐Ÿ› ๏ธ What Gets Created
When you run `mix dev_nerves.new my_robot`, you get:
```
my_robot/
โ”œโ”€โ”€ .devcontainer/
โ”‚ โ”œโ”€โ”€ devcontainer.json # VS Code dev container config
โ”‚ โ”œโ”€โ”€ docker-compose.yml # Docker Compose setup
โ”‚ โ””โ”€โ”€ Dockerfile # Container with all Nerves tools
โ”œโ”€โ”€ .ssh/
โ”‚ โ””โ”€โ”€ .gitkeep # Mount point for SSH keys
โ”œโ”€โ”€ config/ # Nerves configuration
โ”œโ”€โ”€ lib/ # Your application code
โ”œโ”€โ”€ test/ # Tests
โ”œโ”€โ”€ .gitignore # Updated with dev container entries
โ”œโ”€โ”€ FIRST_DEVICE.md # Complete getting started guide
โ”œโ”€โ”€ my_robot.code-workspace # VS Code workspace file
โ””โ”€โ”€ mix.exs # Project configuration
```
## ๐Ÿš€ Quick Start After Creation
After creating your project:
```bash
# 1. Open in VS Code
cd my_robot
code my_robot.code-workspace
# 2. Reopen in Container
# Press F1 โ†’ "Dev Containers: Reopen in Container"
# Wait for container to build (5-10 minutes first time)
# 3. Inside the container terminal:
mix deps.get
mix firmware
# 4. Burn to SD card (from host machine with Balena Etcher)
# Or use fwup on Linux/Mac
# 5. Boot your device and connect!
ssh nerves.local
```
For detailed instructions, see the auto-generated `FIRST_DEVICE.md` in your project!
## ๐Ÿ“– Documentation
Each created project includes a comprehensive `FIRST_DEVICE.md` guide covering:
- โœ… Prerequisites and setup
- โœ… Opening the dev container
- โœ… Generating SSH keys
- โœ… Building firmware
- โœ… Burning to SD card (multiple methods)
- โœ… Finding your device on the network
- โœ… SSH connection
- โœ… OTA updates
- โœ… Troubleshooting common issues
- โœ… Next steps and resources
## ๐ŸŽจ Interactive UI with Owl
DevNerves uses the powerful [Owl library](https://hex.pm/packages/owl) by Mykola Konyk for beautiful CLI interactions:
- **Arrow key navigation** - Use โ†‘โ†“ keys to select options, no typing numbers!
- **Multi-select menus** - Beautiful, intuitive selection interface
- **Colored output** - Clear visual feedback with semantic colors
- **Secure password input** - WiFi passwords hidden while typing
- **Progress indicators** - Real-time feedback on what's happening
Owl makes the CLI experience feel modern and professional, similar to tools like `npm create` or `cargo new`.
### Example Interaction
```
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘ ๐Ÿš€ Nerves Dev Container Setup โ•‘
โ•‘ Easy Nerves development for Windows users โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
๐Ÿ“‹ Configuration
Select your target device:
โฏ Raspberry Pi 4 Model B - BCM2711, 2-8GB RAM
Raspberry Pi 3 Model B/B+ - BCM2837, 1GB RAM
Raspberry Pi Zero / Zero W - BCM2835, 512MB RAM
Raspberry Pi 5 - BCM2712, 4-8GB RAM
BeagleBone Black - AM335x, 512MB RAM
โœ“ Selected: rpi4
```
## ๐Ÿ› Troubleshooting
### "mix: command not found"
Install Elixir first: https://elixir-lang.org/install.html
### "nerves_bootstrap not found"
Install Nerves bootstrap:
```bash
mix archive.install hex nerves_bootstrap
```
### Docker Container Won't Start
- Ensure Docker Desktop is running
- Check that virtualization is enabled in BIOS (Windows)
- Try rebuilding: F1 โ†’ "Dev Containers: Rebuild Container"
### Can't Find Device on Network (Windows)
- Enable host networking in Docker Desktop settings
- Disable VPN temporarily
- Check firewall settings
## ๐Ÿค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
### Development
```bash
# Clone the repository
git clone https://github.com/yourusername/dev_nerves.git
cd dev_nerves
# Install dependencies
mix deps.get
# Run tests
mix test
# Build archive locally
mix archive.build
# Install locally for testing
mix archive.install
```
## ๐Ÿ“š Resources
- [Nerves Project](https://nerves-project.org/)
- [Nerves Documentation](https://hexdocs.pm/nerves/getting-started.html)
- [Elixir Lang](https://elixir-lang.org/)
- [Owl Library](https://hex.pm/packages/owl)
- [Original Dev Container Inspiration](https://github.com/Oooska/elixir_nerves_devcontainer)
## ๐Ÿ“„ License
Apache License 2.0
## ๐Ÿ™ Acknowledgments
- Inspired by [Oooska's Elixir Nerves DevContainer](https://github.com/Oooska/elixir_nerves_devcontainer)
- Built with the excellent [Owl](https://hex.pm/packages/owl) library by Mykola Konyk for beautiful CLI interactions
---
Made with โค๏ธ for the Elixir and Nerves community