nix-darwin
nix-darwin copied to clipboard
Suggestion: launchd agents/daemons should have an option to prepend `/bin/wait4path /nix/store` to the script
I'm looking at modules/nix/linux-builder.nix
right now and seeing it do
{
serviceConfig = {
ProgramArguments = [
"/bin/sh" "-c"
"/bin/wait4path && exec ${builderWithOverrides}/bin/create-builder"
];
};
};
Searching the repo for wait4path
I'm seeing this used elsewhere as well. And I expect it's something we should be doing for any launch daemon that references things from the nix store.
Given how common this is, it seems like we should just make this easy and add an extra option to the daemon/agent config for waitForNixStore
. This way all these daemons could be specified using the command
or script
options instead of having to fall back to serviceConfig.ProgramArguments
. We could even have it default to true
for any config with serviceConfig.RunAtLoad == true
.
I've been wanting to do this for a while, but I don't think I'll have time to work on this change for at least another 2 months.
Feel free to make a PR, contributions are most definitely welcome :)
Oh wow, I had no idea /bin/wait4path
existed. I wonder if the absence of wait4path
invocations in critical places could explain why I've found that Nix-installed executables appear to go missing briefly after a system update or restarting with "re-open windows" selected… That issue in particular is one reason I've sworn off Nix-installed yabai
.
@montchr most likely, yeah. I had this problem with Nix-installed fish when restoring Terminal windows, so my login shell is actually a C program that invokes /bin/wait4path /nix/store
before exec'ing the real shell. When I first looked into this ages ago I couldn't find any way to force the Nix store to load before GUI apps started launching.