tatara_init/lib.rs
1//! # tatara-init — tatara IS PID 1
2//!
3//! Drop-in replacement for systemd/s6/openrc inside a tatara-os Linux guest.
4//! No daemon, no dbus, no cgroup choreography (the kernel already does that).
5//! A single static Rust binary that:
6//!
7//! 1. Reads `/etc/tatara/init.lisp` (or `$TATARA_INIT_CONFIG`)
8//! 2. Compiles it to a typed `InitConfig` via `tatara-lisp-derive`
9//! 3. For each declared `Service`, forks + execs
10//! 4. Reaps zombie children (the classic PID-1 duty)
11//! 5. Honors `SIGTERM`/`SIGINT` → propagates to children, then exits
12//! 6. On `SIGHUP` → re-reads the config, diff + apply (start new,
13//! stop removed, restart changed)
14//!
15//! The supervisor is abstract (`Supervisor` trait) so the control logic is
16//! unit-testable without actually being PID 1. A concrete `LinuxSupervisor`
17//! ships for the real boot path; a `MockSupervisor` ships for tests.
18//!
19//! Lisp authoring:
20//!
21//! ```lisp
22//! (definit
23//! :name "plex-boot"
24//! :reap-zombies #t
25//! :services
26//! ((:name "sshd" :exec "/run/current-system/sw/bin/sshd -D")
27//! (:name "tatara-reconciler" :exec "/bin/tatara-reconciler")
28//! (:name "kasou" :exec "/bin/kasou" :restart "always"
29//! :env (("KASOU_SOCKET" "/run/kasou.sock")))))
30//! ```
31
32pub mod config;
33pub mod mounts;
34pub mod supervisor;
35
36pub use config::{InitConfig, MountSpec, RestartPolicy, Service};
37pub use mounts::{mount_early_filesystems, mount_extra, EarlyMount, EarlyMountError};
38pub use supervisor::{LinuxSupervisor, MockSupervisor, Pid, Supervisor, SupervisorError};