A template repository demonstrating the Nix-based development and deployment workflow for the Elodin Aleph flight computer.
This project serves as a starting point for building your own custom Aleph software stack. It demonstrates three common patterns for packaging and deploying software to Aleph using NixOS.
flowchart TB
subgraph flake [flake.nix]
inputs[Aleph + nixpkgs inputs]
overlay[Custom Overlay]
module[NixOS Module]
end
subgraph pkgs [nix/pkgs/]
nixpkgEx[example-nixpkgs.nix]
sourceEx[example-from-source.nix]
helloPkg[hello-service.nix]
end
subgraph mods [nix/modules/]
helloMod[hello-service.nix]
end
subgraph src [src/hello-service/]
mainPy[main.py]
end
overlay --> nixpkgEx
overlay --> sourceEx
overlay --> helloPkg
module --> helloMod
helloPkg --> src
helloMod --> helloPkg
Before you begin, ensure you have:
- Determinate Systems Nix installed on your development machine
- An Aleph flight computer with the base NixOS image flashed
- Network connectivity to your Aleph (WiFi or USB ethernet)
- SSH access configured (password or key-based)
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- installgit clone https://github.com/elodin-sys/aleph-template-project.git
cd aleph-template-projectTest that everything compiles correctly:
nix build --accept-flake-config .#packages.aarch64-linux.toplevel --show-traceOnce connected to your Aleph over the network:
./deploy.sh -h <aleph-hostname-or-ip> -u rootFor example:
./deploy.sh -h aleph-24a5.local -u root
./deploy.sh -h 192.168.4.181 -u rootSSH into your Aleph and check that everything is working:
ssh -i ./ssh/aleph-key aleph@<aleph-ip>
# Check the hello-service is running
journalctl -u hello-service -f
# Try the example commands
aleph-monitor # btop wrapper (Pattern 1)
lazygit # Built from source (Pattern 2)If your Aleph is fresh out of the box or you've lost network connectivity, you'll need to configure it via the serial console.
- Connect a USB cable to the Aleph's FTDI debug port
- Find the serial device:
ls /dev/tty.usbserial-* # macOS ls /dev/ttyUSB* # Linux
- Connect with screen:
screen /dev/tty.usbserial-XXXXX 115200 # or on Linux: screen /dev/ttyUSB0 115200 - Press Enter to get a login prompt
- Login as
root, default password isroot
Once connected via serial, use iwctl to configure WiFi:
# Start the interactive WiFi tool
iwctl
# Inside iwctl:
station wlan0 scan
station wlan0 get-networks
station wlan0 connect "YourNetworkName"
# Enter password when prompted
exit
# Verify connection
ip addr show wlan0
ping -c 3 google.com# On the Aleph (via serial or existing SSH):
ip addr show wlan0
# Or use mDNS from your development machine:
ping aleph-XXXX.local # where XXXX is the last 4 chars of the serial numberaleph-template-project/
├── flake.nix # Main Nix configuration
├── flake.lock # Locked dependency versions
├── deploy.sh # Deployment script
├── README.md # This file
├── nix/
│ ├── modules/
│ │ └── hello-service.nix # NixOS module (Pattern 3)
│ └── pkgs/
│ ├── example-nixpkgs.nix # Using nixpkgs (Pattern 1)
│ ├── example-from-source.nix # Building from source (Pattern 2)
│ └── hello-service.nix # Local Python package (Pattern 3)
├── src/
│ └── hello-service/
│ └── main.py # Python application source
└── ssh/
├── aleph-key # SSH private key
└── aleph-key.pub # SSH public key
This template demonstrates three common patterns for adding software to your Aleph:
File: nix/pkgs/example-nixpkgs.nix
The simplest pattern—use packages that already exist in nixpkgs. This example wraps btop (a modern resource monitor) with a custom launcher script called aleph-monitor.
# In your overlay:
example-nixpkgs = final.callPackage ./nix/pkgs/example-nixpkgs.nix {};
# In environment.systemPackages:
example-nixpkgs # Available as 'aleph-monitor' commandWhen to use: For well-supported packages in nixpkgs that you want to include or customize.
File: nix/pkgs/example-from-source.nix
Fetch source code from GitHub and build it. This example builds lazygit from the official repository.
# Key elements:
src = fetchFromGitHub {
owner = "jesseduffield";
repo = "lazygit";
rev = "v${version}";
hash = "sha256-..."; # Use nix-prefetch-github to get this
};When to use: For packages not in nixpkgs, specific versions, forks, or custom patches.
Files:
src/hello-service/main.py— Python source codenix/pkgs/hello-service.nix— Nix package definitionnix/modules/hello-service.nix— NixOS module with systemd service
This pattern packages your own Python application and deploys it as a managed systemd service with configurable options.
# In flake.nix:
services.hello-service = {
enable = true;
message = "Hello from Aleph Template Project!";
interval = 30;
};When to use: For your own applications that need to run as background services.
git clone https://github.com/elodin-sys/aleph-template-project.git my-aleph-project
cd my-aleph-project
rm -rf .git
git initrm ssh/aleph-key ssh/aleph-key.pub
ssh-keygen -t ed25519 -f ssh/aleph-key -C "my-aleph-project"Update flake.nix with your new public key:
users.users.aleph = {
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAA... your-new-key"
];
};- Create a new file in
nix/pkgs/your-package.nix - Add it to the overlay in
flake.nix:overlays.default = final: prev: { your-package = final.callPackage ./nix/pkgs/your-package.nix {}; };
- Include it in
environment.systemPackagesor create a module for it
- Create your application source in
src/your-service/ - Create a package in
nix/pkgs/your-service.nix - Create a NixOS module in
nix/modules/your-service.nix - Import the module in
flake.nixand enable it
Once you're comfortable, remove the example patterns:
- Delete
nix/pkgs/example-*.nix - Delete
nix/modules/hello-service.nixand related files - Remove references from
flake.nix
Uses your local machine or configured remote builders:
./deploy.sh -h <host> -u <user>If you don't have an aarch64 builder, the script will automatically build on the Aleph itself:
./deploy.sh -h <host> -u <user>
# Script will detect missing builder and use AlephForce local/configured builder usage:
./deploy.sh -h <host> -u <user> --no-aleph-builder- Check physical connection: Ensure Aleph is powered and connected
- Try mDNS:
ping aleph-XXXX.local - Fall back to serial: Connect via FTDI and check network config
- Check WiFi: Run
iwctlto verify/reconfigure WiFi
# macOS: Find the device
ls /dev/tty.usbserial-*
# Linux: Find the device
ls /dev/ttyUSB*
# Connect (115200 baud)
screen /dev/tty.usbserial-XXXXX 115200
# Exit screen: Ctrl+A, then K, then Y-
Verify the key file exists and has correct permissions:
ls -la ssh/aleph-key chmod 600 ssh/aleph-key
-
Ensure the public key is in
flake.nix:cat ssh/aleph-key.pub # Compare with openssh.authorizedKeys.keys in flake.nix -
Redeploy after any key changes:
./deploy.sh -h <host> -u root
-
Hash mismatch: Update the hash in your package definition
# The error will show the expected hash, copy it -
Missing dependencies: Check
buildInputsandnativeBuildInputs -
Evaluation errors: Run with
--show-tracefor detailed errorsnix build --accept-flake-config .#packages.aarch64-linux.toplevel --show-trace
# Check service status
systemctl status hello-service
# View logs
journalctl -u hello-service -f
# Restart service
systemctl restart hello-service# Build the system
nix build --accept-flake-config .#packages.aarch64-linux.toplevel
# Deploy to Aleph
./deploy.sh -h <host> -u root
# SSH to Aleph
ssh -i ./ssh/aleph-key aleph@<host># System info
neofetch
btop
# Service management
systemctl status hello-service
journalctl -u hello-service -f
# Network info
ip addr
iwctl station wlan0 show
# Check NixOS generation
nixos-rebuild list-generations- Elodin GitHub Repository
- Elodin Documentation
- Aleph Modules Source
- NixOS Manual
- Nix Pills (Learning Resource)
This template is provided under the Apache-2.0 license. See LICENSE for details.