-
-
Notifications
You must be signed in to change notification settings - Fork 476
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
Broken LaunchAgent
s with launchctl
2.0
#1255
Comments
What's your macOS version? I'm pretty sure I've had all-user LaunchAgents work for me before |
TBF I'm still wrapping my head around this
That said, the need to provide a uid kind of hints at a few things, e.g say you have:
In multi-user (say, |
I think the general consensus is that in an ideal world nix-darwin shouldn't manage per-user LaunchAgents ( |
Latest Sequoia. The thing is, the usage of the legacy commands make things wildly unpredictable: I've had a config working on one machine and the exact same config failing on another. The only difference I see is that I created and set up the plist manually on the first one before removing it and making it declarative, which left some state that made it work. On the clean one it failed, and now after a bit of mucking, it also fails on the new one. |
That's the thing, there doesn't seem to be one, you have to pass the user id, which leads to having to declare users in config (otherwise you can't get a reliable list?) |
do you know whether that properly enables a service for users other than the activating user? |
Unknown. I'll sort my particular problem out eventually, but the core issue remains anyway:
This makes systemwide LaunchAgents via |
I can't figure out how to remove the plist manually and stop the service, perhaps I mucked it up by removing the file before disable/bootout? |
This:
Results in a
/Library/LaunchAgents/com.some.agent.plist
, as expected.Unfortunately it gets loaded by
launchtl load
in aroot
context (either because directly doingsudo darwin-rebuild
ordarwin-rebuild
invoking asudo
password prompt):The root cause here is that launchctl 2.0 (introduced in macOS 10.10), there's a more precise domain system:
... and a corresponding more explicit CLI has been added (notably the domain must be explicitly provided):
Legacy commands like
launchctl load
andlaunchctl unload
attempt to guess the user intent:The consequence of the current code is than in a root context
launchctl load
apparently mistakenly makes theLaunchAgent
aLaunchDaemon
on thesystem
domain:Which is, well, wrong.
As far as the current code is concerned I found these:
nix-darwin/modules/system/launchd.nix
Lines 18 to 32 in ba9b317
nix-darwin/modules/system/launchd.nix
Lines 34 to 48 in ba9b317
And these:
nix-darwin/modules/system/launchd.nix
Lines 113 to 114 in ba9b317
nix-darwin/modules/system/launchd.nix
Lines 126 to 127 in ba9b317
nix-darwin/modules/system/launchd.nix
Lines 151 to 152 in ba9b317
The text was updated successfully, but these errors were encountered: