Configuration
mas ▁▁▁▁ 6.0.1
slice ▁▁ arm64
slices ▁ arm64
dist ▁▁▁ homebrew/core/mas
origin ▁ https://github.com/mas-cli/mas.git
swift ▁▁ 6.2.4 (swiftlang-6.2.4.1.4 clang-1700.6.4.2)
driver ▁ 1.127.15
store ▁▁ US
region ▁ US
macos ▁▁ 26.4 (25E246)
mac ▁▁▁▁ Macmini9,1
cpu ▁▁▁▁ Apple M1
arch ▁▁▁ arm64
Bug description
When using nix-darwin with the homebrew.masApps option, brew bundle is invoked during system activation (via sudo darwin-rebuild switch --flake ...). The masApps entries consistently fail with:
Error: Unable to install <AppName>. mas installation failed.
This happens even when the apps are already installed and up to date. Running mas install <id> directly in a user terminal works fine and correctly reports Warning: Already installed <AppName> (<id>).
Steps to reproduce
- Install nix-darwin with the nix-homebrew module
- Add
masApps entries to the homebrew configuration in flake.nix:
homebrew = {
enable = true;
brews = [ "mas" ];
masApps = {
"Xcode" = 497799835;
"Logic" = 634148309;
"Final" = 424389933;
};
};
- Run
sudo darwin-rebuild switch --flake ~/.config/nix-darwin
- Observe the activation output:
Using cloudmounter
Using ipfs-desktop
Using betterdisplay
Using cameracontroller
Using vcam
Error: Unable to install Final app. mas installation failed.
The error appears for one or more of the masApps entries on every activation.
- Verify
mas install works directly:
$ mas install 424389933
Warning: Already installed Final Cut Pro (424389933)
Expected behavior
brew bundle should succeed for masApps entries when the apps are already installed, similar to how mas install correctly handles this case when run directly.
Actual behavior
brew bundle reports mas installation failed during nix-darwin activation, even for already-installed apps.
Analysis
The likely cause is a session mismatch: nix-darwin runs brew bundle under sudo during system activation. The installd / App Store service requires the logged-in user's session context. When brew bundle invokes mas under sudo, the connection to the installation service fails because the root session cannot talk to the user-session installd.
Running mas install directly in a user terminal (same user, same session) works without issue.
Workaround
Comment out masApps in the nix-darwin flake and manage Mac App Store apps manually via the App Store or by running mas install directly. The cleanup = "zap" option in nix-darwin's homebrew module only affects brews, casks, and taps — it does not uninstall MAS apps.
Possibly related
Configuration
Bug description
When using nix-darwin with the
homebrew.masAppsoption,brew bundleis invoked during system activation (viasudo darwin-rebuild switch --flake ...). ThemasAppsentries consistently fail with:This happens even when the apps are already installed and up to date. Running
mas install <id>directly in a user terminal works fine and correctly reportsWarning: Already installed <AppName> (<id>).Steps to reproduce
masAppsentries to the homebrew configuration inflake.nix:sudo darwin-rebuild switch --flake ~/.config/nix-darwinThe error appears for one or more of the
masAppsentries on every activation.mas installworks directly:Expected behavior
brew bundleshould succeed formasAppsentries when the apps are already installed, similar to howmas installcorrectly handles this case when run directly.Actual behavior
brew bundlereportsmas installation failedduring nix-darwin activation, even for already-installed apps.Analysis
The likely cause is a session mismatch: nix-darwin runs
brew bundleundersudoduring system activation. Theinstalld/ App Store service requires the logged-in user's session context. Whenbrew bundleinvokesmasundersudo, the connection to the installation service fails because the root session cannot talk to the user-sessioninstalld.Running
mas installdirectly in a user terminal (same user, same session) works without issue.Workaround
Comment out
masAppsin the nix-darwin flake and manage Mac App Store apps manually via the App Store or by runningmas installdirectly. Thecleanup = "zap"option in nix-darwin's homebrew module only affects brews, casks, and taps — it does not uninstall MAS apps.Possibly related
purchase/install/upgradefail withPKInstallErrorDomain 201on macOS 26.1, 15.7.2 & 14.8.2 #1029 (purchase/install/upgradefail withPKInstallErrorDomain 201) — fixed in 4.0.0, but thebrew bundle/ sudo context issue persists on 6.0.1