Orientation file for AI coding agents working in this repo. Keep it short and pointer-heavy — link to docs/code instead of duplicating specifics that drift.
NeuralDrive is a bootable Debian-12 live distro (built with live-build) that turns an x86_64 host into a self-contained, OpenAI-compatible LLM inference server. Read first:
README.md— product overview, features, hardware reqs, quick startdocs/user-guide/src/SUMMARY.md— end-user documentation (mdbook)docs/dev-guide/src/SUMMARY.md— developer documentation (mdbook)- Architecture:
docs/dev-guide/src/architecture/ - Build system internals:
docs/dev-guide/src/build/
- Architecture:
plan/— internal design docs (numbered 00–12). Source-of-truth for component-level design; not copied into the published mdbooks.SIZE-REDUCTION-PLAN.md— record of how the ISO got from ~32 GB to ~3.9 GB (open-webui--no-deps, NVIDIA headless packages, etc.). Read before touching package lists.
config/— live-build tree (hooks, includes.chroot, package-lists, archives, preseed)config/hooks/live/— chroot build hooks, numerically ordered (01-setup-system…99-cleanup)config/includes.chroot/etc/systemd/system/—neuraldrive-*.serviceunitsconfig/includes.chroot/usr/lib/neuraldrive/— runtime payload (TUI, System API, GPU detect, certs, monitors)scripts/— build/flash helpers (docker-entrypoint.sh,neuraldrive-flash.sh,validate-config.sh,apply-branding.sh,download-models.sh, …)tests/— boot/GPU/API tests (test-boot.sh,test-gpu.sh,test_api.py)auto/—lb config/build/cleanwrappers consumed by live-buildDockerfile,docker-compose.yml,build.sh,build_docker.sh— build entry points (see below)neuraldrive-build.yaml.example— schema for optional custom-config builds
Building requires Debian + live-build + root + the ability to chroot/mknod. On macOS or non-Debian Linux, use the Docker path. Don't try to run lb build natively on macOS — it won't work.
./build_docker.sh # standard build
./build_docker.sh -f # force docker-image rebuild (no cache)
./build_docker.sh -s # set up workspace, drop into shell
./build_docker.sh -d # verbose; drop to shell on failure
./build_docker.sh -- neuraldrive-build.yaml # custom config (see example file)What that does, in order:
docker compose build builder— builds theDockerfile(Debian bookworm +live-build,debootstrap,squashfs-tools,xorriso,grub-pc-bin,grub-efi-amd64-bin,mtools,yq).docker compose run --rm builderwithplatform: linux/amd64,cap_add: [SYS_ADMIN, MKNOD, SYS_CHROOT],apparmor:unconfined. Bind mounts./:/src:roand./output:/output.scripts/docker-entrypoint.shruns inside the container:- Patches
live-buildin two places (grub-pc hybrid-MBR viaxorriso --grub2-mbr, pluspart_msdos+searchmodules inbinary_grub-pc). Without these patches the ISO won't boot from USB. If you upgrade the base image and the patch greps stop matching, fix them here — don't work around it. cp -a /src/. /build/so the heavy work happens in the container's writable overlay, not on the read-only bind mount.- Symlinks
/build/output → /outputso the finished ISO lands on the host without an extra copy. - Execs
./build.sh.
- Patches
build.shrunslb clean --all,lb config …,lb build, then moves the ISO tooutput/neuraldrive-<version>.isoand writesSHA256SUMS.
Output: ./output/neuraldrive-<version>.iso (+ SHA256SUMS) on the host filesystem.
Version derivation (build.sh top): $NEURALDRIVE_VERSION env > exact vX.Y.Z git tag on HEAD > dev-YYYY.MM.DD-<short-sha>. To cut a clean release ISO, tag first (e.g. ./scripts/tag-release.sh) — otherwise expect a dev-… filename.
Build time: 30–90 min on native Debian/amd64 per README. On Apple Silicon under Rosetta/QEMU emulation, expect roughly 1.5–3× longer and very network-dependent (apt + pip + ollama pull all hit the wire).
Disk: the chroot, squashfs, and intermediate artifacts (~10–20 GB peak) live in Docker Desktop's VM disk, not in ./. Only the final ISO (~3.9 GB target) is written to ./output/. Make sure Docker Desktop has enough VM disk allocated.
Privileges: ./build_docker.sh does not need sudo — Docker grants the required capabilities via cap_add. The native ./build.sh path does need sudo (see README.md "Building from source").
sudo apt install live-build debootstrap squashfs-tools xorriso grub-pc-bin grub-efi-amd64-bin
sudo ./build.sh
# or: sudo ./build.sh neuraldrive-build.yamlThis path skips the Docker entrypoint's live-build patches. If you hit "GRUB loading…" hangs from USB, port those patches into the host's /usr/lib/live/build/binary_iso and binary_grub-pc (see scripts/docker-entrypoint.sh).
- GRUB hangs at boot → live-build patches missing (see entrypoint).
- ISO is huge (~30 GB) → something pulled torch/CUDA transitively. Read
SIZE-REDUCTION-PLAN.mdbefore changing package lists or pip installs in the chroot hooks. apt installfailures mid-build → usually upstream archive flakiness;./build_docker.sh -ddrops to a shell on failure so you can inspect/build/chroot/and/build/.build/.- macOS bind mount weirdness → entrypoint already copies
/srcinto the container, so building from an external drive (/Volumes/…) is fine; the chroot never touches the host filesystem.
scripts/neuraldrive-flash.sh <iso> /dev/sdX (Linux), or dd on macOS, or Balena Etcher. See README.md "Quick start" for the canonical commands.
tests/test-boot.sh— boot-flow testtests/test-gpu.sh— GPU detection testtests/test_api.py— API surface test
There is no CI-enforced lint/format gate in this repo today. If you add one, document it here.
- Don't duplicate drift-prone specifics in this file. Service names, port numbers, package lists, cap values, version strings, chapter counts — link to the code or docs instead.
- Numbered prefixes are load order, not arbitrary:
config/hooks/live/NN-*.chrootandplan/NN-*.mdare read/executed in order. Pick a free number when adding. - Runtime code under
config/includes.chroot/usr/lib/neuraldrive/is Python (Textual TUI, FastAPI System API). Thewebui/directory is intentionally empty — Open WebUI is installed via pip in a chroot hook, not vendored. - Persistent design discussion lives in
plan/. Short-lived implementation plans live in.sisyphus/plans/(gitignored).
Read docs/dev-guide/src/build/ (especially live-build.md, docker.md, hooks.md) and the matching plan/ chapter before changing build, hook, or service behavior.