mirror of
https://github.com/robcholz/vibebox.git
synced 2026-04-01 00:10:15 +02:00
feat: first commit
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/target
|
||||
.vibebox
|
||||
.idea
|
||||
120
Cargo.lock
generated
Normal file
120
Cargo.lock
generated
Normal file
@@ -0,0 +1,120 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
|
||||
|
||||
[[package]]
|
||||
name = "block2"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5"
|
||||
dependencies = [
|
||||
"objc2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dispatch2"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"block2",
|
||||
"libc",
|
||||
"objc2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lexopt"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9fa0e2a1fcbe2f6be6c42e342259976206b383122fc152e872795338b5a3f3a7"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.180"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc"
|
||||
|
||||
[[package]]
|
||||
name = "objc2"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7c2599ce0ec54857b29ce62166b0ed9b4f6f1a70ccc9a71165b6154caca8c05"
|
||||
dependencies = [
|
||||
"objc2-encode",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-app-kit"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"objc2",
|
||||
"objc2-foundation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-core-foundation"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"dispatch2",
|
||||
"objc2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-encode"
|
||||
version = "4.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33"
|
||||
|
||||
[[package]]
|
||||
name = "objc2-foundation"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"block2",
|
||||
"libc",
|
||||
"objc2",
|
||||
"objc2-core-foundation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-virtualization"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8edb98625ad1f7dea2e82ab54d5bdf3f477e6645b550f4a7cced1818be9ff59d"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"block2",
|
||||
"dispatch2",
|
||||
"objc2",
|
||||
"objc2-app-kit",
|
||||
"objc2-core-foundation",
|
||||
"objc2-foundation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vibebox"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"block2",
|
||||
"dispatch2",
|
||||
"lexopt",
|
||||
"libc",
|
||||
"objc2",
|
||||
"objc2-foundation",
|
||||
"objc2-virtualization",
|
||||
]
|
||||
23
Cargo.toml
Normal file
23
Cargo.toml
Normal file
@@ -0,0 +1,23 @@
|
||||
[package]
|
||||
name = "vibebox"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
objc2 = "*"
|
||||
objc2-foundation = { version = "*", features = [
|
||||
"NSArray",
|
||||
"NSString",
|
||||
"NSURL",
|
||||
"NSError",
|
||||
"NSFileHandle",
|
||||
"NSData",
|
||||
"NSDate",
|
||||
"NSRunLoop",
|
||||
"NSObject",
|
||||
] }
|
||||
objc2-virtualization = "*"
|
||||
block2 = "*"
|
||||
dispatch2 = "*"
|
||||
libc = "*"
|
||||
lexopt = "0.3"
|
||||
7
LICENSE
Normal file
7
LICENSE
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright 2026 Kevin Lynagh
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
12
build.rs
Normal file
12
build.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
let sha = Command::new("git")
|
||||
.args(["rev-parse", "--short", "HEAD"])
|
||||
.output()
|
||||
.map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string())
|
||||
.unwrap_or_else(|_| "unknown".into());
|
||||
|
||||
println!("cargo:rustc-env=GIT_SHA={sha}");
|
||||
println!("cargo:rerun-if-changed=.git/HEAD");
|
||||
}
|
||||
91
docs/implementations.md
Normal file
91
docs/implementations.md
Normal file
@@ -0,0 +1,91 @@
|
||||
# Implementations
|
||||
|
||||
## Definitions
|
||||
|
||||
### Vibebox Command
|
||||
|
||||
Commands for vibebox, the format is `:<command>`
|
||||
|
||||
### Box Command
|
||||
|
||||
Commands for general vm spawned by the vibebox, a typical linux command,
|
||||
the format is as same as the linux, `<command>`
|
||||
|
||||
### Data Storage
|
||||
|
||||
Global session index is stored in `~/.vibebox/sessions.toml`.
|
||||
|
||||
Global images are stored in `~/.vibebox/images`.
|
||||
|
||||
Project config is stored in `[project_dir]/vibebox.toml`, this should be committed to VCS.
|
||||
|
||||
Project cache should be stored in `[project_dir]/.vibebox/`.
|
||||
|
||||
### Session management
|
||||
|
||||
Each session represents an underlying VM instance, users can quit, enter, spawn a session.
|
||||
|
||||
A session is represented by a UUID(RFC 4122 variant),and it is UUIDv7.
|
||||
|
||||
Example:
|
||||
|
||||
`019bf290-cccc-7c23-ba1d-dce7e6d40693`
|
||||
|
||||
Each session has the following members:
|
||||
|
||||
- `id`: session id
|
||||
- `directory`: project directory (absolute)
|
||||
- `last_active`: utc time indicating the last active time for the session
|
||||
|
||||
Sessions info are stored in `~/.vibebox/sessions.toml`
|
||||
|
||||
A session can be shut down, resumed, deleted, created.
|
||||
|
||||
A session links to a directory. Currently, a directory can only have a single session; a session can be connected to
|
||||
multiple vibeboxes.
|
||||
|
||||
Instance data are stored in `project_dir/.vibebox`.
|
||||
|
||||
Deleting `[project_dir]/.vibebox/` permanently deletes the session. The global index entry (if any) will be removed by
|
||||
any command that uses the global index but failed to locate.
|
||||
|
||||
There is a reference count for each session, and this represents the number of `vibebox` using that session.
|
||||
|
||||
A session (VM) will only shut down after `AUTO_SHUTDOWN_GRACE_MS` milliseconds if the reference count is 0. Shutting a
|
||||
session down can save some resources, but the first startup time will be larger than resuming an active session.
|
||||
|
||||
When a session shuts down, the VM stops, but the instance disk in project_dir/.vibebox/ is preserved for faster
|
||||
later boots.
|
||||
|
||||
#### Behavior
|
||||
|
||||
In host cli:
|
||||
|
||||
- use `vibebox` without config to connect to an exising session, or create a new one if not existed.
|
||||
- use `vibebox delete <session_id>` to delete an existed session, delete <session_id> removes
|
||||
`[session.directory]/.vibebox/` and deletes the global index entry.
|
||||
- use `vibebox list` to list a list of sessions
|
||||
|
||||
In vibebox:
|
||||
|
||||
- use `:new` to prompt user to delete and create a session.
|
||||
- use `:exit` to exit vibebox.
|
||||
|
||||
### (Shows all the mounts/network/visibility)
|
||||
|
||||
Each session has mounts, meaning it has a file system mapping from host to the inner VM, this has a default value, and
|
||||
users can add new mounts to it.
|
||||
|
||||
Each session also has its own network mapping, users can choose to use blocklist or allowlist mode to control the
|
||||
traffic by hostname/domain.
|
||||
|
||||
The command can display the mapping and network strategy.
|
||||
|
||||
They are also stored per project, in `vibebox.toml`
|
||||
|
||||
#### Behaviors
|
||||
|
||||
- use `:explain` to display:
|
||||
- mounts: host_path → guest_path, ro/rw
|
||||
- network: mode (allowlist/blocklist) and entries
|
||||
- storage: paths to vibebox.toml and .vibebox/ (relative from the project_dir)
|
||||
22
docs/new_features.md
Normal file
22
docs/new_features.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# New Features
|
||||
|
||||
## Priority 1
|
||||
|
||||
### Session management
|
||||
|
||||
1. each session is a folder
|
||||
2. by default, there should be a reference count for each vm, if count is 0, shutdown in DEFAULT_EXPECT_TIMEOUT.
|
||||
3. You can also use command inside a session to never allow it to auto shutdown
|
||||
4. you can use commands to resume a session
|
||||
|
||||
### explain (Shows all the mounts/network/visibility)
|
||||
|
||||
1. you can display all the mounts & network activity.
|
||||
2. you can set disable to disable a network connection.
|
||||
3. use a config file in .vibebox/config.toml to config it
|
||||
|
||||
## Priority 2
|
||||
|
||||
### Port Forwarding
|
||||
|
||||
1. Port will be auto forwarded to the host
|
||||
47
docs/old_features.md
Normal file
47
docs/old_features.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# Existing Features (Legacy Snapshot)
|
||||
|
||||
This document summarizes the currently implemented features in the repo at the time of review.
|
||||
|
||||
## Core Purpose
|
||||
- Single-binary CLI to spin up a Linux VM on Apple Silicon macOS for sandboxing LLM agents.
|
||||
- Uses Apple Virtualization framework with a lightweight Debian nocloud image.
|
||||
|
||||
## VM Lifecycle
|
||||
- Downloads a Debian base image on first run and verifies SHA-512 before use.
|
||||
- Decompresses the base image and provisions it once, saving as a default template.
|
||||
- Creates a per-project instance disk at `.vibe/instance.raw` on first run.
|
||||
- Instance disks persist across runs until manually deleted.
|
||||
|
||||
## Default Sharing and Mounts
|
||||
- Automatically shares the current project directory into the VM.
|
||||
- Shares common cache/config directories when present:
|
||||
- `~/.m2`, `~/.cargo/registry`, `~/.codex`, `~/.claude`.
|
||||
- Maintains a dedicated guest mise cache at `~/.cache/vibe/.guest-mise-cache` on the host.
|
||||
- Supports disabling default mounts with `--no-default-mounts`.
|
||||
- Supports explicit mounts via `--mount host:guest[:read-only|:read-write]`.
|
||||
|
||||
## CLI Options and Automation
|
||||
- `--cpus` and `--ram` to configure virtual CPU count and memory size.
|
||||
- `--script` to upload and run a shell script inside the VM.
|
||||
- `--send` to type a command into the VM console.
|
||||
- `--expect` to wait for console output before continuing with script or send actions.
|
||||
- Optional disk image argument to boot an existing raw disk directly.
|
||||
|
||||
## Console and Login Experience
|
||||
- Auto-login as root by waiting for login prompt.
|
||||
- Mounts shared directories using virtiofs, then bind-mounts to target paths.
|
||||
- Prints a startup MOTD showing host and guest mount mappings.
|
||||
- Streams VM console to the terminal with raw mode for interactive use.
|
||||
|
||||
## Security and Signing
|
||||
- Checks for `com.apple.security.virtualization` entitlement on startup.
|
||||
- Self-signs the binary with the required entitlement if missing, then re-execs.
|
||||
|
||||
## Networking and Devices
|
||||
- NAT networking enabled by default.
|
||||
- Virtio block device for storage and virtio entropy device for randomness.
|
||||
- Serial console plumbing between host and guest for I/O.
|
||||
|
||||
## Platform Assumptions
|
||||
- ARM-based macOS (Ventura or newer) is required.
|
||||
- First run requires network access to fetch the base image.
|
||||
208
readme.md
Normal file
208
readme.md
Normal file
@@ -0,0 +1,208 @@
|
||||
Vibe is a quick, zero-configuration way to spin up a Linux virtual machine on Mac to sandbox LLM agents:
|
||||
|
||||
```
|
||||
$ cd my-project
|
||||
$ vibe
|
||||
|
||||
░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░▒▓███████▓▒░░▒▓████████▓▒░
|
||||
░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░
|
||||
░▒▓█▓▒▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░
|
||||
░▒▓█▓▒▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓██████▓▒░
|
||||
░▒▓█▓▓█▓▒░ ░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░
|
||||
░▒▓█▓▓█▓▒░ ░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░
|
||||
░▒▓██▓▒░ ░▒▓█▓▒░▒▓███████▓▒░░▒▓████████▓▒░
|
||||
|
||||
Host Guest Mode
|
||||
---------------------------------------- ----------------------- ----------
|
||||
/Users/dev/work/my-project /root/my-project read-write
|
||||
/Users/dev/.cache/vibe/.guest-mise-cache /root/.local/share/mise read-write
|
||||
/Users/dev/.m2 /root/.m2 read-write
|
||||
/Users/dev/.cargo/registry /root/.cargo/registry read-write
|
||||
/Users/dev/.codex /root/.codex read-write
|
||||
/Users/dev/.claude /root/.claude read-write
|
||||
|
||||
root@vibe:~/my-project#
|
||||
```
|
||||
|
||||
On my M1 MacBook Air it takes ~10 seconds to boot.
|
||||
|
||||
|
||||
Dependencies:
|
||||
|
||||
- An ARM-based Mac running MacOS 13 (Ventura) or higher.
|
||||
- A network connection is required on the first run to download and configure the Debian Linux base image.
|
||||
- That's it!
|
||||
|
||||
|
||||
## Why use Vibe?
|
||||
|
||||
- LLM agents are more fun to use with `--yolo`, since they're not always interrupting you to approve their commands.
|
||||
- Sandboxing the agent in a VM lets it install/remove whatever tools its lil' transformer heart desires, *without* wrecking your actual machine.
|
||||
- You control what the agent (and thus the upstream LLM provider) can actually see, by controlling exactly what's shared into the VM sandbox.
|
||||
(This project was inspired by me running `codex` *without* `--yolo` and seeing it reading files outside of the directory I started it in --- not cool, bro.)
|
||||
|
||||
I'm using virtual machines rather than containers because:
|
||||
|
||||
- Virtualization is more secure against malicious escapes than containers or the MacOS sandbox framework.
|
||||
- Containers on MacOS require spinning up a virtual machine anyway.
|
||||
|
||||
Finally, as a matter of taste and style:
|
||||
|
||||
- The binary is < 1 MB.
|
||||
- I wrote the entire README myself, 100% with my human brain.
|
||||
- The entire implementation is in one ~1200 line Rust file.
|
||||
- The only Rust dependencies are the [Objc2](https://github.com/madsmtm/objc2) interop crates and the [lexopt](https://github.com/blyxxyz/lexopt) argument parser.
|
||||
- There are no emoji anywhere in this repository.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
Vibe is a single binary built with Rust.
|
||||
|
||||
Download [the latest binary built by GitHub actions](https://github.com/lynaghk/vibe/releases/tag/latest) and put it somewhere on your `$PATH`:
|
||||
|
||||
curl -LO https://github.com/lynaghk/vibe/releases/download/latest/vibe-macos-arm64.zip
|
||||
unzip vibe-macos-arm64.zip
|
||||
mkdir -p ~/.local/bin
|
||||
mv vibe ~/.local/bin
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
|
||||
If you use [mise-en-place](https://mise.jdx.dev/):
|
||||
|
||||
mise use github:lynaghk/vibe@latest
|
||||
|
||||
I'm not making formal releases or keeping a change log.
|
||||
I recommend reading the commit history and pinning to a specific version.
|
||||
|
||||
You can also install via `cargo`:
|
||||
|
||||
cargo install --locked --git https://github.com/lynaghk/vibe.git
|
||||
|
||||
If you don't have `cargo`, you need to install Rust:
|
||||
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||
|
||||
|
||||
## Using Vibe
|
||||
|
||||
|
||||
```
|
||||
vibe [OPTIONS] [disk-image.raw]
|
||||
|
||||
Options
|
||||
|
||||
--help Print this help message.
|
||||
--version Print the version (commit SHA).
|
||||
--no-default-mounts Disable all default mounts.
|
||||
--mount host-path:guest-path[:read-only | :read-write] Mount `host-path` inside VM at `guest-path`.
|
||||
Defaults to read-write.
|
||||
Errors if host-path does not exist.
|
||||
--cpus <count> Number of virtual CPUs (default 2).
|
||||
--ram <megabytes> RAM size in megabytes (default 2048).
|
||||
--script <path/to/script.sh> Run script in VM.
|
||||
--send <some-command> Type `some-command` followed by newline into the VM.
|
||||
--expect <string> [timeout-seconds] Wait for `string` to appear in console output before executing next `--script` or `--send`.
|
||||
If `string` does not appear within timeout (default 30 seconds), shutdown VM with error.
|
||||
```
|
||||
|
||||
Invoking vibe without a disk image:
|
||||
|
||||
- shares the current directory with the VM
|
||||
- shares package manager cache directories with the VM, so that packages are not re-downloaded
|
||||
- shares the `~/.codex` directory with the VM, so you can use OpenAI's [codex](https://openai.com/codex/)
|
||||
- shares the `~/.claude` directory with the VM, so you can use Anthropic's [claude](https://claude.com/product/claude-code)
|
||||
|
||||
The first time you run `vibe`, a Debian Linux image is downloaded to `~/.cache/vibe/`, configured with basic tools like gcc, [mise-en-place](https://mise.jdx.dev/), ripgrep, rust, etc., and saved as `default.raw`.
|
||||
(See [provision.sh](/src/provision.sh) for details.)
|
||||
|
||||
Then when you run `vibe` in a project directory, it copies this default image to `.vibe/instance.raw`, boots it up, and attaches your terminal to this VM.
|
||||
|
||||
When you `exit` this shell, the VM is shutdown.
|
||||
The disk state persists until you delete it.
|
||||
There is no centralized registry of VMs --- if you want to delete a VM, just delete its disk image file.
|
||||
|
||||
## Other notes
|
||||
|
||||
- Apple Filesystem is copy-on-write, so instance images only use disk space when they diverge from the default image.
|
||||
You can use `du -h` to see how much space is actually consumed:
|
||||
|
||||
$ /bin/ls -lah .vibe/instance.raw
|
||||
-rw-r--r-- 1 dev staff 10G Jan 25 20:41 .vibe/instance.raw
|
||||
|
||||
$ du -h .vibe/instance.raw
|
||||
2.3G .vibe/instance.raw
|
||||
|
||||
- MacOS only lets binaries signed with the `com.apple.security.virtualization` entitlement run virtual machines, so `vibe` checks itself on startup and, if necessary, signs itself using `codesign`. SeCuRiTy!
|
||||
|
||||
- Debian "nocloud" is used as a base image because it boots directly to a root prompt.
|
||||
The other images use [cloudinit](https://cloudinit.readthedocs.io/en/latest/), which I found much more complex:
|
||||
- Network requests are made during the boot process, and if you're offline they take several *minutes* to timeout before the login prompt is reached (thanks, `systemd-networkd-wait-online.service`).
|
||||
- Subsequent boots are much slower (at least, I couldn't easily figure out how to remove the associated cloud init machinery).
|
||||
|
||||
|
||||
## Alternatives
|
||||
|
||||
Here's what I tried before writing this solution:
|
||||
|
||||
- [Sandboxtron](https://github.com/lynaghk/sandboxtron/) - My own little wrapper around Mac's `sandbox-exec`.
|
||||
Turns out both Claude Code and Codex rely on this as well, and MacOS doesn't allow creating a sandbox from within a sandbox.
|
||||
I considered writing my own sandboxing rules and running the agents `--yolo`, but didn't like the risk of configuration typos and/or Mac sandbox escapes (there are a lot --- I'm not an expert, but from [this HN discussion](https://news.ycombinator.com/item?id=42084588) I figured virtualization would be safer).
|
||||
|
||||
- [Lima](https://github.com/lima-vm/lima/), quick Linux VMs on Mac. I wanted to like this, ran into too many issues in first 30 minutes to trust it:
|
||||
- The recommended Debian image took 8 seconds to get to a login prompt, even after the VM was already running.
|
||||
- The CLI flags *mutate hidden state*. E.g., If you `limactl start --mount foo` and then later `limactl start --mount bar`, both `foo` and `bar` will be mounted.
|
||||
- Some capabilities are only available via yaml. E.g., the `--mount` CLI flag always mounts at the same path in the guest. If you want to mount at a different path, you have to do that via YAML.
|
||||
- There are many layers of inheritance/defaults, so even if you do write YAML, you can't see the full configuration.
|
||||
|
||||
- [Vagrant](https://developer.hashicorp.com/vagrant/) - I fondly remember using this back in the early 2010's, but based on this [2025 Reddit discussion](https://www.reddit.com/r/devops/comments/1axws75/vagrant_doesnt_support_mac_m1/) it seemed like running it on an ARM-based Mac was A Project and so I figured it'd be easier to roll my own thing.
|
||||
|
||||
- [Tart](https://tart.run/) - I found this via some positive HN comments, but unfortunately wasn't able to run the release binary from their GitHub because it's not signed.
|
||||
They apparently hack around that when installing with homebrew, but I don't use homebrew either.
|
||||
I tried cloning the repo and compiling myself, but the build failed with lots of language syntax errors despite the repo SHA is the same as one of their releases.
|
||||
I assume this is a Swift problem and not Tart's, since this sort of mess happens most times when I try to build Swift. `¯\_(ツ)_/¯`
|
||||
|
||||
- [OrbStack](https://orbstack.dev/) - This looked nice, but seems mostly geared towards container stuff.
|
||||
It runs a single VM, and I couldn't figure out how to have this VM run *without* my entire disk mounted inside of it.
|
||||
I didn't want to run agents via containers, since containers aren't security boundaries.
|
||||
|
||||
- [Apple Container Framework](https://github.com/apple/container) - This looks technically promising, as it runs every container within a lightweight VM.
|
||||
Unfortunately it requires MacOS 26 Tahoe, which wrecks [window resizing](https://news.ycombinator.com/item?id=46579864), adds [useless icons everywhere](https://news.ycombinator.com/item?id=46497712), and otherwise seems to be a mess.
|
||||
Sorry excellent Apple programmers and hardware designers, I hope your management can reign in the haute couture folks before we all have to switch to Linux for professional computing.
|
||||
|
||||
- [QEMU](https://wiki.qemu.org/) - The first prototype of this app was [a single bash script](https://github.com/lynaghk/vibe/blob/1c82fd3b9fabf93abba2680fc856458e97a105cd/qemu.sh) wrapping `qemu`. This worked swimmingly, except for host/guest directory sharing, which ended up being a show-stopper. This is because QEMU doesn't support [virtiofs](https://virtio-fs.gitlab.io/) on Mac hosts, it only supports "9p", which is way slower --- e.g., `mise use node@latest` takes > 10 minutes on 9p and 5 seconds on virtiofs.
|
||||
|
||||
|
||||
## Roadmap / Collaboration
|
||||
|
||||
I wrote this software for myself, and I'm open to pull requests and otherwise collaborating on features that I'd personally use:
|
||||
|
||||
- resizing disk images
|
||||
- forwarding ports from the host to a guest
|
||||
- running `vibe` against a disk image that's already running should connect to the already-running VM
|
||||
- the VM shouldn't shutdown until all host terminals have logged out
|
||||
- if not the above, at least a check and throw a nice error message when you try to start a VM that's already running
|
||||
- a way to make faster-booting even more minimal Linux virtual machines
|
||||
- this should be bootstrappable on Mac; i.e., if the only way to make a small Linux image is with Linux-only tools, the entire process should still be runnable on MacOS via intermediate VMs
|
||||
- propagate an exit code from within VM to the `vibe` command
|
||||
- don't propagate user typing until all provided `--expect` and `--send` actions have completed
|
||||
- CPU core / memory / networking configuration, possibly via flags or via extended attributes on the disk image file
|
||||
- a `--plan` flag which pretty-prints a CLI invocation with all of the default arguments shown
|
||||
- to keep ourselves honest, we should use the same codepath for the actual execution (maybe we can `exec` into the generated command?)
|
||||
- Being fully "explicit" is tricky due to flag interactions.
|
||||
E.g., the friendly `--mount` would need to be decomposed into two flags: One that exposes the host directory in the guest's staging area at `/mnt/shared/` and another flag `--send 'mount --bind ...'`to bind this to the desired guest location.
|
||||
|
||||
I'm not sure about (but open to discussing proposals via GitHub issues):
|
||||
|
||||
- running VMs in the background
|
||||
- supporting Linux hosts
|
||||
- supporting guests beyond Debian Linux
|
||||
- using SSH as a login mechanism; this would eliminate the current stdin/stdout-to-console plumbing (yay!) but require additional setup/configuration (boo!)
|
||||
- making Claude Code work seamlessly
|
||||
- I tried the native installer but it sometimes fails during setup (see 6352d13), so I switched back to NPM via mise which is more reliable.
|
||||
- The `~/.claude` folder is shared in the VM by default, by apparently the `~/.claude.json` file is also required for auth credentials and session history.
|
||||
I'm not sure the best way to share a file between host and VM (virtioFS only works with folders).
|
||||
Also: Wild to me that Anthropic puts both a file and a folder in your home directory --- how rude!
|
||||
|
||||
I'm not interested in:
|
||||
|
||||
- anything related to Docker / containers / Kubernetes / distributed systems
|
||||
8
src/entitlements.plist
Normal file
8
src/entitlements.plist
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.virtualization</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
1216
src/main.rs
Normal file
1216
src/main.rs
Normal file
File diff suppressed because it is too large
Load Diff
62
src/provision.sh
Normal file
62
src/provision.sh
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
set -eux
|
||||
|
||||
# Don't wait too long for slow mirrors.
|
||||
echo 'Acquire::http::Timeout "2";' | tee /etc/apt/apt.conf.d/99timeout
|
||||
echo 'Acquire::https::Timeout "2";' | tee -a /etc/apt/apt.conf.d/99timeout
|
||||
echo 'Acquire::Retries "2";' | tee -a /etc/apt/apt.conf.d/99timeout
|
||||
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
pkg-config \
|
||||
libssl-dev \
|
||||
curl \
|
||||
git \
|
||||
ripgrep
|
||||
|
||||
# Set hostname to "vibe" so it's clear that you're inside the VM.
|
||||
hostnamectl set-hostname vibe
|
||||
|
||||
# Set this env var so claude doesn't complain about running as root.'
|
||||
echo "export IS_SANDBOX=1" >> .bashrc
|
||||
|
||||
# Shutdown the VM when you logout
|
||||
cat > .bash_logout <<EOF
|
||||
systemctl poweroff
|
||||
sleep 100 # sleep here so that we don't see the login screen flash up before the shutdown.
|
||||
EOF
|
||||
|
||||
|
||||
# Install Rust
|
||||
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --component "rustfmt,clippy"
|
||||
|
||||
|
||||
# Install Mise
|
||||
curl https://mise.run | sh
|
||||
echo 'eval "$(~/.local/bin/mise activate bash)"' >> .bashrc
|
||||
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
eval "$(mise activate bash)"
|
||||
|
||||
mkdir -p .config/mise/
|
||||
|
||||
cat > .config/mise/config.toml <<MISE
|
||||
[settings]
|
||||
# Always use the venv created by uv, if available in directory
|
||||
python.uv_venv_auto = true
|
||||
experimental = true
|
||||
idiomatic_version_file_enable_tools = ["rust"]
|
||||
|
||||
[tools]
|
||||
uv = "0.9.25"
|
||||
node = "24.13.0"
|
||||
"npm:@openai/codex" = "latest"
|
||||
"npm:@anthropic-ai/claude-code" = "latest"
|
||||
MISE
|
||||
|
||||
touch .config/mise/mise.lock
|
||||
mise install
|
||||
|
||||
# Done provisioning, power off the VM
|
||||
systemctl poweroff
|
||||
Reference in New Issue
Block a user