Skip to content

NixOS for Robotics

Advanced

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.

  • 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

Understanding the distinction is important:

ComponentWhat It IsUse Case
NixPackage managerRuns on any Linux/macOS for isolated dev environments
NixOSFull Linux distroEntire OS defined declaratively via Nix

You can use Nix for robotics development on Ubuntu, then deploy to NixOS for production.

┌─────────────────────────────────────────────────────────────────┐
│ 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/ │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘

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

The nix-ros-overlay project provides ROS 2 packages for Nix.

ROS 2 Distronix-ros-overlay BranchStatus
Jazzymaster/developPrimary support
HumbledevelopSupported
RollingdevelopDevelopment
Terminal window
# Enter ROS 2 Jazzy development shell
nix develop github:lopsided98/nix-ros-overlay/master#example-ros2-desktop-jazzy
# Test ROS 2
ros2 launch demo_nodes_cpp talker_listener_launch.xml
{
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="
];
};
}

The jetpack-nixos project (maintained by Anduril) enables NixOS on Jetson devices.

JetPackDevicesStatus
JetPack 7AGX ThorSupported (CUDA 13 pending nixpkgs 25.11)
JetPack 6AGX Orin, Orin NX, Orin NanoFull CUDA support
JetPack 5AGX Orin, Orin NX, Orin NanoFull CUDA support
# 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";
})
];
};
};
}
┌─────────────────────────────────────────────────────────────────┐
│ 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 │
│ │
└─────────────────────────────────────────────────────────────────┘
  • Colmena: Modern deployment tool with parallel rollouts
  • deploy-rs: Flake-native deployment with health checks
  • Bento: Simple sftp-based config distribution for small fleets

NixOS supports cross-compilation for ARM targets:

Terminal window
# Cross-compile for aarch64 (Jetson, Pi)
nix-build '<nixpkgs>' -A pkgsCross.aarch64-multiplatform.hello
# Enable binfmt emulation to run ARM binaries on x86
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
AspectNixOSYocto
ApproachDeclarative OS + package managerBuild system for custom distros
ReproducibilityRuntime & build-timeBuild-time
Build timeFast (binary cache)Slow (hours for initial build)
FlexibilityHigh (any package combo)Very high (BSP customization)
Best forFleet management, developmentCustom embedded images