robotnix: give the robot root a /usr tree before nspawn starts

robotnix-genix.service on hub was in start-limit-hit with exec_main_status 1.
systemd-nspawn refused the root: "Directory /run/robotnix/genix/root doesnt
look like it has an OS tree (/usr/ directory is missing). Refusing." The storage
and seed units were healthy (image mounted, "installation finished!"), so the
tree existed and was populated - it was just missing /usr.

The seed script ends with a tail block that runs on every invocation, not only
when it installs: it creates etc, var/lib, root and home, and touches os-release
and machine-id. That list was copied from nixos-containers but dropped its first
line, mkdir -p "$root/usr/bin" (nixos-containers.nix:102). nspawn treats the
presence of /usr as the marker of an OS tree, so every start died before the
init ran, and because the unit restarts on failure it burned through the start
limit instead of recovering.

Add that mkdir with an explicit 0755 mode to the same tail block. Because the
block is outside the first-install branch, the directory is created on the next
storage+seed run for an already seeded root, so this needs no robotnix reseed
and loses no data. The module layout is unchanged.

ABOUTME.md gains a Notes/decisions bullet recording why the root gets /usr/bin
and that no reseed is required.
This commit is contained in:
Hermenix committed 2026-10-26 00:45:42 +00:00
1 parent eb6380ddfe
commit 86f9ae010e
2 files changed
+5

No files matched your search

+4
View File
@@ -104,6 +104,10 @@ Runtime state comes from `/etc/robotnix.json`, written by the module.
the `containers.*` module: that module shares the host store, which would
break the robot's self-rebuilds. The unit mirrors `nixos-containers.nix`
(`Type=notify`, SIGRTMIN+3, exit status 133, `machine.slice`).
- The robot's root gets `/usr/bin` before its first start: `systemd-nspawn`
refuses a tree without `/usr` ("doesn't look like it has an OS tree"), the
same reason `nixos-containers.nix` creates it. The seed's tail block runs on
every start, so no reseed is needed after this landed.
- `systemd-nspawn` runs in `machine.slice` (systemd's nspawn home), not
`system.slice`.
- Timers use `skyg.server.timers`; eval asserts unique robot ids/IPs, name
+1
View File
@@ -224,6 +224,7 @@ let
fi
# What nspawn and NixOS's init expect (same as nixos-containers).
mkdir -p "$root/etc" "$root/var/lib" "$root/root" "$root/home"
mkdir -p -m 0755 "$root/usr/bin"
chmod 0700 "$root/root"
[ -e "$root/etc/os-release" ] || [ -L "$root/etc/os-release" ] || touch "$root/etc/os-release"
[ -e "$root/etc/machine-id" ] || touch "$root/etc/machine-id"