Scripts and instructions for making ephemeral macOS machines with Mosyle MDM support.
Shell
89
214 commits
updated Aug 6, 2025
Internally, we use this tooling to support the testing of our software on macOS, and the Nix installer itself.
This repository makes many assumptions about your workflow and how you want to use this code. These assumptions are a byproduct of the repository only being used internally, and are likely not difficult to remove. If you use this code and documentation for yourself, consider sending contributions upstream that make it easier for people to use.
Set up macOS machines to automatically erase and provision themselves on a Tailscale network with Buildkite. An erase/reinstall cycle can complete in less than 10 minutes, making it suitable for regular automation.
This README and tooling is public documentation for Determinate Systems, Inc.'s internal use. The goal of making it public is to share the information, and foster the use of ephemeral macOS machines running Nix.
Front:
Back:
Select the device in Management,
then Devices Overview,
then select the More menu.
Click Erase device.
Change Obliteration Behavior to Do not Obliterate.
This requires a T2 or Apple Silicon chip.
See "ObliterationBehavior" on https://developer.apple.com/documentation/devicemanagement/erasedevicecommand/command/.
After erasing, the machine should fully boot and configure itself without any human interaction. The main tasks here are to configure the region, language, and the initial user account.
On the Organization tab,
select Apple Basic Setup,
select Enrollment,
click Automated Device Enrollment
to get to the Device Enrollment (DEP) page.
Click your default profile.
If enabled, macOS will automatically advance through all Setup Assistant screens. Available for macOS 11+ when connected to Ethernet.Prompt user to create an accountCreate additional local admin during Setup Assistantephemeraladmin for the username. Note that other pieces of this system depends on the user being named ephemeraladmin.Password dropdown to automatically generate a password for each deviceSet this account to be managed.Rename devices after enrollment to mac-ephemeral-%SerialNumber%Click Save.
The described automation is applied to specific machines through Device Groups.
On the Management tab,
on the left side under Devices,
select Device Groups,
click Add Device Group.
Ephemeral CIClick Save.
In general, software updates should be applied quickly and without any user interaction. I want to be able to forget this machine exists after setup, so we have fully automated the update process.
On the Management tab,
on the left side under Management Profiles,
select Software Update,
click Add new profile.
If the profile type isn't there,
click Activate New Profile Type,
search for it by name,
click Activate,
then click Add new profile.
Automatic UpdatesUnder Profile Assignment,
click + Add Assignment,
select Devices from specific Devices Group,
tick Ephemeral CI.
Click Save.
If the machine sleeps it is generally not easy to wake it back up.
On my Mac Studio, waking it back up requires physically pressing the Power button on the back.
I tried using a wireless mouse and a KVM, but neither were able to replace it.
This profile disables sleeping.
On the Management tab,
on the left side under Management Profiles,
select Energy Saver,
click Add new profile.
If the profile type isn't there,
click Activate New Profile Type,
search for it by name,
click Activate,
then click Add new profile.
Don't sleepDesktop profile tabPut the display(s) to sleep after: to 2 minutesPut the computer to sleep after: to NeverPut the hard disk(s) to sleep after to Do not configure this optionWake options, tick Wake for Ethernet network administrator accessOther options, tick Start up automatically after a power failureUnder Profile Assignment,
click + Add Assignment,
select Devices from specific Devices Group,
tick Ephemeral CI.
Click Save.
Our provisioning script uses SSH keys stored on an external volume to survive wipes. Apple widely prohibits programs from reading removable storage. This means Mosyle MDM agent cannot access removable media out of the box.
This profile allows Mosyle to access removable storage.
Note that we don't actually enable anything in this profile except a single checkbox for the Self-Service app. That is intentional: that tickbox is all we need.
On the Management tab,
on the left side under Management Profiles,
select Security & Privacy,
near the top of the screen select the Privacy tab
click Add new profile.
If the profile type isn't there,
click Activate New Profile Type,
search for it by name,
click Activate,
then click Add new profile.
Allow Mosyle access to Removable VolumesInstall the Privacy Preferences Policy Control settings for the Mosyle Self-Service app to allow access to all necessary files and application data.Under Profile Assignment,
click + Add Assignment,
select Devices from specific Devices Group,
tick Ephemeral CI.
Click Save.
Autologin is necessary to allow fast erases and reprovisions.
Modern macOS software and hardware has two erase modes: "Erase All Content and Settings" (EACS) and "Obliterate". EACS takes approximately 5 minutes and involves a brief reboot after clearing the existing content and settings. Obliterate completely erases the disk and then rewrites the operating system, annd can take up to several hours. Obliterate is the only option on older hardware.
EACS is the preferred method of implementing an ephemeral macOS machine because of the fast cycle time. In order for EACS to work, the machine must have a "Bootstrap Token" escrowed with our MDM server. The only way to escrow a bootstrap token is to have an administrative user log in.
This profile creates an administrative user with a random, unknown password, and causes it to automatically log in. After creating the user, the machine is rebooted to cause the login to happen.
On the Management tab,
on the left side under Management Profiles,
select Custom Commands,
click Add new profile.
If the profile type isn't there,
click Activate New Profile Type,
search for it by name,
click Activate,
then click Add new profile.
Autologin as CICode profile tabauto-login.sh into the boxExecution Settings profile tabExecute Command select Only based on schedule or eventsEvent tick Upon Enrollment OnlyUnder Profile Assignment,
click + Add Assignment,
select Devices from specific Devices Group,
tick Ephemeral CI.
Click Save.
Configure SSH keys and start the SSH daemon for the DEP-managed administrative user, ephemeraladmin.
This script runs very frequently to ensure SSH is both running, and your users' keys are on the machine.
On the Management tab,
on the left side under Management Profiles,
select Custom Commands,
click Add new profile.
If the profile type isn't there,
click Activate New Profile Type,
search for it by name,
click Activate,
then click Add new profile.
Setup SSHCode profile tabsetup-ssh.sh into the boxExecution Settings profile tabExecute Command select Only based on schedule or eventsEvent untick Upon Enrollment OnlyEvent tick Every start up of the Mac, Every user sign-in, and Every "Device Info Update".Under Profile Assignment,
click + Add Assignment,
select Devices from specific Devices Group,
tick Ephemeral CI.
Click Save.
Installs Nix and nix-darwin, which is configured to run a Buildkite agent and join our Tailscale network.]
Note that right now this code assumes you're installing everything for DetSys purposes. It is an explicit goal for this repository to support configuring things for your purposes without necessarily having to fork the repo. Please open issues discussing or send PRs improving this.
First configure a tag to assign to ephemeral macs, by adding this to your Tailscale ACL:
"tagOwners": {
"tag:ephemeral-mac-ci": ["you@example.com"],
}
The actual acquisition of pre-auth tokens is done through Vault on our systems (see setup-vault.sh).
Save the buildkite agent token into /Volumes/CONFIG/buildkite.token.
On the Management tab,
on the left side under Management Profiles,
select Custom Commands,
click Add new profile.
If the profile type isn't there,
click Activate New Profile Type,
search for it by name,
click Activate,
then click Add new profile.
Install NixCode profile tabinstall-nix-fetcher.sh into the boxrepo, branch, cfgpath) to point to your repository and configuration.
Note you can use Mosyle's tags and variables to do dynamic configuration dispatch.
See the end for an example.Execution Settings profile tabExecute Command select Only based on schedule or eventsEvent untick Upon Enrollment OnlyEvent tick Every user sign-inUnder Profile Assignment,
click + Add Assignment,
select Devices from specific Devices Group,
tick Ephemeral CI.
Click Save.
Shows the public key of the private key generated on the box.
On the Management tab,
on the left side under Management Profiles,
select Custom Commands,
click Add new profile.
If the profile type isn't there,
click Activate New Profile Type,
search for it by name,
click Activate,
then click Add new profile.
Show Public SSH KeyCode profile tabcat /Volumes/CONFIG/buildkite-agent/sshkey.pub into the boxExecution Settings profile tabExecute Command select Only based on schedule or eventsEvent untick Upon Enrollment OnlyEvent tick Every start up of the MacEvent tick Every user sign-inEvent tick Every "Device info" update"Under Profile Assignment,
click + Add Assignment,
select Devices from specific Devices Group,
tick Ephemeral CI.
Click Save.
repo="https://github.com/DeterminateSystems/macos-ephemeral.git"
branch="HEAD"
cfgpath="config.nix"
if (echo "%Tags%" | grep -q "beta"); then
branch="beta"
cfgpath="configuration.nix"
fi
Shell
76.4%
Nix
23.6%
Scripts and instructions for making ephemeral macOS machines with Mosyle MDM support.
Shell
89
214 commits
updated Aug 6, 2025
Internally, we use this tooling to support the testing of our software on macOS, and the Nix installer itself.
This repository makes many assumptions about your workflow and how you want to use this code. These assumptions are a byproduct of the repository only being used internally, and are likely not difficult to remove. If you use this code and documentation for yourself, consider sending contributions upstream that make it easier for people to use.
Set up macOS machines to automatically erase and provision themselves on a Tailscale network with Buildkite. An erase/reinstall cycle can complete in less than 10 minutes, making it suitable for regular automation.
This README and tooling is public documentation for Determinate Systems, Inc.'s internal use. The goal of making it public is to share the information, and foster the use of ephemeral macOS machines running Nix.
Front:
Back:
Select the device in Management,
then Devices Overview,
then select the More menu.
Click Erase device.
Change Obliteration Behavior to Do not Obliterate.
This requires a T2 or Apple Silicon chip.
See "ObliterationBehavior" on https://developer.apple.com/documentation/devicemanagement/erasedevicecommand/command/.
After erasing, the machine should fully boot and configure itself without any human interaction. The main tasks here are to configure the region, language, and the initial user account.
On the Organization tab,
select Apple Basic Setup,
select Enrollment,
click Automated Device Enrollment
to get to the Device Enrollment (DEP) page.
Click your default profile.
If enabled, macOS will automatically advance through all Setup Assistant screens. Available for macOS 11+ when connected to Ethernet.Prompt user to create an accountCreate additional local admin during Setup Assistantephemeraladmin for the username. Note that other pieces of this system depends on the user being named ephemeraladmin.Password dropdown to automatically generate a password for each deviceSet this account to be managed.Rename devices after enrollment to mac-ephemeral-%SerialNumber%Click Save.
The described automation is applied to specific machines through Device Groups.
On the Management tab,
on the left side under Devices,
select Device Groups,
click Add Device Group.
Ephemeral CIClick Save.
In general, software updates should be applied quickly and without any user interaction. I want to be able to forget this machine exists after setup, so we have fully automated the update process.
On the Management tab,
on the left side under Management Profiles,
select Software Update,
click Add new profile.
If the profile type isn't there,
click Activate New Profile Type,
search for it by name,
click Activate,
then click Add new profile.
Automatic UpdatesUnder Profile Assignment,
click + Add Assignment,
select Devices from specific Devices Group,
tick Ephemeral CI.
Click Save.
If the machine sleeps it is generally not easy to wake it back up.
On my Mac Studio, waking it back up requires physically pressing the Power button on the back.
I tried using a wireless mouse and a KVM, but neither were able to replace it.
This profile disables sleeping.
On the Management tab,
on the left side under Management Profiles,
select Energy Saver,
click Add new profile.
If the profile type isn't there,
click Activate New Profile Type,
search for it by name,
click Activate,
then click Add new profile.
Don't sleepDesktop profile tabPut the display(s) to sleep after: to 2 minutesPut the computer to sleep after: to NeverPut the hard disk(s) to sleep after to Do not configure this optionWake options, tick Wake for Ethernet network administrator accessOther options, tick Start up automatically after a power failureUnder Profile Assignment,
click + Add Assignment,
select Devices from specific Devices Group,
tick Ephemeral CI.
Click Save.
Our provisioning script uses SSH keys stored on an external volume to survive wipes. Apple widely prohibits programs from reading removable storage. This means Mosyle MDM agent cannot access removable media out of the box.
This profile allows Mosyle to access removable storage.
Note that we don't actually enable anything in this profile except a single checkbox for the Self-Service app. That is intentional: that tickbox is all we need.
On the Management tab,
on the left side under Management Profiles,
select Security & Privacy,
near the top of the screen select the Privacy tab
click Add new profile.
If the profile type isn't there,
click Activate New Profile Type,
search for it by name,
click Activate,
then click Add new profile.
Allow Mosyle access to Removable VolumesInstall the Privacy Preferences Policy Control settings for the Mosyle Self-Service app to allow access to all necessary files and application data.Under Profile Assignment,
click + Add Assignment,
select Devices from specific Devices Group,
tick Ephemeral CI.
Click Save.
Autologin is necessary to allow fast erases and reprovisions.
Modern macOS software and hardware has two erase modes: "Erase All Content and Settings" (EACS) and "Obliterate". EACS takes approximately 5 minutes and involves a brief reboot after clearing the existing content and settings. Obliterate completely erases the disk and then rewrites the operating system, annd can take up to several hours. Obliterate is the only option on older hardware.
EACS is the preferred method of implementing an ephemeral macOS machine because of the fast cycle time. In order for EACS to work, the machine must have a "Bootstrap Token" escrowed with our MDM server. The only way to escrow a bootstrap token is to have an administrative user log in.
This profile creates an administrative user with a random, unknown password, and causes it to automatically log in. After creating the user, the machine is rebooted to cause the login to happen.
On the Management tab,
on the left side under Management Profiles,
select Custom Commands,
click Add new profile.
If the profile type isn't there,
click Activate New Profile Type,
search for it by name,
click Activate,
then click Add new profile.
Autologin as CICode profile tabauto-login.sh into the boxExecution Settings profile tabExecute Command select Only based on schedule or eventsEvent tick Upon Enrollment OnlyUnder Profile Assignment,
click + Add Assignment,
select Devices from specific Devices Group,
tick Ephemeral CI.
Click Save.
Configure SSH keys and start the SSH daemon for the DEP-managed administrative user, ephemeraladmin.
This script runs very frequently to ensure SSH is both running, and your users' keys are on the machine.
On the Management tab,
on the left side under Management Profiles,
select Custom Commands,
click Add new profile.
If the profile type isn't there,
click Activate New Profile Type,
search for it by name,
click Activate,
then click Add new profile.
Setup SSHCode profile tabsetup-ssh.sh into the boxExecution Settings profile tabExecute Command select Only based on schedule or eventsEvent untick Upon Enrollment OnlyEvent tick Every start up of the Mac, Every user sign-in, and Every "Device Info Update".Under Profile Assignment,
click + Add Assignment,
select Devices from specific Devices Group,
tick Ephemeral CI.
Click Save.
Installs Nix and nix-darwin, which is configured to run a Buildkite agent and join our Tailscale network.]
Note that right now this code assumes you're installing everything for DetSys purposes. It is an explicit goal for this repository to support configuring things for your purposes without necessarily having to fork the repo. Please open issues discussing or send PRs improving this.
First configure a tag to assign to ephemeral macs, by adding this to your Tailscale ACL:
"tagOwners": {
"tag:ephemeral-mac-ci": ["you@example.com"],
}
The actual acquisition of pre-auth tokens is done through Vault on our systems (see setup-vault.sh).
Save the buildkite agent token into /Volumes/CONFIG/buildkite.token.
On the Management tab,
on the left side under Management Profiles,
select Custom Commands,
click Add new profile.
If the profile type isn't there,
click Activate New Profile Type,
search for it by name,
click Activate,
then click Add new profile.
Install NixCode profile tabinstall-nix-fetcher.sh into the boxrepo, branch, cfgpath) to point to your repository and configuration.
Note you can use Mosyle's tags and variables to do dynamic configuration dispatch.
See the end for an example.Execution Settings profile tabExecute Command select Only based on schedule or eventsEvent untick Upon Enrollment OnlyEvent tick Every user sign-inUnder Profile Assignment,
click + Add Assignment,
select Devices from specific Devices Group,
tick Ephemeral CI.
Click Save.
Shows the public key of the private key generated on the box.
On the Management tab,
on the left side under Management Profiles,
select Custom Commands,
click Add new profile.
If the profile type isn't there,
click Activate New Profile Type,
search for it by name,
click Activate,
then click Add new profile.
Show Public SSH KeyCode profile tabcat /Volumes/CONFIG/buildkite-agent/sshkey.pub into the boxExecution Settings profile tabExecute Command select Only based on schedule or eventsEvent untick Upon Enrollment OnlyEvent tick Every start up of the MacEvent tick Every user sign-inEvent tick Every "Device info" update"Under Profile Assignment,
click + Add Assignment,
select Devices from specific Devices Group,
tick Ephemeral CI.
Click Save.
repo="https://github.com/DeterminateSystems/macos-ephemeral.git"
branch="HEAD"
cfgpath="config.nix"
if (echo "%Tags%" | grep -q "beta"); then
branch="beta"
cfgpath="configuration.nix"
fi
Shell
76.4%
Nix
23.6%