Add a macOS image pipeline mirroring the Windows one: unattended install,
generalization and user creation, driven end to end in QEMU on a KVM host.
lib/images/macos:
- makeOpenCore: OSX-KVM OpenCore ESP with a config.plist rewritten per image —
SMBIOS model + serial/MLB (macserial) + UUID + ROM=en0 MAC (built-in NIC pinned
to PciRoot(0x0)/Pci(0x12,0x0)) for Apple ID / iMessage / App Store; boot disk;
OpenCore self-entry hidden. ident.nix derives MAC+UUID from a seed so the NixOS
module and CLI know the NIC MAC at eval time.
- makeImage: one QEMU session driven by vm-driver.py (QMP + screenshot settle
detection + OCR of the menu bar) — boots the recovery via OpenCore, opens
Terminal (Ctrl-F2 -> Utilities -> Terminal), types the bootstrap command;
vmix-install.sh erases the disk as APFS, lays down the host-extracted installer
app skeleton + a byte-exact SharedSupport.dmg (raw disk mapped to that byte range
of the pkg, dd'd in — Recovery's xar truncates an 18 GB member), runs
startosinstall with the vmix agent pkg. OpenCore is then copied into the image's
ESP so it boots standalone with OVMF.
- customizeImage / templates: boot the image with a FAT-then-HFS+ VMIX volume; the
vmix agent (LaunchDaemon) runs a script as root, records status and powers off —
the macOS counterpart of Windows Audit Mode. generalize creates the admin user +
auto-login (kcpassword), suppresses Setup Assistant, sets hostname/timezone,
grows APFS, and assigns a fresh SMBIOS identity. Templates: noUpdates,
performance, remoteAccess (ssh + screen sharing).
- fetchRecovery: Apple recovery BaseSystem, retried until the pinned Tahoe build
(osrecovery load-balances Sequoia/Tahoe during the rollout). makeAgentPkg builds
a distribution flat pkg on Linux (xar+bom+cpio) for startosinstall --installpackage.
CLI: vmix build/copy/run for macOS (run --macos --vnc, reads the image's MAC from
its ESP), and a `vmix macserial` helper. NixOS module: disks.os.file carrying
_vmixOsType="macos" auto-enables the macOS QEMU profile (AppleSMC+OSK, Skylake
CPU spoof, AHCI system disk, VMware SVGA, pinned NIC); macos.{enable,cpu,mac}.
Status: proven through the installer prepare phase (SharedSupport.dmg mounts,
version 26.6.2 read, SU catalog loads). Two blockers remain, documented in
lib/images/macos/README.md: (1) startosinstall's OSISVerifyBaseSystemOperation
rejects the byte-identical plain-UDIF SharedSupport as "pkgdmg missing a footer"
in this Tahoe recovery/VM; (2) Apple's CDN unreliably serves the Tahoe recovery
during rollout (self-hosting the verified BaseSystem is the robust fix).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XsESshRCoBoUVWV9qKURUF
28 lines
1.3 KiB
Nix
28 lines
1.3 KiB
Nix
# GPT disk with a single HFS+ partition named VMIX. macOS mounts it natively by
|
|
# name at /Volumes/VMIX (its FAT driver rejects Linux-made FAT volumes as
|
|
# "damaged"; HFS+ made by mkfs.hfsplus mounts cleanly). The partition starts at
|
|
# 1 MiB. Files are staged with their target names and copied in via libguestfs.
|
|
# files: list of { source = <path|drv>; name = "dest name"; } — directories copied recursively.
|
|
{ pkgs, lib, ... }:
|
|
{ name ? "vmix", files, size ? "64M" }:
|
|
pkgs.runCommand "${name}-vmix-volume.img" {
|
|
nativeBuildInputs = with pkgs; [ hfsprogs gptfdisk gnutar libguestfs-with-appliance ];
|
|
} ''
|
|
mkdir stage
|
|
${lib.concatMapStringsSep "\n" (f: ''
|
|
mkdir -p "$(dirname "stage/${f.name}")"
|
|
cp -r --no-preserve=mode ${f.source} "stage/${f.name}"
|
|
'') files}
|
|
tar -C stage -cf stage.tar .
|
|
|
|
truncate -s ${size} $out
|
|
sgdisk -n 1:2048:0 -t 1:AF00 -c 1:VMIX $out >/dev/null
|
|
FIRST=$(sgdisk -i 1 $out | sed -n 's/First sector: \([0-9]*\).*/\1/p')
|
|
LAST=$(sgdisk -i 1 $out | sed -n 's/Last sector: \([0-9]*\).*/\1/p')
|
|
truncate -s $(( (LAST - FIRST + 1) * 512 )) hfs.part
|
|
mkfs.hfsplus -v VMIX hfs.part >/dev/null
|
|
|
|
# tar-in takes a host-side tarball and unpacks it into the mounted volume
|
|
guestfish -a hfs.part run : mount /dev/sda / : tar-in stage.tar / : ls / : umount /
|
|
dd if=hfs.part of=$out bs=512 seek=$FIRST conv=notrunc status=none
|
|
''
|