Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions macs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ These machine are aarch64-darwin hosts.
- mac04.ofborg.org
- mac05.ofborg.org

## MDM Bootstrap

Machines provisioned via MDM (e.g. Mosyle) use the `mdm-bootstrap.sh` script for
initial activation. This replaces the legacy `activate-user` + `activate`
sequence with the recommended `darwin-rebuild activate` approach.

The MDM bootstrap flow is:

```
systemConfig="$(readlink -f ./result)"
nix-env -p /nix/var/nix/profiles/system --set "$systemConfig"
./mdm-bootstrap.sh
```

See [mdm-bootstrap.sh](./mdm-bootstrap.sh) for details.

## Install

- Login to user hetzner with the given password
Expand Down
43 changes: 43 additions & 0 deletions macs/mdm-bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#! /usr/bin/env bash

# MDM Bootstrap script for nix-darwin Mac builders
#
# This script is intended to be run by an MDM solution (e.g. Mosyle)
# during initial machine bootstrap, after building the nix-darwin
# configuration into a ./result symlink.
#
# It replaces the deprecated activate-user step with the recommended
# darwin-rebuild activate approach.

set -euo pipefail

if [[ $EUID -ne 0 ]]; then
echo "$0: please run this script as root"
exit 1
fi

if [[ ! -e ./result ]]; then
echo "$0: no ./result symlink found. Build your nix-darwin configuration first."
exit 1
fi

systemConfig="$(readlink -f ./result)"

if [[ ! -d $systemConfig ]]; then
echo "$0: $systemConfig does not exist or is not a directory"
exit 1
fi

nix-env -p /nix/var/nix/profiles/system --set "$systemConfig"

if [[ -x "$systemConfig/sw/bin/darwin-rebuild" ]]; then
echo "Activating system via darwin-rebuild activate..."
"$systemConfig/sw/bin/darwin-rebuild" activate
else
echo "darwin-rebuild not found; falling back to legacy activation."
if [[ -x "$systemConfig/activate-user" ]]; then
echo "WARNING: activate-user is deprecated and will be removed in nix-darwin 25.11."
"$systemConfig/activate-user"
fi
"$systemConfig/activate"
fi