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

Tracking issue for improving launchd support #1219

Open
5 tasks
Enzime opened this issue Dec 8, 2024 · 7 comments
Open
5 tasks

Tracking issue for improving launchd support #1219

Enzime opened this issue Dec 8, 2024 · 7 comments

Comments

@Enzime
Copy link
Collaborator

Enzime commented Dec 8, 2024

  • Make sure all nix-darwin managed units are loaded in
  • Back up existing files before replacing them
  • Restore backed up files when uninstalling nix-darwin
  • Replace usage of {un,}load and boot{out,strap}
  • Use more descriptive names than sh for Login Items in System Settings
@Enzime Enzime changed the title Tracking issue for improving launchd Tracking issue for improving launchd support Dec 8, 2024
@Samasaur1
Copy link
Contributor

Should this also include the work that needs to be done to have them show with nicer names in System Settings, or should that be its own tracking issue?

@Enzime
Copy link
Collaborator Author

Enzime commented Dec 8, 2024

Updated 👍

@lloeki
Copy link

lloeki commented Jan 6, 2025

Replace usage of {un,}load and boot{out,strap}

I've opened an issue heavily related to that, because for LaunchAgents it can get tricky: #1255

@Samasaur1
Copy link
Contributor

Use more descriptive names than sh for Login Items in System Settings

also I've said this on Matrix before but just to get it down on GitHub, the plan for this is:

  1. merge Allow linking files into place anywhere on the system #1205

  2. merge upcoming followup PR that allows copying files into place

  3. replace this section:

    config = {
    command = mkIf (config.script != "") (pkgs.writeScript "${name}-start" ''
    #! ${stdenv.shell}
    ${config.script}
    '');
    serviceConfig.Label = mkDefault "${cfg.labelPrefix}.${name}";
    serviceConfig.ProgramArguments = mkIf (config.command != "") [
    "/bin/sh"
    "-c"
    "/bin/wait4path /nix/store && exec ${config.command}"
    ];
    serviceConfig.EnvironmentVariables = mkIf (env != {}) env;
    };

    with an implementation that builds a binary wrapper with the a filename equal to the service name that calls /bin/wait4path on the Nix store and then executes config.command, copies that binary somwhere not in the Nix store, and then sets up a plist that calls that copied binary

@lloeki
Copy link

lloeki commented Jan 6, 2025

copies that binary somwhere not in the Nix store

I'm curious, why is that?

@Samasaur1
Copy link
Contributor

copies that binary somwhere not in the Nix store

I'm curious, why is that?

For the same reason that our current implementation uses wait4path: if the executable is on a volume that isn't the root, and that volume hasn't mounted by the time the launchagent or launchdaemon starts, the service will fail repeatedly until it is put in the "penalty box" and then won't start at all. By copying the binary onto the root volume, we avoid this error, and then that binary waits for the Nix store before running the actual executable

@lloeki
Copy link

lloeki commented Jan 6, 2025

Ah yes of course, what a brain glitch on my part.

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

3 participants