docs: restructure CONTRIBUTING into setup, testing, tasks, style and design

This commit is contained in:
Willem Vanhulle committed 2026-10-21 12:49:34 +02:00
1 parent cfcb9bcaa0
commit e0169bf9f2
1 file changed
+65 -57
+65 -57
View File
@@ -1,73 +1,81 @@
# Contributing # Contributing
## Workflow ## Setup
Work inside the dev shell (`direnv allow` once). Run `cargo clippy --workspace Work inside the dev shell (`direnv allow` once). Version control is jj, not
--all-targets` before committing (the workspace warns on clippy pedantic plus the `git` CLI.
`absolute_paths`) and `cargo fmt --all`, which needs the nightly toolchain for
`.rustfmt.toml`. Version control is jj, not the `git` CLI.
The workspace has two crates: `bootvine` itself and `xtask`, the repository ## Before committing
tasks behind `cargo xtask` (`record-screencasts`, `install`, `uninstall`).
```sh
cargo clippy --workspace --all-targets
cargo fmt --all
```
Clippy runs with the pedantic lints and forbids absolute paths; formatting
needs the nightly toolchain the dev shell provides.
## Testing ## Testing
Everything that boots a machine or a service manager lives under `tests/`: | What | Command |
`tests/sample-machine/` holds the sample host, its slow and failing sample units | --- | --- |
and the interactive VM; `tests/vm-checks/` holds the NixOS tests that boot it. | Model and render tests | `cargo test --workspace` |
| Scripted demos | `cargo run --example boot` (also `shutdown`, `luks`) |
| Sample machine in a window | `nix run .#sample-machine-vm` |
| Boot and shutdown in a VM | `nix build .#checks.x86_64-linux.vm-boot-and-shutdown` |
| Passphrase prompt in a VM | `nix build .#checks.x86_64-linux.vm-luks-passphrase` |
- `cargo test --workspace`: model and render snapshot tests. To watch your own user manager start the sample units:
- Live against your user manager, with the sample units:
```sh ```sh
units=$(nix build --no-link --print-out-paths .#sample-unit-files) units=$(nix build --no-link --print-out-paths .#sample-unit-files)
systemctl --user link --runtime $units/* systemctl --user link --runtime $units/*
systemctl --user start --no-block bootvine-demo.target systemctl --user start --no-block bootvine-demo.target
cargo run -- --user --target bootvine-demo.target --hold 3s cargo run -- --user --target bootvine-demo.target --hold 3s
systemctl --user stop $(ls $units) systemctl --user stop $(ls $units)
systemctl --user disable --runtime $(ls $units) systemctl --user disable --runtime $(ls $units)
``` ```
- `nix run .#sample-machine-vm`: the sample host in a QEMU window. Its disk The VM checks read the console as text, hold the boot at fixed points and wait
image goes to `~/.cache/bootvine-sample-machine.qcow2`. on marker files instead of sleeping. To step through one by hand, run
- `nix build .#checks.x86_64-linux.<name>`: each `tests/vm-checks/<test>.nix` `nix run .#checks.x86_64-linux.vm-boot-and-shutdown.driverInteractive` and
boots a VM and runs `console.py` followed by `<test>.py`. call `test_script()`.
`vm-boot-and-shutdown` follows the initrd, stage 2 and a poweroff;
`vm-luks-passphrase` answers a passphrase prompt in the initrd. They read Prefix VM and recording commands with `env -u LD_LIBRARY_PATH` when your shell
tty12 as text from `/dev/vcsu12`, hold the boot with the initrd backdoor and exports libraries that clash with QEMU or Chromium.
gate files under `/run` instead of sleeping. Run one by hand with
`nix run .#checks.x86_64-linux.vm-boot-and-shutdown.driverInteractive`, then ## Repository tasks
`test_script()`.
- `nix run .#record-screencasts`, from the repository root: runs - `nix run .#record-screencasts` re-records the README animations from the
`cargo xtask record-screencasts`, which records `recordings/boot.tape` and scripted demos and copies the passphrase screenshot from the VM check.
`recordings/shutdown.tape` with VHS against the scripted examples into the README - `cargo xtask install --destdir <dir> --initrd dracut` stages an install
GIFs and copies the passphrase screenshot from the `vm-luks-passphrase` check. without touching the system; `cargo xtask uninstall --destdir <dir>` removes
- `cargo xtask install --destdir <dir> --initrd dracut`: stages an install
without touching the system; `cargo xtask uninstall --destdir <dir>` empties
it again. it again.
Prefix the VM and VHS commands with `env -u LD_LIBRARY_PATH` when the shell ## Code style
exports libraries that clash with QEMU's or Chromium's.
## Conventions - No comments; names and call flow carry the intent.
- Public fields over getters, durations over raw integers, existing crates over
hand-written formatting.
- Iterator and stream combinators over loops.
- No comments or doc comments; intent lives in names and call flow. ## Design notes
- Pub fields instead of getters, `Duration` instead of raw integers, crates
instead of hand-written formatting.
- One thread, Elm-style: a tokio current-thread runtime merges streams of
`ScreenInput` (the bus as `BootChange` batches, keys, frame ticks, full
repaints, the ask-password inotify watch, SIGTERM) with `stream::select`,
and one owned `WatchScreen` absorbs each ready batch and draws once. The
live boot and the scripted demos share this loop and differ only in their
console desk.
- Ratatui views are built declaratively from iterators.
## systemd's private socket ### One event loop
- zbus rejects it: PID 1 sends as `org.freedesktop.systemd1`, not a unique Everything runs on one thread. The service manager, the keyboard, the frame
name. libdbus works. timer, password prompts and termination each produce a stream of inputs; the
- libdbus pipelines `BEGIN` with the first message and sd-bus leaves it unread, streams are merged, applied in batches to a single screen state, and the screen
so a no-reply `Ping` goes out right after connecting. is drawn once per batch. The live boot and the scripted demos share this loop
- Surviving switch-root needs `argv[0]` starting with `@`, `IgnoreOnIsolate`, and differ only in where their inputs come from.
and a chroot through an fd to `/sysroot` taken when
`initrd-switch-root.service` is queued. ### systemd's private socket
- zbus rejects it, because PID 1 sends under its well-known name rather than a
unique one. libdbus works.
- libdbus sends its authentication handshake together with the first message,
which systemd leaves unread, so a no-reply ping goes out right after
connecting.
- Surviving the switch to the real root needs a process name starting with `@`,
a unit that is not stopped on isolate, and a chroot through a file descriptor
to the new root taken as soon as the switch is queued.