NixOS for Robotics
Advanced
Terminal window
Terminal window
Terminal window
NixOS is a Linux distribution built around the Nix package manager that takes a fully declarative approach to system configuration. For robotics, NixOS enables reproducible, immutable deployments where entire robot configurations can be version-controlled and reliably deployed across fleets with identical behavior.
Prerequisites
ROS 2 Robot Operating System integrated via nix-ros-overlay
Why NixOS for Robotics?
- Reproducibility: Identical system configuration across entire robot fleet
- Atomic updates: System changes are all-or-nothing with instant rollback
- Declarative config: Entire robot defined in version-controlled code
- No dependency conflicts: Multiple package versions coexist cleanly
- Fleet management: Push identical configurations to hundreds of robots
Nix vs NixOS
Understanding the distinction is important:
| Component | What It Is | Use Case |
|---|---|---|
| Nix | Package manager | Runs on any Linux/macOS for isolated dev environments |
| NixOS | Full Linux distro | Entire OS defined declaratively via Nix |
You can use Nix for robotics development on Ubuntu, then deploy to NixOS for production.
Architecture Overview
┌─────────────────────────────────────────────────────────────────┐│ NixOS System Architecture │├─────────────────────────────────────────────────────────────────┤│ ││ ┌─────────────────────────────────────────────────────────┐ ││ │ /etc/nixos/configuration.nix │ ││ │ (Declarative System Definition) │ ││ └─────────────────────────────────────────────────────────┘ ││ │ ││ ▼ ││ ┌─────────────────────────────────────────────────────────┐ ││ │ nixos-rebuild │ ││ │ (Build & Activate System Configuration) │ ││ └─────────────────────────────────────────────────────────┘ ││ │ ││ ┌─────────────────┼─────────────────┐ ││ ▼ ▼ ▼ ││ ┌──────────────┐ ┌──────────────┐ ┌──────────────────┐ ││ │ Generation 1 │ │ Generation 2 │ │ Generation N │ ││ │ (rollback) │ │ (previous) │ │ (current/active) │ ││ └──────────────┘ └──────────────┘ └──────────────────┘ ││ │ ││ ▼ ││ ┌─────────────────────────────────────────────────────────┐ ││ │ /nix/store │ ││ │ (Immutable Package Store - Content-Addressed) │ ││ │ /nix/store/abc123-ros-jazzy-nav2/ │ ││ │ /nix/store/def456-python3-3.11/ │ ││ └─────────────────────────────────────────────────────────┘ ││ │└─────────────────────────────────────────────────────────────────┘Nix Flakes
Flakes are the modern way to define reproducible Nix projects:
- flake.nix: Project definition with inputs and outputs
- flake.lock: Pinned dependency versions for reproducibility
ROS 2 with nix-ros-overlay
The nix-ros-overlay project provides ROS 2 packages for Nix.
Supported ROS 2 Distributions
| ROS 2 Distro | nix-ros-overlay Branch | Status |
|---|---|---|
| Jazzy | master/develop | Primary support |
| Humble | develop | Supported |
| Rolling | develop | Development |
Quick Start
# Enter ROS 2 Jazzy development shellnix develop github:lopsided98/nix-ros-overlay/master#example-ros2-desktop-jazzy
# Test ROS 2ros2 launch demo_nodes_cpp talker_listener_launch.xmlDevelopment Shell (flake.nix)
{ description = "Robot development environment";
inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; nix-ros-overlay.url = "github:lopsided98/nix-ros-overlay/master"; };
outputs = { self, nixpkgs, nix-ros-overlay }: let system = "x86_64-linux"; pkgs = import nixpkgs { inherit system; overlays = [ nix-ros-overlay.overlays.default ]; }; in { devShells.${system}.default = pkgs.mkShell { name = "robot-dev";
buildInputs = with pkgs; [ colcon (rosPackages.jazzy.buildEnv { paths = with rosPackages.jazzy; [ ros-core nav2-bringup slam-toolbox rviz2 ]; }) ];
shellHook = '' echo "ROS 2 Jazzy development environment" ''; }; };
nixConfig = { extra-substituters = [ "https://ros.cachix.org" ]; extra-trusted-public-keys = [ "ros.cachix.org-1:dSyZxI8geDCJrwgvCOHDoAfOm5sV1wCPjBkKL+38Rvo=" ]; };}# Enter development shellnix develop
# Or run directlynix develop .#default
# Build and enter shellnix develop --command bashNVIDIA Jetson Support
The jetpack-nixos project (maintained by Anduril) enables NixOS on Jetson devices.
Supported Platforms
| JetPack | Devices | Status |
|---|---|---|
| JetPack 7 | AGX Thor | Supported (CUDA 13 pending nixpkgs 25.11) |
| JetPack 6 | AGX Orin, Orin NX, Orin Nano | Full CUDA support |
| JetPack 5 | AGX Orin, Orin NX, Orin Nano | Full CUDA support |
Jetson Configuration
# flake.nix for Jetson Orin robot{ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; jetpack-nixos.url = "github:anduril/jetpack-nixos"; nix-ros-overlay.url = "github:lopsided98/nix-ros-overlay/master"; };
outputs = { self, nixpkgs, jetpack-nixos, nix-ros-overlay }: let system = "aarch64-linux"; in { nixosConfigurations.robot-orin = nixpkgs.lib.nixosSystem { inherit system; modules = [ jetpack-nixos.nixosModules.default ({ config, pkgs, ... }: { nixpkgs.overlays = [ nix-ros-overlay.overlays.default ];
hardware.nvidia-jetpack = { enable = true; som = "orin-agx"; carrierBoard = "devkit"; };
# CUDA capability for Orin (mandatory) config.cudaCapabilities = [ "8.7" ];
environment.systemPackages = with pkgs; [ (rosPackages.jazzy.buildEnv { paths = with rosPackages.jazzy; [ ros-core ]; }) ];
system.stateVersion = "24.11"; }) ]; }; };}Fleet Deployment
┌─────────────────────────────────────────────────────────────────┐│ NixOS Fleet Deployment Flow │├─────────────────────────────────────────────────────────────────┤│ ││ ┌──────────────┐ ││ │ Git Repo │◄── Developer pushes configuration changes ││ │ (flake.nix) │ ││ └──────┬───────┘ ││ │ ││ ▼ ││ ┌──────────────┐ ┌────────────────┐ ││ │ CI/CD │───►│ Binary Cache │ ││ │ (Actions) │ │ (Cachix/S3) │ ││ └──────────────┘ └───────┬────────┘ ││ │ ││ ┌────────────────────┼────────────────────┐ ││ ▼ ▼ ▼ ││ ┌────────────┐ ┌────────────┐ ┌────────────┐ ││ │ Robot 1 │ │ Robot 2 │ │ Robot N │ ││ │ (pull & │ │ (pull & │ │ (pull & │ ││ │ rebuild) │ │ rebuild) │ │ rebuild) │ ││ └────────────┘ └────────────┘ └────────────┘ ││ ││ Deploy: nixos-rebuild switch --flake github:org/repo ││ Rollback: nixos-rebuild switch --rollback ││ │└─────────────────────────────────────────────────────────────────┘Fleet Management Tools
- Colmena: Modern deployment tool with parallel rollouts
- deploy-rs: Flake-native deployment with health checks
- Bento: Simple sftp-based config distribution for small fleets
Cross-Compilation
NixOS supports cross-compilation for ARM targets:
# Cross-compile for aarch64 (Jetson, Pi)nix-build '<nixpkgs>' -A pkgsCross.aarch64-multiplatform.hello
# Enable binfmt emulation to run ARM binaries on x86boot.binfmt.emulatedSystems = [ "aarch64-linux" ];NixOS vs Yocto
| Aspect | NixOS | Yocto |
|---|---|---|
| Approach | Declarative OS + package manager | Build system for custom distros |
| Reproducibility | Runtime & build-time | Build-time |
| Build time | Fast (binary cache) | Slow (hours for initial build) |
| Flexibility | High (any package combo) | Very high (BSP customization) |
| Best for | Fleet management, development | Custom embedded images |
Related Terms
Yocto Alternative embedded Linux approach for custom images
ROS 2 Robot Operating System integrated via nix-ros-overlay
Isaac ROS NVIDIA GPU-accelerated ROS packages
Learn More
- zero-to-nix — Beginner-friendly introduction
- NixOS & Flakes Book — Comprehensive guide
- nix-ros-overlay GitHub — ROS 2 packages for Nix
- jetpack-nixos GitHub — Jetson NixOS support
Sources
- NixOS Homepage — Official project page
- NixOS Wiki - Flakes — Flakes documentation
- nix-ros-overlay GitHub — Primary ROS/ROS 2 overlay
- jetpack-nixos GitHub — Anduril’s Jetson NixOS module
- NixOS Wiki - CUDA — CUDA configuration guide
- Nix vs Docker (DevZero) — Comparison article