# Images

An image is a macOS installed from Apple's restore image; a twin is a copy-on-write clone of one. This page is how the images are made and kept small.

## The four images

- `tahoe`: macOS from Apple, at the setup assistant. Made by `twin image install tahoe`.
- `tahoe-golden`: a user `twin` with automatic login, sudo without a password, twin's agent
  started at boot, twin allowed to control System Events, no sleep, no automatic updates, no key
  repeat, dark mode, a black wallpaper, no widgets, SSH on. Made by the setup assistant, then
  `seed.sh` and `golden.sh`.
- `tahoe-dev`: the golden image, and Xcode's command line tools, Homebrew, git, Node with npm and
  pnpm, Bun, Python with uv, jq, ripgrep, fd, gh. Made by `dev.sh`.
- `tahoe-lean`: the developer image with Spotlight indexing, Siri, widgets, photo and media
  analysis, suggestions and Time Machine off, at 4 GB. Made by `lean.sh`.

The scripts are in the repository, in `images/macos/`. Each image is saved with
`twin image make <name> --from <twin>` from a stopped twin, so they share their blocks on disk:
`tahoe-dev` holds about 3 GB more than `tahoe-golden`.

## Making the golden image

1. `twin create prep --from tahoe` and `twin up prep`.
2. Go through the setup assistant on its screen, with `twin screenshot` and `twin click`: English,
   the region, a new user `twin` with the password `twin`, no Apple Account, no location, no
   analytics, no FileVault.
3. Run `seed.sh` once as root in the guest: it puts the agent in place and turns on automatic
   login. From then on nothing is typed on the screen.
4. Let twin control System Events: run any `osascript` that talks to it through `twin sh`, and
   click **Allow** in the dialog macOS shows. Style steps need it, and every clone keeps the
   answer. The first click on a fresh screen can be taken as focus: look, and click again.
5. Everything else goes through the agent:

```sh
twin put prep images/macos/golden.sh /tmp/golden.sh
twin sh prep --sudo -- 'sh /tmp/golden.sh'
twin down prep
twin image make tahoe-golden --from prep
```

A script goes in as a file, not through standard input: a program in it that reads its own input,
such as `brew install`, would read the rest of the script and the script would end there.

## Sizes

An image keeps the processors and memory it was installed with; `twin create` and
`twin image make` take `--cpus` and `--memory` to change them for that clone. A running twin holds
its memory plus about 1.5 GB on the host and keeps it until it stops, so the default for a new
image is 4 GB.

| Guest | Ready for commands | Held on the host |
| --- | --- | --- |
| 8 GB, 4 processors | 18.1 s | 7.6 GB |
| 4 GB, 4 processors | 16.7 s | 5.6 GB |
| 8 GB, 6 processors | 14.7 s | 8.4 GB |

## Sharing images

macOS's license does not let us hand out copies of macOS, and Xcode's command line tools may not
be passed on either. So twin does not download ready images from us: every image is installed
from Apple on the Mac it runs on.
