-
Notifications
You must be signed in to change notification settings - Fork 4
docs(install): add unattended and MDM installs page for macOS #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tanjadev
wants to merge
2
commits into
main
Choose a base branch
from
tu/mdm-install-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+106
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| --- | ||
| title: "Unattended and MDM installs" | ||
| description: "How to install the Flox macOS package from an MDM or a script with nobody at the keyboard" | ||
| --- | ||
|
|
||
| The Flox `.pkg` can be installed by a device management (MDM) agent or any | ||
| other script with the standard macOS command: | ||
|
|
||
| ```console | ||
| $ sudo installer -pkg flox-<VERSION>.aarch64-darwin.pkg -target / | ||
| ``` | ||
|
|
||
| Use the `x86_64-darwin` package on Intel Macs. The package refuses to install | ||
| on the wrong architecture, so a policy that ships both and lets the installer | ||
| decide is safe. Download links for the current release are on the | ||
| [Install](/install-flox/install#macos) page. | ||
|
|
||
| ## What the installer changes on the machine | ||
|
|
||
| Everything happens in the package's `postinstall` script and runs as root: | ||
|
|
||
| * Adds `nix` to `/etc/synthetic.conf` so that the read-only system volume gets | ||
| an empty `/nix` directory to mount on. | ||
| * Creates an APFS volume named `Nix Store` in the same container as the boot | ||
| disk. When FileVault is on, the volume is encrypted with a random passphrase | ||
| stored in the System keychain. | ||
| * Installs two LaunchDaemons: `org.nixos.darwin-store`, which mounts the | ||
| volume at `/nix` on every boot, and `org.nixos.nix-daemon`. | ||
| * Creates the `nixbld` group and the `_nixbld1` to `_nixbld32` build users. | ||
| * Writes `/etc/nix/nix.conf` and `/etc/nix/flox.conf`, links `flox` and `nix` | ||
| into `/usr/local/bin`, and patches two Apple bugs in `/etc/zshrc`. | ||
|
|
||
| Flox 1.17.0 and later do not write `/etc/fstab`. The mount options for the | ||
| volume are set by the mount service instead. | ||
|
|
||
|
Comment on lines
+33
to
+35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Flox 1.17.0 hasn't been released, so a bit odd to mention it here, but also I don't think this will be true (since we haven't yet prioritized the work to change the existing /etc/fstab behavior). |
||
| ## Older installers and `/etc/fstab` | ||
|
|
||
| Flox 1.16.0 and earlier add a line to `/etc/fstab` with `vifs`. On a Mac that | ||
| has never had Nix, that step fails when the install is driven by an MDM agent, | ||
| and the install log shows: | ||
|
|
||
| ```text | ||
| vifs: error creating /etc/fstab | ||
| ``` | ||
|
|
||
| followed by `PKInstallErrorDomain Code=112`. The same package installs fine | ||
| when you double-click it on the same machine. | ||
|
|
||
| The cause is macOS Transparency, Consent and Control (TCC). PackageKit runs | ||
| package scripts with the TCC identity of the process that called | ||
| `installer`, which under an MDM policy script is the agent itself, and | ||
| `/etc/fstab` is a protected path. The agent has no grant for it, so the write | ||
| is refused. Nothing inside the package can change that. | ||
|
|
||
| <Warning> | ||
| The install stops after the volume has already been created. A machine that | ||
| hit this has a `Nix Store` volume, nothing mounted at `/nix`, no | ||
| LaunchDaemons and no package receipt. Delete the volume before trying again: | ||
|
|
||
| ```bash | ||
| sudo diskutil apfs deleteVolume "Nix Store" | ||
| ``` | ||
| </Warning> | ||
|
|
||
| Two ways to install 1.16.0 or earlier unattended: | ||
|
|
||
| * **Use the native package install command of the MDM** rather than a policy script | ||
| that calls `installer`. That keeps the agent out of the process tree, and the | ||
| scripts run with the identity of an Apple system process that has the grant. | ||
| * **Grant the agent the permission** with a Privacy Preferences Policy Control | ||
| (PPPC) profile that allows `SystemPolicySysAdminFiles` for the agent binary. | ||
| The binary is the one named in the `Set responsibility to pid` line of | ||
| `/var/log/install.log`. A PPPC grant does not appear in System Settings, so | ||
| verify it by running the install rather than by looking. | ||
|
|
||
| ## Machines that already have Nix | ||
|
|
||
| The package behaves differently when `/nix/var/nix/db/db.sqlite` exists and | ||
| Flox is not installed: | ||
|
|
||
| * **Flox 1.16.0 and later** refuse a command-line install and print an | ||
| explanation. Replacing an existing Nix installation with Flox changes the Nix | ||
| daemon and the default profile, so it must be confirmed in the graphical | ||
| installer. Alternatively, install Flox | ||
| [with the existing Nix](/install-flox/install#nix). | ||
| * **Flox 1.15.0** installs nothing and reports success. Both installer choices | ||
| start deselected on such a machine, so an unattended run that appears to | ||
| work has not installed Flox. Check the result as described below. | ||
|
|
||
| ## Verifying a fleet install | ||
|
|
||
| Do not rely on `/etc/flox-version` alone. It is written early in the install | ||
| and can be present after a failed run. Check all of the following: | ||
|
|
||
| ```bash | ||
| pkgutil --pkg-info com.floxdev.flox | ||
| diskutil info /nix | grep 'Mount Point' | ||
| launchctl print system/org.nixos.darwin-store > /dev/null && echo "mount service loaded" | ||
| flox --version | ||
| ``` | ||
|
|
||
| A successful install has a package receipt, `/nix` mounted from the | ||
| `Nix Store` volume, the mount service loaded, and `flox --version` printing | ||
| the installed version. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we need to bother with this paragraph since we're deprecating x86_64-darwin soon anyway.