This repo bootstraps a NixOS Lima VM that declaratively runs Firecracker and a nested Ubuntu microVM.
It builds on:
yashdiq/firecracker-lima-vmfor the original Firecracker-on-Lima flow and networking approachnixos-lima/nixos-limafor the NixOS-on-Lima base template
- macOS on Apple Silicon
- Lima (
limactl)
Install examples:
brew install limaor
nix-env -iA nixpkgs.limaFrom repo root:
./scripts/bootstrap.sh
./connect.shbootstrap.sh will:
- create/recreate the Lima VM (
fc-nixosby default) - stage Firecracker + Lima NixOS modules into
/etc/nixos - apply a bootable declarative generation (
nixos-rebuild boot) - reboot the guest and verify Firecracker services
- export the nested microVM SSH key to
./.state/ssh/microvm.id_rsa
connect.sh will:
- ensure the Lima VM is running
- start
firecracker-microvm-start.service - SSH into the nested microVM via Lima proxy
It may take a minute to start the service when you first bring up the Lima VM and connect.
./scripts/bootstrap.sh auto-loads ./.bootstrap.env if present.
Example:
LIMA_CPUS=8
LIMA_MEMORY=14GiB
LIMA_DISK=80GiB
MICROVM_VCPUS=6
MICROVM_MEM_MIB=49152
MICROVM_ROOTFS_SIZE=40GSupported variables:
LIMA_INSTANCE_NAME(default:fc-nixos)LIMA_TEMPLATE_PATH(default:lima/nixos.yaml)LIMA_CPUS(default:4)LIMA_MEMORY(default:4GiB)LIMA_DISK(default:100GiB)MICROVM_VCPUS(default:1)MICROVM_MEM_MIB(default:1024)MICROVM_ROOTFS_SIZE(default:1G)FC_BOOTSTRAP_FORCE=1(skip delete confirmation)
Unit notes:
LIMA_MEMORY/LIMA_DISKuse Lima byte units likeGiBMICROVM_MEM_MIBuses integer MiBMICROVM_ROOTFS_SIZEusestruncatesyntax (G,M, etc.)
Why mixed units: Lima and Firecracker/rootfs tooling consume different unit formats; the script passes each in its native format.
Precedence:
- exported shell env vars override
.bootstrap.env .bootstrap.envoverrides script defaults
Connect to nested microVM:
./connect.shStop Lima VM:
./scripts/stop.shReset everything (delete VM + local state):
./scripts/reset.shscripts/bootstrap.sh- deterministic VM bootstrap + declarative guest configscripts/stop.sh- stop Lima instancescripts/reset.sh- delete Lima instance + local stateconnect.sh- host-to-microVM SSH helperlima/nixos.yaml- Lima template (nested virtualization enabled)nixos/configuration.nix- Firecracker NixOS modulenixos/lima.nix- vendorednixos-limabase guest modulenixos/lima-init.nix- vendorednixos-limacidata/guest-agent init modulenixos/scripts/init-first-run.sh- one-time kernel/rootfs init inside guestnixos/scripts/start-stack.sh- Firecracker API config + tap/NAT + microVM start
Check KVM inside guest:
limactl shell fc-nixos -- ls -l /dev/kvmCheck Firecracker services:
limactl shell fc-nixos -- sudo systemctl --no-pager --full status firecracker firecracker-microvm-init firecracker-microvm-startCheck Firecracker API socket/process:
limactl shell fc-nixos -- bash -lc "ps -ef | grep -E '[f]irecracker --api-sock /tmp/firecracker.socket'; ls -l /tmp/firecracker.socket"Replace fc-nixos with your LIMA_INSTANCE_NAME if modified.
Upstream licenses apply:
firecracker-microvm/firecrackerandyashdiq/firecracker-lima-vm: Apache-2.0nixos-lima/nixos-lima: MIT