Skip to content
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

Manually removed launchd daemons are not re-added #1199

Open
NoRePercussions opened this issue Nov 26, 2024 · 3 comments
Open

Manually removed launchd daemons are not re-added #1199

NoRePercussions opened this issue Nov 26, 2024 · 3 comments

Comments

@NoRePercussions
Copy link

While debugging a daemon, I removed it with sudo launchctl bootout org.nixos.mydaemon. I expected re-running darwin-rebuild switch would re-add it back, but it does not. It seems that if the unit derivation does not change, the service is assumed to be unchanged and not re-populated: once I made a trivial change to the service definition, switching successfully re-added it.

My expectation is that there is some way to recover the defined launchd state: either doing a simple scan for the presence of services and printing a warning or re-adding if one is missing, or through a flag that forcefully re-bootstraps daemons and agents.

@NoRePercussions
Copy link
Author

I've run into an issue with launchd in which it will refuse to start a process that fails on first launch, instead of auto-restarting as it is configured to do. The only fix so far is to completely regenerate the launchd config. Therefore, this becomes an issue even for users who have not tampered with launchctl.

@Enzime
Copy link
Collaborator

Enzime commented Dec 10, 2024

I’ve created #1219 which also includes fixing this issue

@NoRePercussions This is launchd’s default behaviour as far as I’m aware, if a service doesn’t start up correctly (for example if the program doesn’t exist when the service tries to run like if it comes from the Nix Store) then launchd won’t auto restart the unit and you’ll have to bootout and then bootstrap that service

As of #1052 all services defined from nix-darwin that use command or script (but not ProgramArguments) will automatically wait for Nix Store to appear before attempting to run

@NoRePercussions
Copy link
Author

Great news! Thank you.

Thanks for the tip on launchd, I'll switch away from ProgramArguments in my personal configs to take advantage of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants