Skip to content

Commit 928028d

Browse files
committed
macs: replace deprecated activate-user with darwin-rebuild activate in MDM bootstrap
The activate-user script is deprecated in nix-darwin and will be removed in 25.11. The deprecation warning advises using darwin-rebuild activate instead, which handles both user and system activation. This change: - Adds mdm-bootstrap.sh, a proper bootstrap script for MDM-provisioned Mac builders that uses darwin-rebuild activate instead of the legacy activate-user + activate sequence - Updates the macs/README.md with MDM bootstrap documentation Fixes #1043
1 parent 8eeb5fa commit 928028d

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

macs/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,22 @@ These machine are aarch64-darwin hosts.
6565
- mac04.ofborg.org
6666
- mac05.ofborg.org
6767

68+
## MDM Bootstrap
69+
70+
Machines provisioned via MDM (e.g. Mosyle) use the `mdm-bootstrap.sh` script
71+
for initial activation. This replaces the legacy `activate-user` + `activate`
72+
sequence with the recommended `darwin-rebuild activate` approach.
73+
74+
The MDM bootstrap flow is:
75+
76+
```
77+
systemConfig="$(readlink -f ./result)"
78+
nix-env -p /nix/var/nix/profiles/system --set "$systemConfig"
79+
./mdm-bootstrap.sh
80+
```
81+
82+
See [mdm-bootstrap.sh](./mdm-bootstrap.sh) for details.
83+
6884
## Install
6985

7086
- Login to user hetzner with the given password

macs/mdm-bootstrap.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#! /usr/bin/env bash
2+
3+
# MDM Bootstrap script for nix-darwin Mac builders
4+
#
5+
# This script is intended to be run by an MDM solution (e.g. Mosyle)
6+
# during initial machine bootstrap, after building the nix-darwin
7+
# configuration into a ./result symlink.
8+
#
9+
# It replaces the deprecated activate-user step with the recommended
10+
# darwin-rebuild activate approach.
11+
12+
set -euo pipefail
13+
14+
if [[ $EUID -ne 0 ]]; then
15+
echo "$0: please run this script as root"
16+
exit 1
17+
fi
18+
19+
if [[ ! -e ./result ]]; then
20+
echo "$0: no ./result symlink found. Build your nix-darwin configuration first."
21+
exit 1
22+
fi
23+
24+
systemConfig="$(readlink -f ./result)"
25+
26+
if [[ ! -d "$systemConfig" ]]; then
27+
echo "$0: $systemConfig does not exist or is not a directory"
28+
exit 1
29+
fi
30+
31+
nix-env -p /nix/var/nix/profiles/system --set "$systemConfig"
32+
33+
if [[ -x "$systemConfig/sw/bin/darwin-rebuild" ]]; then
34+
echo "Activating system via darwin-rebuild activate..."
35+
"$systemConfig/sw/bin/darwin-rebuild" activate
36+
else
37+
echo "darwin-rebuild not found; falling back to legacy activation."
38+
if [[ -x "$systemConfig/activate-user" ]]; then
39+
echo "WARNING: activate-user is deprecated and will be removed in nix-darwin 25.11."
40+
"$systemConfig/activate-user"
41+
fi
42+
"$systemConfig/activate"
43+
fi

0 commit comments

Comments
 (0)