Skip to main content

tatara_vm/
lib.rs

1//! # tatara-vm — Darwin-hosted Linux guests for tatara-os
2//!
3//! Typed `VmSpec` authored in tatara-lisp, emitted as config for whichever
4//! hypervisor the host has available:
5//!
6//!   - **`vfkit`** — Apple Virtualization.framework, minimal CLI, JSON config.
7//!     Default on Darwin. Installed via nixpkgs' `vfkit` attribute.
8//!   - **`qemu`** — portable fallback; KVM on Linux, HVF on Darwin (intel).
9//!   - **`kasou`** — pleme-io's own Virtualization.framework wrapper. Used when
10//!     we want Rust-native control, no CLI shell-out.
11//!
12//! The Nix story: the VM's **kernel** + **initrd** + **rootfs** are tatara
13//! `Derivation` values. That means every guest is content-addressed, and two
14//! identical `VmSpec` values produce the same bytes in `/nix/store`. Darwin
15//! hosts the hypervisor; Nix (on Darwin) builds every guest artifact.
16//!
17//! Lisp authoring:
18//!
19//! ```lisp
20//! (defvm plex-guest
21//!   :cpus     4
22//!   :memory-mib 4096
23//!   :hypervisor (:kind Vfkit)
24//!   :kernel   (:bridge "linuxPackages.kernel")
25//!   :initrd   (:bridge "tatara.initrd")
26//!   :rootfs   (:system plex)
27//!   :network  ((:kind Nat :subnet "10.200.0.0/24"))
28//!   :shares   ((:host "/Users/drzzln/code" :guest "/mnt/code"))
29//!   :cmdline  ("console=hvc0" "init=/bin/tatara-init"))
30//! ```
31
32pub mod boot;
33pub mod config;
34pub mod darwin_rootfs;
35pub mod engine;
36pub mod guest;
37// `maquina` is ENTIRELY a projection onto `maquina_engine::VmShape`, so it
38// cannot exist without the optional dependency. It was declared unconditionally
39// while `maquina-engine` is `optional = true`, which is why the default build
40// failed with E0432 `unresolved import maquina_engine` — the module compiled,
41// the crate was never linked. Gated to match the dependency that defines it.
42#[cfg(feature = "engines")]
43pub mod maquina;
44pub mod rootfs;
45pub mod vfkit;
46
47pub use boot::{compose, BootManifest};
48pub use config::{
49    GuestKernel, GuestRootfs, Hypervisor, NetworkKind, NetworkSpec, ShareSpec, VmSpec,
50};
51pub use darwin_rootfs::DarwinRootfs;
52pub use engine::{engine_for, EngineSelectError};
53pub use guest::{GuestKind, GuestSpec, ResourceLimits, WasmSpec};
54pub use rootfs::{GuestPackage, InitrdContent, InitrdFile, LinuxRootfs};
55pub use vfkit::{VfkitEmitter, VfkitJson};